Assess GPU capacity risk before you deploy on AWS
An open source MIT-0 agent that scores the feasibility of GPU deployments on Amazon SageMaker AI and Amazon EC2, returning a reproducible, auditable verdict.
This post shows you how to deploy an open source AI agent that scores the capacity risk of a graphics processing unit (GPU) deployment on Amazon SageMaker AI and Amazon Elastic Compute Cloud (Amazon EC2) before you commit to it. The agent runs on Amazon Bedrock, and it computes its verdict with deterministic logic instead of the model, so you can reproduce the result and defend it to your stakeholders. The code is open source under the MIT-0 license, and it deploys with the AWS Serverless Application Model (AWS SAM).
GPU capacity is one of the hardest variables to plan around. You get the model trained, the application built, and the launch date set, and then the deployment fails with an
InsufficientInstanceCapacity error on the morning it matters. Answering "will the capacity be there?" today means checking several data sources by hand: instance availability by AWS Region, pricing and availability, service quotas, Amazon EC2 Spot placement scores, and alternative instance types. Each lives behind a different API, the work takes hours, and the final risk call stays subjective. This post walks you through an agent that turns that question into a fast, reproducible answer.Solution overview
You ask the agent a plain-language question, for example, "Can I deploy 20 ml.g5.2xlarge in us-east-1 for inference?" The agent gathers the relevant signals from read-only AWS APIs and returns a structured decision package: a confidence score, a feasibility verdict, the signals behind it, and a recommended capacity mitigation. It runs as an AWS Lambda function behind Amazon API Gateway, and it's model-agnostic: any Amazon Bedrock model that supports the Converse API with tool use works, and callers choose a model per request from an allowlist you control.
The following diagram shows the reference architecture.

Figure 1. A daily or on-demand request reaches an AWS Lambda function through Amazon API Gateway, fronted by AWS WAF. The function calls Amazon Bedrock with read-only tools, reads capacity signals from Amazon EC2, the AWS Price List API, Service Quotas, AWS CloudTrail, and Amazon CloudWatch, caches results in Amazon DynamoDB, scores the result deterministically, and returns a decision package. Failed runs go to an Amazon Simple Queue Service dead-letter queue with Amazon Simple Notification Service alerting.
At a high level, the agent works through these steps:
- You send a capacity question to Amazon API Gateway, or to an AWS Lambda function URL for longer queries.
- AWS WAF screens the request, and Amazon API Gateway authenticates it and invokes the function.
- The function calls Amazon Bedrock with the Converse API, and the model requests read-only tools in a loop.
- The function runs the tools against Amazon EC2, the AWS Price List API, Service Quotas, AWS CloudTrail, Amazon CloudWatch, and Amazon SageMaker AI.
- A deterministic scorer computes the confidence score and verdict from the raw tool outputs.
- The function returns the decision package, including a recommended mitigation when risk is high.
Why the agent is auditable
A large language model that decides feasibility is a problem, because two identical questions can produce two different answers, and you can't audit why. This agent separates the two jobs. The model chooses which tools to call and writes the human-readable explanation. It doesn't produce the number. A deterministic scorer computes the confidence score, label, and verdict from the raw tool outputs. Ask the same question twice, and you get the same verdict twice. Every response carries the signals, the weights, the pre-cap base score, and an audit trail of adjustments, so you can recompute the result yourself with
base_score = sum(signals[k] * weights[k] for k in weights) .The signal hierarchy
The scorer combines weighted signals, each from a read-only AWS API.
Signal | Weight | Source |
|---|---|---|
Instance available in the Region | 0.25 | Amazon EC2 DescribeInstanceTypeOfferings |
Pricing and availability | 0.15 | AWS Price List API |
Quota headroom (limit divided by requested) | 0.25 | Service Quotas ListServiceQuotas |
Spot placement score (a proxy for pool depth) | 0.25 | Amazon EC2 GetSpotPlacementScores |
Region maturity, per GPU family | 0.10 | bundled reference data |
On top of the weighted sum, hard gates and ceilings apply, so one decisive fact can override a healthy-looking average. An instance type that isn't offered in the Region caps to NOT FEASIBLE. A history of real capacity errors in your own AWS CloudTrail also caps the verdict. That cap gets stricter as the error count rises, unless a fully covering On-Demand Capacity Reservation (ODCR) offsets it. If the capacity-error signal is unavailable or throttled, the scorer treats it as unknown rather than clean, and it doesn't return DEPLOYABLE. The score maps to one of four verdicts: DEPLOYABLE, DEPLOYABLE WITH PREPARATION, HIGH RISK, or NOT FEASIBLE.
A worked example
When you ask about 22 g5.2xlarge instances in a less-mature Region, the
confidence_assessments array carries the auditable record, one entry per instance type and Region the agent investigated:json
{ "instance_type": "g5.2xlarge", "region": "af-south-1", "requested_count": 22, "confidence": { "score": 0.32, "label": "MODERATE-LOW", "verdict": "HIGH RISK", "signals": { "availability": 1.0, "pricing": 1.0, "quota": 0.09, "spot_placement": 0.3, "region_maturity": 0.3 }, "base_score": 0.328, "applied_caps": [] }}
The instance is available and priced, but quota headroom is thin and the Spot placement score is low in a less-mature Region, so the math lands on HIGH RISK, and you can observe exactly why.
When risk is high, the agent doesn't stop at "no." It checks real inventory and recommends a mitigation, citing the offering it found: Amazon EC2 Capacity Blocks for ML, Amazon SageMaker AI Flexible Training Plans, ODCRs, or a heterogeneous Amazon SageMaker AI endpoint that can fall back to a second instance pool. The agent handles Amazon SageMaker AI managed endpoints and self-managed Amazon EC2 fleets in one query shape, and every tool is read-only, so it never changes your account.
Prerequisites
To deploy this solution, you need the following:
- An AWS account with Amazon Bedrock model access enabled for at least one model that supports the Converse API with tool use.
- The AWS SAM command line interface, version 1.100 or later.
- Python 3.10 or later.
- Permissions to deploy AWS Lambda, Amazon API Gateway, Amazon DynamoDB, Amazon Simple Queue Service (Amazon SQS), AWS Secrets Manager, AWS WAF, and Amazon CloudWatch resources.
- An existing Amazon Simple Notification Service (Amazon SNS) topic for alarm notifications.
Deploy the agent
You deploy the agent with AWS SAM in three steps.
- Clone the repository and change into the Guidance directory:bash``` git clone https://github.com/awslabs/support-solutions-aws.gitcd support-solutions-aws/AI-ML/guidance-for-gpu-capacity-planning-on-aws
git clone https://github.com/awslabs/support-solutions-aws.gitcd support-solutions-aws/AI-ML/guidance-for-gpu-capacity-planning-on-aws
- Build the application:
make build
- Deploy the stack. The first deployment is guided, so you confirm the stack name and parameters:
make deployQuery the agent
After the deployment finishes, send a question to the endpoint.
- Retrieve the API endpoint from the stack outputs.
- Send a capacity question as a JSON request body, for example,
{"query": "Can I deploy 20 ml.g5.2xlarge in us-east-1 for inference?"}.
- Review the decision package in the response. The narrative explains the result, and the
confidence_assessmentsarray holds the reproducible score, verdict, and signals.
Cost
As of this writing, the solution costs about USD $17 per month at the infrastructure floor with no traffic, and about USD $52 per month at 100 queries per day on the default model. Amazon Bedrock usage is the largest cost lever, and you can shift it by choosing a cheaper or stronger model per query. These are estimates. To model your own workload, use the AWS Pricing Calculator.
Clean up resources
To avoid incurring future charges, delete the resources you created:
sam delete --stack-name gpu-capacity-agentThis removes the AWS Lambda function, Amazon API Gateway, the AWS Identity and Access Management (IAM) role, the Amazon DynamoDB cache table, the Amazon SQS dead-letter queue, the AWS Secrets Manager secret, the AWS WAF web ACL, and the Amazon CloudWatch dashboard and alarms.
Conclusion
In this post, you deployed an open source AI agent that scores the capacity risk of a GPU deployment on Amazon SageMaker AI and Amazon EC2, and returns a reproducible verdict you can defend. Because the scorer computes the result from raw signals rather than the model, the same inputs always produce the same answer, with a full audit trail.
To get started, deploy the Guidance in a test account and ask it about a workload you're planning. To go deeper, add your own signal or tool, or adjust the scoring weights for your environment. If you build on it, open an issue or a pull request in the GitHub repository, and tell us in the comments how you use it.
For more information, refer to the GitHub repository, the Amazon Bedrock User Guide, and the Amazon SageMaker AI Developer Guide. This is sample code for non-production use. Work with your security and legal teams, and test and harden it, before any production deployment.
About the authors
ToAnh Tran is a Senior Cloud Technical Account Manager at Amazon Web Services (AWS), where she leads technical direction for AI inference reliability and GPU capacity across large-scale generative AI workloads. She holds the AWS Certified Generative AI Developer – Professional, AWS Certified Solutions Architect – Professional, and AWS Certified Security – Specialty certifications, and brings a perspective shaped by more than a decade in the non-profit world and years of hands-on machine learning and AI.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article