12-04 更新 实时
首页/ 技术栈/ 正文

SageMaker HyperPod 全球推理网关:单端点跨区域跨集群

技术栈 来源:AWS Machine Learning 2026-11-21 06:35 3 阅读 机器翻译
SageMaker HyperPod 全球推理网关:单端点跨区域跨集群

在流量高峰期,请求可能会在已饱和的 HyperPod 集群上排队等候,而另一个集群(有时位于另一个 AWS Region)上的 GPU 却处于闲置状态。你已经为那部分容量付了费,但你的请求却触达不了它。

在《Introducing Amazon SageMaker HyperPod Inference Gateway》一文中,我们展示了 Inference Gateway 如何为每个 Amazon SageMaker HyperPod 集群提供一个统一的、感知 GPU 的端点。它读取键值(KV)缓存利用率和队列深度等实时信号,把每个请求放到最合适的 pod 上。这解决了单个集群内部的路由问题,但解决不了跨集群的路由。

今天,SageMaker HyperPod 推出 Global Inference Gateway。它是一个由 SageMaker 托管的网关,可在你注册的所有集群之间路由,无论这些集群位于同一个 Region 还是跨 Region。该网关选择集群,并通过 AWS 骨干网传输请求,同时借助 AWS Signature Version 4(SigV4)和 AWS Identity and Access Management(IAM)实现自动故障转移和身份认证。在每个集群内部,仍由 Inference Gateway 继续选择 pod,这一点没有变化。Global Inference Gateway 就是我们第 1 部分所述架构的第二层。

模型规模越来越大,而用于服务这些模型的 GPU 容量越来越难获取。为了获得足够的容量,你只能把它分散到更多集群和更多 Region 中。

假设有一个团队,在两个 Region 的五个 HyperPod 集群上提供四个模型的服务。没有 Inference Gateway 时,客户端需要跟踪 20 个端点:每个集群上每个模型各一个。Inference Gateway 将其缩减到五个,即每个集群一个。但每个客户端仍然要自行选择集群。

这种选择是有代价的:

该团队需要一个端点,能把每个请求发送到最合适的集群,并在集群发生故障时自动将流量转移出去。

Global Inference Gateway 帮助你更充分地利用已有的 GPU 算力,同时减少运维工作。

“在 Bagelcode,我们在 AWS 上运行自己的 LLM 推理服务,帮助公司内包括游戏团队在内的各团队用 AI 改进工作方式。在 beta 测试中,Amazon SageMaker HyperPod 中的 Global Inference Gateway 通过单一端点将请求路由到两个 AWS 区域,并在其中一个集群无法再提供该模型服务时继续处理这些请求。这让我们规模不大的平台团队获得了跨区域故障转移能力,而无需自行构建或维护路由层。”

— Jinhyung Park,Bagelcode 副总裁(AI 平台)

设置该网关需要做两个决定:开放哪些集群用于路由,以及把其中哪些集群归到同一个网关之后。

集群只有在发布之后才可访问。发布集群时,控制器会在该集群的 Inference Gateway 前面创建一个网络负载均衡器(Network Load Balancer),在其上发布 VPC 端点服务,并将监听器的证书上传到你的 TLS 存储桶。这些资源都位于你的账户中。如果你在发布集群之前就把它列入某个网关,该调用会失败,并返回一条提示你需要修复什么的信息。

图 1 展示了每个请求的路径:(1)你的客户端用 SigV4 对请求签名,并将其发送到该网关的区域端点。(2)网关对调用方进行身份验证,并选出最合适的集群。(3)AWS PrivateLink 将该请求传送到该集群——可能在同一区域,也可能在其他区域——然后(4)该集群的 Inference Gateway 像现在一样把请求路由到某个模型 Pod。

图 1:Global Inference Gateway 在一个区域端点接收每个请求,并通过 AWS PrivateLink 将其转发到最合适的 HyperPod 集群,再由该集群的 Inference Gateway 将请求路由到一个模型 Pod。每个集群都会把自己的负载回传给网关。

由你决定发布哪些集群、把哪些集群归组到某个网关之后,以及如何为路由分配权重。其余部分由 AWS 运营:

在每个集群上,一个由服务托管、拥有独立 IAM 角色的指标发布器会把该集群的负载发送给网关。

对于每个请求,网关会根据四项信号为每个健康集群打分,并把请求发送给得分最高的集群。每个集群的指标发布器提供这些负载信号。

你可以通过路由权重控制每项信号所占的比重。每个权重都是 0.0 到 1.0 之间的值,权重为 0 表示关闭该项信号。如果设置权重,就必须四项全部设置,且它们之和必须为 1.0。如果省略,则适用下表中的默认值。

默认权重倾向于靠近网关所在区域的集群,同时仍会把流量导向有可用容量的集群,并避开正在发生故障的集群。如果你的工作负载更看重韧性而非就近性,可调高 ErrorRate 并调低 RegionProximity。例如,下面的 routing 块将近期错误的权重设为 0.7:

{"Weights": {"KVHeadroom": 0.1, "QueueDepth": 0.1, "RegionProximity": 0.1, "ErrorRate": 0.7}} 你在 CreateGlobalInferenceGateway 的 Routing 参数中传入这些权重,之后可以通过 UpdateGlobalInferenceGateway 修改它们。

采用哪条路径取决于你当前的运行方式。如果你从单个集群提供服务,就继续使用该集群的 Inference Gateway 端点。当你增加第二个集群时,再迁移到 Global Inference Gateway。

要设置 Global Inference Gateway,你需要准备好每个集群、创建执行角色,然后调用 CreateGlobalInferenceGateway。之后,将使用 SigV4 签名的 OpenAI 兼容请求发送到网关端点。有关分步说明(包括 IAM 角色和策略),请参阅 AWS 文档。

发往网关的每个请求都使用 SigV4 签名,并通过 IAM 进行授权。调用方需要拥有调用该网关的权限,而流式传输有自己单独的操作:

{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "sagemaker:InvokeGlobalInferenceGateway", "sagemaker:InvokeGlobalInferenceGatewayWithResponseStream" ], "Resource": "arn:aws:sagemaker:<region>:<account-id>:global-inference-gateway/<gateway-id>" }] } 将此策略附加到每个发送请求的 IAM 身份上。若要允许账户中的所有网关,请将资源设为 global-inference-gateway/*。

执行角色遵循最小权限原则。它只能描述你列出的集群,只能访问这些集群的 Amazon Elastic Kubernetes Service(Amazon EKS)API,并且只能读取 TLS 存储桶中 gig/ 前缀下的路由证书,且这些证书需带有由 HyperPod Inference 创建的标签。

身份令牌。如果你的集群会校验 JSON Web Token(JWT),请通过 --customer-identity-token(即 X-Amzn-SageMaker-Customer-Identity-Token 标头)传入令牌,不要加 Bearer 前缀。该令牌在 SigV4 签名内部传输,因此未签名的令牌会被拒绝并返回 403,重复的令牌则返回 400。请在每一个提供模型的集群上开启 JWT 校验,或者全部都不开启,以免请求在一个集群上成功、却在另一个集群上失败。

如图 1 所示,请求仅通过 AWS PrivateLink 到达你的集群。网关不会记录或存储提示词或补全内容。

以下是配置该网关的步骤。

按照文档所述,准备新集群并在其上为执行角色创建 EKS 访问条目。还要将新集群添加到执行角色权限策略的 Resource 列表中。然后,在网关所在的区域调用 AddInferenceGateway,即使新集群位于另一个区域:

aws sagemaker add-inference-gateway \ --identifier <gateway-name> \ --region <region> \ --cluster-arn arn:aws:sagemaker:<region-3>:<account-id>:cluster/<cluster-id-3> \ --name <gateway-config-name-3> \ --namespace inference-gateway 网关会验证该集群,并在其健康后开始将流量路由到它。端点、其他集群和客户端不受影响。

在网关所在的区域调用 RemoveInferenceGateway:

aws sagemaker remove-inference-gateway \ --identifier <gateway-name> \ --region <region> \ --cluster-arn arn:aws:sagemaker:<region-3>:<account-id>:cluster/<cluster-id-3> \ --name <gateway-config-name-3> \ --namespace inference-gateway 网关会停止向该集群发送新请求,让正在处理的请求完成,并移除私有端点。一个网关始终至少保留一个集群。要完全撤出该集群,请在其 InferenceGatewayConfig 中将 globalRouting.enabled 设置为 false,并重新应用它。

调用 DeleteGlobalInferenceGateway:

aws sagemaker delete-global-inference-gateway \ --identifier <gateway-name> --region <region> 网关端点停止提供服务,而各集群端点继续提供服务。删除网关后,使用 globalRouting.enabled: false 撤出每个集群,然后删除执行角色以及你为全局路由添加的 IAM 权限。

下表总结了常见事件和变更如何影响流量。

如需任何故障排除帮助,请参阅《故障排除指南》。

在这篇博文中,我们介绍了 Amazon SageMaker HyperPod Global Inference Gateway:在单个区域或多个区域内,跨你的 HyperPod 集群提供一个由 SageMaker 管理的端点。该网关会根据 KV 缓存余量、队列深度、区域邻近性和错误率来选择集群,并在无需客户端做任何改动的情况下,将流量从故障集群上迁走。

原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。

查看英文原文(Introducing Amazon SageMaker HyperPod Global Inference Gateway: One endpoint across Regions and clusters)

During a traffic peak, a request can sit in a queue on a saturated HyperPod cluster while GPUs on another cluster, sometimes in another AWS Region, sit idle. You have already paid for that capacity, but your requests can’t reach it.

In Introducing Amazon SageMaker HyperPod Inference Gateway, we showed how the Inference Gateway gives each Amazon SageMaker HyperPod cluster a single, GPU-aware endpoint. It reads real-time signals such as key-value (KV) cache utilization and queue depth to place every request on the best-suited pod. That solves routing inside one cluster, but not across clusters.

Today, SageMaker HyperPod introduces the Global Inference Gateway. It is one SageMaker-managed gateway that routes across every cluster you register, in one Region or across Regions. The gateway picks the cluster and carries the request over the AWS backbone, with automatic failover and authentication through AWS Signature Version 4 (SigV4) and AWS Identity and Access Management (IAM). Inside each cluster, the Inference Gateway keeps picking the pod, unchanged. The Global Inference Gateway is the second tier of the architecture we described in part 1.

The challenge: Capacity spread across clusters and Regions

Models are getting larger, and the GPU capacity to serve them is harder to find. To get enough of it, you spread it across more clusters and more Regions.

Consider a team that serves four models across five HyperPod clusters in two Regions. Without the Inference Gateway, clients track 20 endpoints: one per model per cluster. The Inference Gateway cuts that to five, one per cluster. But each client still picks a cluster itself.

That choice has costs:

  • Uneven load. During peaks, requests queue in one Region while GPUs in the other Region are idle.
  • Manual failover. When a cluster fails, an engineer changes configuration to move traffic away from it.
  • Custom plumbing. Spreading traffic across Regions means building and maintaining load balancers, DNS, and cross-Region networking yourself.

The team needs one endpoint that sends each request to the best-suited cluster and moves traffic off a failed cluster on its own.

Key benefits

The Global Inference Gateway helps you get more from the GPU capacity you already have, with less to operate.

  • Put idle GPUs to work. During a peak, requests overflow to clusters with available capacity in the same Region or another one, instead of queuing on a saturated cluster.
  • Fail over automatically. When a cluster fails, the gateway moves its traffic to the next-best cluster. Clients don’t change anything.
  • Use one endpoint for everything. Clients call a single SageMaker-managed endpoint instead of tracking one endpoint per cluster or per model.
  • Skip the custom networking. You don’t build or maintain load balancers, DNS, or cross-Region networking.
  • Stay private by default. Every request is authenticated with SigV4 and IAM, and it reaches your clusters only over AWS PrivateLink.

Customer feedback

“At Bagelcode, we run our own LLM inference service on AWS to help teams across the company, including our game teams, use AI to improve how they work. In our beta tests, the Global Inference Gateway in Amazon SageMaker HyperPod routed requests across two AWS Regions through a single endpoint and kept serving them when one cluster could no longer serve the model. That gave our small platform team cross-Region failover without having to build or maintain our own routing layer.”

— Jinhyung Park, VP (AI Platform), Bagelcode

How it works

Setting up the gateway takes two decisions: which clusters to open up for routing, and which of them to group behind one gateway.

  1. Publish a cluster. You do this once per cluster. You turn on the spec.globalRouting block in the cluster’s existing InferenceGatewayConfig. The HyperPod Inference controller then publishes the cluster privately from your own account.
  2. Create the gateway. You do this once per gateway. You call CreateGlobalInferenceGateway with the clusters to route across, and SageMaker returns one endpoint.

A cluster is reachable only after you publish it. When you publish a cluster, the controller creates a Network Load Balancer in front of the cluster’s Inference Gateway, publishes a virtual private cloud (VPC) endpoint service on it, and uploads the listener’s certificate to your TLS bucket. These resources live in your account. If you list a cluster in a gateway before you publish it, the call fails with a message that tells you what to fix.

How a request flows

Figure 1 shows the path of each request: (1) your client signs the request with SigV4 and sends it to the gateway’s regional endpoint. (2) The gateway authenticates the caller and picks the best cluster. (3) AWS PrivateLink carries the request to that cluster, in the same Region or another, and (4) the cluster’s Inference Gateway routes it to a model pod, as it does today.

Figure 1: Global Inference Gateway architecture

Figure 1: The Global Inference Gateway receives each request at one regional endpoint and forwards it over AWS PrivateLink to the best HyperPod cluster, where the cluster’s Inference Gateway routes it to a model pod. Each cluster publishes its load back to the gateway.

What AWS operates

You decide which clusters to publish, which to group behind a gateway, and how to weight routing. AWS operates the rest:

  • The routing fleet. SageMaker provisions and operates the fleet that terminates TLS, authenticates callers, scores clusters, and forwards each request.
  • Private connectivity. SageMaker creates one private endpoint per cluster and carries traffic on the AWS backbone, in-Region and cross-Region.
  • Certificates and validation. Using an execution role that you create, the service reads each cluster’s VPC endpoint service name, certificate, and Region, so you don’t copy them by hand. It checks them before routing traffic.
  • Health and failover. The gateway health-checks every cluster and moves traffic off a failed cluster automatically. For details, see the Operating the gateway section.
  • Authentication and rate limits. The gateway checks SigV4 signatures, IAM permissions, and rate limits, and rejects failing requests before any cluster sees them.

On each cluster, a service-managed metrics publisher with its own IAM role sends the cluster’s load to the gateway.

How the gateway picks a cluster

For each request, the gateway scores every healthy cluster on four signals and sends the request to the highest-scoring cluster. Each cluster’s metrics publisher supplies the load signals.

You control how much each signal counts with routing weights. Each weight is a value from 0.0 to 1.0, and a weight of 0 turns that signal off. If you set weights, you set all four, and they must add up to 1.0. If you omit them, the defaults in the following table apply.

Weight What it scores Default
KVHeadroom Available KV cache and GPU memory on the cluster 0.20
QueueDepth How backed up the cluster is 0.25
RegionProximity Distance between the cluster and the gateway’s Region 0.40
ErrorRate Recent failed requests on the cluster 0.15

The defaults favor clusters close to the gateway’s Region, while still moving traffic toward clusters with available capacity and away from clusters that are failing. If resilience matters more than proximity for your workload, raise ErrorRate and lower RegionProximity. For example, the following routing block weights recent errors at 0.7:

{"Weights": {"KVHeadroom": 0.1, "QueueDepth": 0.1, "RegionProximity": 0.1, "ErrorRate": 0.7}}

You pass the weights in the Routing parameter of CreateGlobalInferenceGateway, and you can change them later with UpdateGlobalInferenceGateway.

Choose your starting point

Your path depends on what you run today. If you serve from a single cluster, stay on that cluster’s Inference Gateway endpoint. Move to the Global Inference Gateway when you add a second cluster.

Starting point What you do Result
The Inference Gateway runs on each cluster, for example four models on five clusters in us-east-1 and us-west-2 Update the add-on, publish each cluster, and create the gateway One endpoint for every cluster. Per-cluster endpoints keep serving while you move clients over.
The HyperPod Inference add-on runs with the Inference Gateway turned off Turn on the Inference Gateway with one add-on update and one InferenceGatewayConfig per cluster, add a scheduler for each model, then follow the first row Per-model endpoints collapse into one
GPU capacity in two Regions, but no HyperPod Inference setup yet Create a HyperPod cluster in each Region with the HyperPod Inference add-on, deploy your model, turn on the Inference Gateway, then follow the first row One endpoint from day one, with traffic whose routing can be fine-tuned, and keeps serving if a Region has a problem

Getting started

To set up the Global Inference Gateway, you prepare each cluster, create an execution role, and call CreateGlobalInferenceGateway. You then send OpenAI-compatible requests, signed with SigV4, to the gateway endpoint. For step-by-step instructions, including the IAM roles and policies, see the AWS documentation.

Security and access

Every request to the gateway is signed with SigV4 and authorized with IAM. Callers need permission to invoke the gateway, and streaming has its own action:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "sagemaker:InvokeGlobalInferenceGateway",
      "sagemaker:InvokeGlobalInferenceGatewayWithResponseStream"
    ],
    "Resource": "arn:aws:sagemaker:<region>:<account-id>:global-inference-gateway/<gateway-id>"
  }]
}

Attach this policy to each IAM identity that sends requests. To allow every gateway in the account, use global-inference-gateway/* as the resource.

The execution role follows least privilege. It can describe only the clusters you list, reach only their Amazon Elastic Kubernetes Service (Amazon EKS) API, and read only the routing certificates under the gig/ prefix of your TLS bucket, tagged as created by HyperPod Inference.

Identity tokens. If your clusters check JSON Web Tokens (JWTs), pass the token with --customer-identity-token (the X-Amzn-SageMaker-Customer-Identity-Token header), with no Bearer prefix. The token travels inside the SigV4 signature, so an unsigned token is rejected with 403 and a repeated token with 400. Turn on JWT checks on every cluster that serves a model, or on none of them, so a request doesn’t succeed on one cluster and fail on another.

Requests reach your clusters only through AWS PrivateLink, as shown in Figure 1. The gateway does not log or store prompts or completions.

Operating the gateway

Here are steps to configure the gateway.

Add a cluster

Prepare the new cluster and create the execution role’s EKS access entry on it, as described in the documentation. Also add the new cluster to the Resource lists of the execution role’s permissions policy. Then call AddInferenceGateway in the gateway’s Region, even if the new cluster is in another Region:

aws sagemaker add-inference-gateway \
  --identifier <gateway-name> \
  --region <region> \
  --cluster-arn arn:aws:sagemaker:<region-3>:<account-id>:cluster/<cluster-id-3> \
  --name <gateway-config-name-3> \
  --namespace inference-gateway

The gateway validates the cluster and starts routing to it once it is healthy. The endpoint, other clusters, and clients aren’t affected.

Detach a cluster

Call RemoveInferenceGateway in the gateway’s Region:

aws sagemaker remove-inference-gateway \
  --identifier <gateway-name> \
  --region <region> \
  --cluster-arn arn:aws:sagemaker:<region-3>:<account-id>:cluster/<cluster-id-3> \
  --name <gateway-config-name-3> \
  --namespace inference-gateway

The gateway stops sending new requests to the cluster, lets in-flight requests finish, and removes the private endpoint. A gateway always keeps at least one cluster. To withdraw the cluster fully, set globalRouting.enabled: false in its InferenceGatewayConfig and reapply it.

Delete the gateway

Call DeleteGlobalInferenceGateway:

aws sagemaker delete-global-inference-gateway \
  --identifier <gateway-name> --region <region>

The gateway endpoint stops serving, and per-cluster endpoints keep serving. After the gateway is deleted, withdraw each cluster with globalRouting.enabled: false, then delete the execution role and the IAM permissions you added for global routing.

The following table summarizes how common events and changes affect traffic.

Event What happens What you do
Gateway creation fails The gateway moves to FAILED, and FailureReason says what failed, such as a certificate name mismatch Fix the cause. To see each cluster’s status, call ListInferenceGateways.
A cluster fails Traffic moves to the next-best cluster, and the cluster returns gradually after it recovers. A failed request is retried once on another cluster unless it has started streaming. If no healthy cluster is left, the gateway returns 503. Nothing. Clients don’t change anything.
Change routing weights New requests use the new weights, and in-flight requests finish under the old ones. Nothing is re-provisioned. Call UpdateGlobalInferenceGateway
Add a cluster Routing starts once the cluster is healthy. Nothing else changes. See Add a cluster
Detach a cluster New requests stop, and in-flight requests finish See Detach a cluster
Delete the gateway The gateway endpoint stops serving, and per-cluster endpoints keep serving See Delete the gateway

For any troubleshooting assistance, please see the Troubleshooting Guide.

Best practices and considerations

  • Plan your groups before you publish. Decide which clusters sit behind each gateway, with the same modelName on every cluster that should share a model’s traffic. If you want peak traffic to overflow across Regions, give clusters in both Regions headroom.
  • Publish only the clusters you add to a gateway. A published cluster that isn’t in any gateway receives no traffic, but its Network Load Balancer still runs and is billed.
  • Cover every model. Each scheduler in the InferenceGatewayConfig maps a model name to the pods that serve it. A model that isn’t in any scheduler can’t be reached through the gateway, and requests for it return a 404 error.
  • Keep your add-on configuration complete. With --resolve-conflicts OVERWRITE, an incomplete configuration can reset your load balancer or TLS settings. Start from the current configuration every time.
  • Pass --context on every kubectl command. You work across several clusters, so make sure each command runs against the cluster you mean.
  • Keep a workload in one Region when you need to. Create a gateway that includes only clusters in that Region.

Conclusion

In this post, we introduced the Amazon SageMaker HyperPod Global Inference Gateway: one SageMaker-managed endpoint across your HyperPod clusters, in one Region or several. The gateway picks the cluster based on KV cache headroom, queue depth, Region proximity, and error rate, and moves traffic off a failed cluster with no client changes.

The Global Inference Gateway is available in 13 AWS Regions: US East (N. Virginia), US East (Ohio), US West (N. California), US West (Oregon), South America (São Paulo), Europe (Frankfurt), Europe (Ireland), Europe (London), Europe (Stockholm), Asia Pacific (Tokyo), Asia Pacific (Mumbai), Asia Pacific (Singapore), and Asia Pacific (Sydney).

To get started, see the AWS documentation.


About the authors

Dmitry Soldatkin

Dmitry Soldatkin

Dmitry is a Worldwide Leader for Specialist Solutions Architecture, Amazon SageMaker AI Inference at AWS. He helps customers design, build, and optimize generative AI and machine learning solutions, with a focus on inference performance optimization, deep learning, and scaling ML across the enterprise. In previous roles, he led teams at financial services, insurance, and telecommunications companies.

Aryaman Kothari

Aryaman Kothari

Aryaman is a Senior Product Manager at Amazon SageMaker AI, where he leads AI inference on Amazon SageMaker HyperPod, helping enterprises run AI models at scale for production workloads. A Chicago Booth graduate, Aryaman previously led product and go-to-market for Quantiphi’s Conversational AI business. Outside of work, he enjoys playing soccer, making chai, and hiking.

Piyush Daftary

Piyush Daftary

Piyush is a Principal Software Engineer on Amazon SageMaker AI, where he builds high-performance, scalable inference systems for large language models, including the SageMaker HyperPod Global Inference Gateway. He is passionate about solving complex distributed systems challenges and making generative AI inference faster and more cost-effective. His technical interests include large-scale model serving, GPU efficiency, and distributed inference. Outside of work, he enjoys traveling, hiking, and spending time with family.

正文保留英文原文,标题与摘要由机器翻译。

本文由采集器自动同步

原文发布于 AWS Machine Learning(Introducing Amazon SageMaker HyperPod Global Inference Gateway: One endpoint across Regions and clusters),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。

阅读原文 ↗