AI Practices AI实践 19h ago Updated 15h ago 更新于 15小时前 48

Reduce LLM latency with prefix-aware routing on Amazon SageMaker Inference 通过前缀感知路由降低 Amazon SageMaker Inference 上的 LLM 延迟

Amazon SageMaker Inference introduces prefix-aware routing, a new strategy that routes requests with identical prompt prefixes to the same inference instance, enabling effective KV cache reuse across scaled fleets Benchmarks on Llama 3.1 70B showed P50 TTFT reductions of up to 77% and throughput increases of up to 16% under long-context workloads with 8,000-token shared prefixes KV cache hit rates jumped from approximately 25% to over 80%, with routing overhead of only 1.3–1.9ms per request—negl Amazon SageMaker Inference推出前缀感知路由(Prefix-Aware Routing),将相同prompt前缀的请求路由到同一实例,使KV cache可被有效复用 在Llama 3.1 70B基准测试中,P50首token延迟(TTFT)降低高达77%,吞吐量提升16%,KV cache命中率从约25%提升至80%+ 该功能解决多实例场景下prefix caching失效的核心痛点,路由开销仅1.3-1.9ms/请求,对整体性能影响可忽略 提供三种路由策略(RANDOM、LEAST_OUTSTANDING_REQUESTS、PREFIX_AWARE),可按需切换无需重

68
Hot 热度
72
Quality 质量
65
Impact 影响力

Analysis 深度分析

TL;DR

  • Amazon SageMaker Inference introduces prefix-aware routing, a new strategy that routes requests with identical prompt prefixes to the same inference instance, enabling effective KV cache reuse across scaled fleets
  • Benchmarks on Llama 3.1 70B showed P50 TTFT reductions of up to 77% and throughput increases of up to 16% under long-context workloads with 8,000-token shared prefixes
  • KV cache hit rates jumped from approximately 25% to over 80%, with routing overhead of only 1.3–1.9ms per request—negligible compared to model TTFT of 63–280ms
  • The feature includes overload protection (bypassing cache affinity when a target instance hits concurrency limits) and stable behavior during autoscaling to prevent cache invalidation
  • SageMaker Inference now offers three routing strategies: RANDOM (default), LEAST_OUTSTANDING_REQUESTS, and PREFIX_AWARE, configurable per production variant without redeploying the model

Why It Matters

Prefix caching has long been a proven optimization in single-instance LLM serving, but its benefits evaporated at scale because standard load balancers distributed identical-prefix requests across different instances. This new routing strategy closes that gap, making prefix caching actually effective for production fleets—a common architecture for any LLM application with system prompts, RAG documents, or conversation history. For AI practitioners running high-traffic LLM endpoints, this translates directly into lower latency, higher throughput, and reduced infrastructure costs without code changes to the model or application.

Technical Details

  • Mechanism: The routing layer inspects the beginning of each incoming request payload and consistently directs requests sharing the same prefix to the same inference instance, allowing the instance's KV cache to accumulate and be reused across requests with that prefix.
  • Benchmarks: Tested on 7 × ml.p5.48xlarge instances running vLLM with prefix caching enabled, using Llama 3.1 70B Instruct. Long-context workloads (8,000-token shared prefixes, 1 hour): P90 TTFT reduced 33–37%, P50 TTFT reduced 71–77%, throughput increased 15–16%, KV cache hit rate rose from ~25% to ~82%. Short-context workloads (ShareGPT-style, 30 minutes): P90 TTFT reduced 24–37%, P50 TTFT reduced 13–16%, throughput increased 1.7–2.0%, KV cache hit rate rose from ~30% to ~80%.
  • Safeguards: Overload protection routes requests away from an instance at capacity despite prefix match, trading a missed cache hit for system stability. Stable scaling behavior ensures that adding or removing instances shifts only a small fraction of traffic, preserving existing caches.
  • Routing overhead: 1.3–1.9ms per request, negligible relative to model TTFT (63–280ms). Traffic remained evenly distributed across all 7 instances (13.3–15.4% each, within 1% of ideal).
  • Configuration: Three strategies available—RANDOM, LEAST_OUTSTANDING_REQUESTS, PREFIX_AWARE—set per production variant in endpoint configuration, swappable without model redeployment.

Industry Insight

  • Cost optimization for LLM deployments: The dramatic TTFT improvements and throughput gains mean teams can serve the same traffic with fewer instances or achieve lower latency at current scale—directly reducing per-request inference costs, which is critical as LLM usage scales.
  • Prefix-aware routing should become a standard consideration for any production LLM system with shared context (system prompts, RAG retrieval results, conversation history). Organizations should audit their routing configurations and switch from random to prefix-aware routing where applicable, especially for long-context workloads where the savings are largest.
  • The feature's overload protection and scaling stability address the two most common operational concerns with affinity-based routing—hot spots and cache thrashing during autoscaling—making it production-ready without requiring custom infrastructure or complex tuning.

TL;DR

  • Amazon SageMaker Inference推出前缀感知路由(Prefix-Aware Routing),将相同prompt前缀的请求路由到同一实例,使KV cache可被有效复用
  • 在Llama 3.1 70B基准测试中,P50首token延迟(TTFT)降低高达77%,吞吐量提升16%,KV cache命中率从约25%提升至80%+
  • 该功能解决多实例场景下prefix caching失效的核心痛点,路由开销仅1.3-1.9ms/请求,对整体性能影响可忽略
  • 提供三种路由策略(RANDOM、LEAST_OUTSTANDING_REQUESTS、PREFIX_AWARE),可按需切换无需重新部署模型

为什么值得看

对于部署大规模LLM应用的企业而言,前缀感知路由直接解决了多实例部署时KV cache命中率低的核心痛点,显著降低推理延迟并提升吞吐量。该功能无需修改应用代码,通过配置即可启用,为LLM服务优化提供了低成本高效率的解决方案。

技术解析

  • 核心机制:SageMaker Inference在请求到达时分析prompt前缀,将相同前缀的请求持续路由到同一实例,使该实例的KV cache能够累积并复用,避免每次请求都从头计算前缀部分。
  • 性能数据:在8000-token长前缀场景下,P90 TTFT降低33-37%,P50 TTFT降低71-77%,KV cache命中率从25%跃升至82%,吞吐量提升15-16%;短前缀场景下P90 TTFT降低24-37%,P50 TTFT降低13-16%,命中率从30%提升至80%。
  • 安全保障:内置过载保护机制,当某前缀请求量过大导致目标实例达到并发上限时,自动将请求路由至其他实例;扩缩容时保持路由稳定性,仅少量请求重新分配。
  • 路由策略:RANDOM(默认,均匀分发)、LEAST_OUTSTANDING_REQUESTS(最少待处理请求优先)、PREFIX_AWARE(前缀感知,新增策略),支持按生产变体配置并动态切换。

行业启示

  • LLM推理优化正从单一模型层面转向系统级协同,路由策略与缓存机制的配合将成为降低推理成本的关键方向。
  • 对于具有固定prompt前缀的应用场景(如客服机器人、RAG系统),启用前缀感知路由可显著改善用户体验并降低基础设施成本。
  • 云服务商正在通过底层基础设施优化来降低LLM部署门槛,企业应关注并评估这些原生能力对现有架构的影响。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

LLM 大模型 Inference 推理 Deployment 部署