AWS Builder Center

AI infrastructure on AWS

AI infrastructure on AWS




1. The three gaps that govern every choice

AI infrastructure has exactly three ways to waste an accelerator, and every section of this article maps to one of them.
Gap
The accelerator is waiting on…
The fix is a property of…
Memory
HBM bandwidth — decode re-reads the whole model + KV cache per token, at low arithmetic intensity [A][3]
the instance you pick (§3, §4)
Network
the fabric — a collective (all-reduce, all-gather) is only as fast as the slowest link between two GPUs [11][12]
the topology you place onto (§5)
Idle
nothing — the GPU is allocated but between jobs, or provisioned but unscheduled
the scheduler and autoscaler (§7, §9)
The trap is optimizing the model (a research problem) while leaving one of these three open (a plumbing problem). A 10% kernel speedup is invisible if the GPU spends 40% of a distributed step waiting on a cross-NUMA network hop [11]. Fix the gaps first; they are where the money is.
The corollary, which the rest of this article assumes: an idle H100 costs the same as a busy one. Utilization, not peak FLOPs, is the number to manage.



2. The lifecycle, and where infrastructure actually lives

A model touches infrastructure at six stages. Most teams over-invest in stage 4 and under-invest in stages 1 and 6, which is where cost and reliability actually come from.
  1. Data — datasets land in S3, are streamed to trainers over FSx for Lustre or Mountpoint for S3 (§6).
  1. Training / fine-tuning — long-running, network-bound, checkpoint-heavy; P5/Trn on EKS + Karpenter, SageMaker HyperPod, or AWS Batch (§7, §8).
  1. Registry — weights and container images in S3 and ECR; loading them is a storage problem, not a model problem (§6).
  1. Serving / inference — latency-bound, autoscaled; see the companion vLLM article for the engine layer, and §8 here for the platform.
  1. Scaling — GPUs are the scarce, expensive resource; the autoscaler decides the bill (§9).
  1. Observability + cost — you cannot manage utilization you cannot see (§10, §11).
Everything below is stages 1–3 and 5–6. Stage 4 (the serving engine itself) is the subject of the companion piece,  LLM serving on AWS ; this article is the platform it runs on.



3. Compute — the AWS accelerator menu, by the gap it closes


AWS offers three accelerator lineages. Pick by the gap, not the brand.
  • NVIDIA GPU instances — the general answer, widest framework support.
  • P5 / P5e / P5en (H100 / H200): 8 GPUs, NVSwitch/NVLink inside the box, EFA across boxes — the training and large-model-serving tier.
  • G6 / G6e (L4 / L40S) and G5 (A10G): single- or few-GPU, the cost-effective inference and small-model tier.
  • P4d / P4de (A100): the previous training generation, still widely available.
  • AWS Trainium (Trn1/Trn2) and Inferentia (Inf2) — AWS's own silicon, programmed through the Neuron SDK. Lower $/token for models Neuron supports, at the cost of a narrower framework surface — the classic price-for-portability trade [4].
  • Managed, no instance at all — Amazon Bedrock serves frontier models with zero infrastructure; SageMaker endpoints wrap the GPU for you. This is the correct default until scale or customization forces you down a layer (§11).
The rule that survives every price change: HBM capacity gates which models fit, HBM bandwidth gates how fast they decode, and NVLink/EFA gate whether they can be split across chips at all. Read the memory numbers before the FLOPs.



4. Picking the instance from the roofline, not the spec sheet


The spec sheet sells FLOPs. Inference decode almost never uses them [A][3]. The selection method:
  1. Does the model fit in one GPU's HBM? Weights (≈ 2 bytes/param at FP16) plus KV cache plus activation headroom. If yes, a single G6e or one GPU of a P5 is the cheapest correct answer — do not distribute.
  1. If not, how many GPUs does it take to fit? That count sets the minimum parallelism, and therefore whether you need NVLink (within a box) or EFA (across boxes) — §5.
  1. Is the workload decode-heavy (chat) or prefill-heavy (RAG, batch scoring)? Decode-heavy rewards bandwidth (H200's HBM3e over H100); prefill-heavy rewards FLOPs and can batch on cheaper cards.
  1. Only now look at price. Choose the smallest instance that clears steps 1–3, then optimize $/token with Spot, Savings Plans, or Capacity Blocks (§11).
This ordering is the whole discipline: capacity → parallelism → regime → price. Starting from price picks a card the model does not fit on.



5. The topology problem — the gap most teams never see

This is the section that separates AI infrastructure from ordinary orchestration, and it is invisible on a dashboard until you measure a collective.
The hardware is not flat. A P5-class server is a NUMA machine: two CPU sockets, two NUMA nodes, multiple PCIe switches, 8 GPUs, and high-speed RDMA NICs. A GPU talks to a NIC or another GPU fast only when they share the same PCIe hierarchy; crossing the CPU interconnect (UPI / Infinity Fabric) is dramatically slower [11]. Inside the box, NVSwitch/NVLink gives all-to-all GPU bandwidth; across boxes, EFA with GPUDirect RDMA lets the NIC read GPU memory directly —  GPU → RDMA NIC , no host-memory copy, no kernel network stack [11][4].
The default scheduler is topology-blind. Kubernetes understands quantities —  nvidia.com/gpu: 1  — but not where that GPU sits: which NUMA node, which PCIe switch, which NIC is adjacent [11][14]. So it can hand you a GPU whose nearest NIC is across the interconnect, and every gradient all-reduce then pays the slow path: higher latency, lower throughput, longer training, more dollars — GPUs "waiting more than computing" [11].
On AWS, closing this gap is native at two layers:
  • Placement — launch multi-node jobs into a cluster placement group and, at scale, an EC2 UltraCluster, so instances are physically close on the network [4]. EFA is the transport NCCL rides for cross-node collectives.
  • Alignment — inside the node, the Kubernetes Topology Manager and device-plugin topology hints keep a pod's GPUs, CPUs, and NICs on the same NUMA node; a gang scheduler (Kueue, or SageMaker HyperPod's scheduler) admits the whole distributed job at once, so it never runs half-placed across the slow path [11].
The modern direction of this whole layer is Dynamic Resource Allocation (DRA), which replaces the count-based device-plugin model with a real resource model that can express "GPUs that share a NVLink domain" as a request, letting Kubernetes become the GPU control plane rather than a GPU counter [11][14]. Treat it as where the platform is going, not yet as the load-bearing default.
The test that this section is handled: a two-node, 16-GPU all-reduce sustains close to the single-node NVLink bandwidth per step. If it collapses, a job is crossing NUMA or leaving the placement group — a topology bug, not a model bug.



6. Storage — weights and data are on the critical path


Two storage problems, both of which show up as GPU idle time.
Weight loading is cold-start latency. A large model is tens to hundreds of GB. Pulling it from S3 to instance disk on every pod start can dominate scale-up and defeat autoscaling. The AWS-native fixes, in order of increasing effort:
  • Mountpoint for Amazon S3 — mount the bucket and stream weights; simplest, good when the read is sequential and one-shot.
  • FSx for Lustre, linked to the S3 bucket — a shared, high-throughput parallel filesystem in front of S3; the standard answer for training clusters and for many GPUs loading the same weights.
  • S3 Express One Zone — single-digit-ms first-byte for the hottest artifacts when even Lustre's warm-up is too slow.
  • Bake into the image or a pre-warmed EBS io2 volume — fastest cold start, least flexible; couples the model version to the image.
Datasets are training throughput. A trainer that out-runs its input starves — the GPU waits on I/O, gap #1 by another name. FSx for Lustre streaming from S3 is the default; checkpoints go back to S3 frequently, because on Spot or Capacity-Block capacity a node can vanish and the only thing that makes that survivable is a recent checkpoint (§8).
The principle: storage exists to keep the accelerator from waiting. Measure weight-load time and dataset throughput as first-class infrastructure metrics, not afterthoughts.



7. Orchestration — three routes, by how much you want to run

Same trade as everywhere in this repo: control versus operational burden.
  • Route A — EKS + Karpenter (self-managed). You run the cluster; Karpenter provisions GPU nodes just-in-time from the pending pods and consolidates them when idle. Maximum control over scheduling, sharing, and topology (§5, §8); maximum responsibility for the driver, device plugin, and node lifecycle. The right route when you need custom scheduling or GPU sharing the managed services do not expose.
  • Route B — SageMaker HyperPod (managed resiliency). AWS runs the training cluster with built-in health checks that detect a failed accelerator, cordon it, and resume from checkpoint automatically — the failure mode that dominates long multi-node training runs. You give up some cluster-level control for a large drop in babysitting.
  • Route C — AWS Batch / SageMaker training jobs (managed batch). Submit a job, AWS provisions, runs, and tears down. Best for fine-tuning and batch/offline inference where you do not want a standing cluster at all.
Cross-cutting, regardless of route: capacity is the real constraint. GPU instances are scarce; EC2 Capacity Blocks for ML let you reserve accelerator capacity for a defined window, which is how you guarantee a training run can start at all. On-demand GPU launch failures are a capacity problem, not a config problem — diagnose accordingly.



8. Multi-tenancy and GPU sharing — the genuinely hard part

The default GPU is a whole-card allocation. That wastes money on small models and still fails to isolate tenants. The sharing spectrum trades utilization against isolation, and every option lands somewhere different [12][13].
Mechanism
How it shares
Memory isolation
Fault isolation
Use it for
MPS (Multi-Process Service)
one shared CUDA context; kills context-switch overhead (~26% faster, far lower variance) [12]
none — one memory pool, no per-process accounting
weak — one crash can take down the card
trusted workloads in one team
Time-slicing
one physical GPU advertised as N logical GPUs [12]
none — no enforcement, just oversubscription
none
dev/test, bursty low-SLA work
MIG (Multi-Instance GPU)
hardware partitions of the card
hard — partitioned HBM and SMs
hard
multi-tenant on MIG-capable cards (A100/H100)
vGPU virtualization (e.g. HAMi model)
per-container HBM (MB) and SM-% limits, zero app changes [13]
hard — container sees only its allotment
strong
mixed-tenant clusters needing fine-grained slices
The multi-tenancy trap is not the GPU — it is everything around it. Two failures recur [12]:
  • Compute noisy-neighbour. A batch job holding a whole GPU leaves a latency-critical inference pod  Pending  for an hour, silently breaking its SLA. Whole-card requests plus a topology-blind scheduler produce this by default; the fix is a slicing mechanism above plus quotas/priority so real-time work preempts batch.
  • Network non-isolation. Namespaces are not a security boundary by default — a pod in  tenant-a  can often reach a service in  tenant-b  directly [12]. On AWS the fix is VPC CNI with Kubernetes NetworkPolicies (or security groups per pod), not the GPU layer at all.
The honest summary: MPS and time-slicing are for trusted co-tenants; MIG and vGPU are for real isolation; and none of them isolate the network. Choose the weakest mechanism that meets the actual trust boundary, because isolation costs utilization.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article