Right-Sizing Inference Instance Families
This lesson explains how matching the instance family to the model's needs is the first and largest cost lever, since inference endpoints run continuously and often account for most ML cost.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish the instance families for inference.
- Find the right instance with Inference Recommender.
- Read a model's resource profile.
Instance families
SageMaker AI instance names follow the EC2 pattern. ml.m (general purpose) and ml.c (compute optimised) suit tree models, linear models and small neural networks. ml.r (memory optimised) suits models with large in-memory structures. ml.g5, ml.g6 and ml.g6e (NVIDIA GPUs) suit deep learning inference and small to medium LLMs. ml.p4d and ml.p5 suit the largest models. ml.inf2 (AWS Inferentia2) gives high throughput and low cost per inference for supported deep learning models compiled with the AWS Neuron SDK. Graviton-based instances (such as ml.c7g) lower cost for CPU inference.
Instance families
Finding the right instance
SageMaker Inference Recommender runs load tests of a registered model on several instance types and reports latency, throughput and cost per inference, either as a quick default job or an advanced job with custom traffic patterns and latency requirements. AWS Compute Optimizer recommends right-sizing for EC2 instances and other resources from utilisation history. Endpoint utilisation metrics show over-provisioning: an endpoint at 10% CPU is a candidate for a smaller or cheaper instance.
The following table summarises the families.
| Family | Best for |
|---|---|
| ml.c / ml.m (and Graviton variants) | Classic ML, small models, CPU inference |
| ml.r | Memory-heavy models |
| ml.g5 / ml.g6 / ml.g6e | Deep learning, small and medium LLMs |
| ml.p4d / ml.p5 | Largest models, highest throughput |
| ml.inf2 (Inferentia2) | Lowest cost per inference for supported deep learning models |
Right-size it
Reading a model's resource profile
Choosing a family starts with identifying the resource that limits the model. A gradient-boosted tree or linear model performs a modest amount of arithmetic per request and is usually limited by CPU, so compute-optimized instances, or Graviton variants where the framework supports Arm, give the best price. A model that keeps a large lookup table, embedding matrix or cache in memory is limited by RAM, and memory-optimized instances supply more memory per vCPU without paying for unneeded cores.
Deep learning models, especially transformers and convolutional networks, perform large matrix multiplications that GPUs and Inferentia execute far faster than CPUs. For them, the key question is memory on the accelerator: the weights, the activations of a batch and, for LLMs, the key-value cache must fit. A model that fits on one GPU with room for batching belongs on a single-GPU instance such as ml.g5 or ml.g6; a model that does not fit needs a multi-GPU instance with tensor parallelism or quantisation. Inferentia2 suits models that the Neuron SDK supports and that serve high volumes, where its lower cost per inference outweighs the effort of compilation.
Utilization metrics confirm or correct the choice after deployment. Low CPU and GPU utilisation at peak traffic indicates an oversized instance; GPU utilisation near zero on a GPU instance indicates a model that does not use the accelerator at all; high latency with low utilisation points to a bottleneck elsewhere, such as payload handling or downstream calls, which a larger instance would not fix. Decisions should be based on load tests and these metrics, not on assumptions about the model type.
The following diagram shows the measured finding for each of three endpoints and the change it led to.

Right-sizing three endpoints
A team reviews three endpoints with Inference Recommender and utilisation data.
| Endpoint | Current | Finding | Change |
|---|---|---|---|
| XGBoost churn | ml.g5.xlarge | GPU unused (XGBoost on CPU path) | ml.c7g.large |
| Image classifier | ml.g5.2xlarge, 20% GPU | Inferentia2 supported, 45% cheaper per inference | ml.inf2.xlarge |
| BERT classifier | ml.m5.4xlarge, p99 at limit | CPU-bound | ml.g6.xlarge (lower latency, similar cost) |
Each change follows from measurement. A blanket policy of "GPUs for everything" or "cheapest CPU for everything" would have been wrong for at least one of the three.
Which instances suit tree and linear models?
Show answer
CPU instances, not GPUs.
Exam Tips
Remember for the exam
- Benchmark instance types for a model: SageMaker Inference Recommender.
- Tree and linear models: CPU instances, not GPUs.
- Lowest cost per inference for supported deep learning models: Inferentia2.
- Low utilization: right-size to a smaller or cheaper instance.
- Graviton lowers CPU inference cost.