Right-size generative AI endpoints with concurrency sweeps on Amazon SageMaker AI
https://aws.amazon.com/blogs/machine-learning/right-size-generative-ai-endpoints-with-concurrency-sweeps-on-amazon-sagemaker-ai/📌 併發掃描一次掃出,GPU端點該租幾臺
TL;DR:SageMaker內建併發掃描,自動找出推理端點的最佳實例與併發規格。
多租一臺ml.g7e.2xlarge,就是白燒一顆閒置GPU的錢;租少一臺,請求開始排隊,延遲飆高,使用者體驗直接崩壞。過去要抓對這個平衡點,只能手動部署、手動壓測、手動調整,一輪一輪試到數字看起來還行為止。
🤔 右調規格的老問題
生成式AI端點的容量規劃向來是個反覆試錯的過程:沒有系統化方法時,團隊只能靠「部署→壓測→調整→再部署」的循環摸索,既耗時間也耗預算。Amazon SageMaker AI Inference Recommendations內建的併發掃描(concurrency sweep),要把這個過程變成一套可重複執行的自動化基準測試。
🧩 四步驟工作流程
併發掃描的做法,是對SageMaker AI端點送出受控且遞增的併發流量,並在每個併發等級量測吞吐量與延遲,藉此描繪出端點的效能曲線。整套流程分四步:
- 部署模型:文章以NVIDIA Nemotron-3 Nano 30B(Mixture-of-Experts架構,僅3B個啟用參數)為例,部署到搭載NVIDIA Blackwell GPU的ml.g7e.2xlarge實例,使用SageMaker AI的vLLM Deep Learning Container,透過
SM_VLLM_*環境變數設定。其中SM_VLLM_ENFORCE_EAGER是必要設定,因為Nemotron-3 Nano採用Mamba-Transformer混合架構,需要eager執行模式;GPU記憶體使用率設為0.85,為高併發下的KV cache成長預留空間;並開啟prefix caching,讓重複出現的system prompt能重複使用快取的key-value配對。 - 定義工作負載設定檔:透過
CreateAIWorkloadConfig定義要模擬的流量型態,範例採用1,024個輸入token、256個輸出token,代表典型的RAG(檢索增強生成)或摘要類工作負載;若應用場景是短prompt、長輸出(例如程式碼生成),則需相應調整。設定同時開啟streaming,以量測time to first token(TTFT)。 - 啟動掃描:透過
CreateAIBenchmarkJobAPI發起基準測試工作,由基準測試引擎AIPerf在單一工作內依序執行各個併發等級(例如64、256、1,024),並在每個等級送出設定的請求總數。依序而非平行執行各等級,能確保每次量測反映的是乾淨、獨立的負載狀態,同時控制測試成本。 - 分析結果:工作完成後,結果會以JSON格式的每等級指標寫入指定的Amazon S3路徑,供下載分析。
📊 飽和點在哪裡:256併發是分水嶺
把吞吐量對延遲畫成曲線,飽和點會呈現一個明顯的「拐點」:吞吐量趨於平緩,而p99延遲則急遽上揚。在文章的測試情境中,這個拐點出現在256個併發請求:拐點以下是安全操作區間,超過拐點,端點已經過載,使用者會開始等待。
如果不想手動挑選要測試的併發等級,可以改用max-concurrency-under-sla搜尋方案,直接指定一項或多項SLA門檻,讓最佳化規劃器自動搜尋滿足所有門檻的最高併發數。範例中,規劃器從併發16開始逐輪倍增,在併發512時首次觸發SLA違規(p99端到端延遲超標或請求失敗),接著把搜尋範圍縮小到256至512之間,最終找到併發320能在滿足p99端到端延遲低於50秒的同時,達到每秒2,782個token的吞吐量。而當同時對端到端延遲與TTFT設下SLA門檻時,該情境下端點能支撐的最高併發數則降為80。
💡 用最佳化規劃器省下反覆試探的成本
比起固定併發清單的線性掃描,搜尋方案的規劃器會從較寬的範圍開始,逐步收斂,只評估找出邊界所需的併發等級,因此能用更少的迭代次數與更低的測試成本逼近答案,迭代次數上限則由search_max_iterations控制。
🎯 實務啟示
併發掃描把容量規劃從「憑感覺調整」變成「看資料決策」:先用單一SLA門檻(例如p99延遲)找出基準,再視場景疊加TTFT等互動體驗指標,往往會發現實際可承受的併發數比單一指標算出來的更保守。另外別忘了,SageMaker端點是按小時計費,不論有沒有流量進來,測試完務必刪除端點、端點設定與模型,避免持續產生費用。
🔗 來源
- 標題:Right-size generative AI endpoints with concurrency sweeps on Amazon SageMaker AI
- 作者/機構:Mona Mona,AWS ML
- 連結:https://aws.amazon.com/blogs/machine-learning/right-size-generative-ai-endpoints-with-concurrency-sweeps-on-amazon-sagemaker-ai/
#AWS #SageMaker #LLMInference #vLLM #MoE #NemotronNano #MLOps #CapacityPlanning #GenerativeAI #Blackwell
原始資料 AWS ML · 收集於 2026-09-22
摘要原文
Concurrency sweeps help you right-size a generative AI endpoint by finding the instance type and serving configuration that maximizes price-performance while holding latency within acceptable bounds. Without a systematic approach, right-sizing means deploying, load-testing manually, adjusting, and repeating until the numbers look acceptable. Choose five ml.g7e.2xlarge instances when one would suffice, and you burn your budget on idle GPUs. Choose too few, and requests queue, latency spikes, and users experience degraded service. Concurrency sweeps address this problem. A concurrency sweep is a systematic benchmarking approach that sends controlled, increasing levels of concurrent traffic to your Amazon SageMaker AI endpoint and analyzes its performance. Concurrency sweeps are built into Amazon SageMaker AI Inference Recommendations , so there’s no custom load-testing infrastructure to build or maintain. In this post, we walk through deploying the NVIDIA Nemotron-3 Nano 30B model, running automated concurrency sweeps, and using the results to make data-driven capacity decisions. By the end, you will know how many concurrent requests your endpoint can handle before latency becomes unacceptable, and how to automate that discovery. A concurrency sweep sends a controlled number of simultaneous requests to your SageMaker AI endpoint and measures two metrics at each level: By progressively increasing the concurrency (for example, 64 to 256, and then 1,024 simultaneous requests), you can trace a curve that reveals your endpoint’s saturation point . This is the point where adding more concurrent traffic stops improving throughput and degrades latency. A concurrency sweep gives you three data points for production planning: Let’s now look at how the end-to-end workflow comes together. The concurrency sweep workflow has four steps: The following diagram illustrates this process. Figure 1: The four-step concurrency sweep workflow The following four steps will take you from a fresh deployment to a complete capacity profile. Each step builds on the previous one, so we recommend following along with the accompanying notebook . Before getting started, make sure that you have: We deploy NVIDIA Nemotron-3 Nano 30B, a Mixture-of-Experts (MoE) model with only 3B active parameters, to an ml.g7e.2xlarge instance. This instance is backed by an NVIDIA Blackwell GPU , which provides a strong price-performance ratio for inference workloads. We use the vLLM Deep Learning Container for SageMaker AI, configured through SM_VLLM_* environment variables: Three of these settings are worth explaining. The SM_VLLM_ENFORCE_EAGER flag is required because Nemotron-3 Nano uses a Mamba-Transformer hybrid architecture that requires eager execution mode. We set the GPU memory utilization to 0.85 to leave headroom for KV cache growth under high concurrency. Prefix caching is enabled to improve performance in scenarios where system prompts are repeated across requests to benefit from reusing cached key-value pairs. After creating the model, endpoint configuration, and endpoint, we verify the deployment with a validation before moving on to benchmarking. Before running any load test, the benchmark engine needs to know what kind of traffic to simulate. We define a workload profile that mirrors a realistic generative AI inference pattern using CreateAIWorkloadConfig . The following table summarizes the values we used for defining the workload. You can follow the code in the accompanying notebook . The choice of 1,024 input tokens and 256 output tokens is representative of Retrieval Augmented Generation (RAG) or summarization workloads. If your application uses shorter prompts and longer completions (such as code generation), adjust these values accordingly. Streaming is enabled to capture time to first token (TTFT) metrics, which are important for interactive user experiences where perceived responsiveness matters as much as raw throughput. With the workload profile defined, the next step is to launch the sweep. We can now create the benchmark job with the CreateAIBenchmarkJob API with the parameters to use in the sweep. In the scenario illustrated in the sample notebook, we have: The benchmark engine ( AIPerf ) runs each concurrency level sequentially within a single job, sending the total number of requests defined under request_count at each level. Running the levels sequentially instead of in parallel means each measurement reflects a clean, isolated load. This approach gives you statistically stable estimates while keeping costs contained. When the job completes, the results are written to the Amazon S3 path defined under OutputConfig as a tarball containing per-level metrics in JSON format. After the job completes, we can download and parse the output for analysis. Four metrics matter most when reading the results: When you plot throughput against latency across the concurrency levels, the saturation point is visible as a “knee” in the curve: throughput flattens while p99 latency bends sharply upward. This happens at 256 concurrent requests in our test scenario. Concurrency levels below the knee are your safe operating region. Above it, the endpoint is overloaded and users are waiting. Figure 2: Throughput and p99 latency across concurrency levels, with the saturation knee at 256 concurrent requests At this point you have a complete picture of how your endpoint behaves under load. For many teams, this is sufficient to make a confident capacity decision. If you want to automate the search for the optimal operating point across model versions or instance types, the benchmark engine offers an automated alternative. The concurrency sweep in Step 3 requires you to choose the concurrency levels to test. You might not know the right range, or you might want to automate capacity planning across model versions. In either case, replace the fixed concurrency list with a search recipe in the same CreateAIBenchmarkJob call. The max-concurrency-under-sla recipe accepts one or more SLA thresholds and searches for the highest concurrency that satisfies all of them. The following table describes the available SLA threshold parameters: For example, we can use the following search parameters to find the maximum concurrency where p99 end-to-end latency stays under 50 seconds: The search engine uses an optimization planner that can converge on the answer in fewer iterations than a linear sweep. It starts with a broad range and narrows progressively, evaluating only the concurrency levels needed to identify the boundary. This can reduce both the number of iterations and the total cost of the search. In this example, the planner starts at concurrency 16 and doubles through each iteration. At concurrency 512, the first SLA violation occurs, either because the p99 end-to-end latency exceeded the threshold or because invocations failed. The planner then narrows the search to the 256–512 range and finds that concurrency 320 meets the SLA at 2,782 tokens per second. The search runs for at most the number of iterations you define in search_max_iterations . A single SLA threshold is insufficient for most production workloads, as some scenarios require that a model must meet multiple SLAs at the same time. For instance, in interactive user experiences, you might need to control both the end-to-end latency and the time to first token. You can still use the max-concurrency-under-sla search recipe by passing multiple SLAs under search parameters: In this case, we observe that when putting SLAs in both the end-to-end latency and time to first token, the maximum level of concurrency supported is 80. With the benchmarking complete, let’s clean up the resources we created during this walkthrough. To avoid ongoing charges, delete your SageMaker endpoints , endpoint configurations , and models after testing. Endpoints bill by the hour whether or not they’re receiving traffic.
由 claude-code/sonnet 自動生成