Configuring Self-Hosted Foundation Model Serving
This lesson explains how self-hosting a large language model means fitting it onto accelerators, choosing a serving engine and allocating resources so throughput and latency meet requirements at acceptable cost.
Learning outcomes
After completing this lesson, you will be able to:
- Size accelerator memory from parameters and precision.
- Use large model inference containers.
- Allocate resources with inference components.
Memory sizing
Model weights need roughly parameters x bytes per parameter of accelerator memory: a 7-billion-parameter model in 16-bit precision needs about 14 GB for weights, plus memory for the KV cache, which grows with batch size and sequence length. Quantization to 8-bit or 4-bit weights cuts memory by two or four times with a small quality loss. If the model does not fit on one GPU, tensor parallelism splits it across the GPUs of an instance.
The following diagram compares how the weights of a 70-billion-parameter model fit on the GPUs of two hosting options.

How much GPU memory?
Large model inference containers
Serving large language models efficiently needs specialised software. SageMaker AI large model inference (LMI) containers package serving engines such as vLLM, TensorRT-LLM and LMI-Dist, configured with properties such as tensor_parallel_degree, which splits the model across GPUs, max_rolling_batch_size, the maximum model length and quantisation, which reduces memory by using lower-precision weights.
Continuous (rolling) batching adds new requests to a running batch as others finish, instead of waiting for the whole batch to complete, which greatly improves GPU utilisation and throughput. Streaming responses reduce the time to the first token, which is what users notice most in chat applications.
LMI settings
Allocating resources with inference components
Inference components let several models share one endpoint's instances. Each component specifies the accelerator devices, CPU cores and memory needed per copy of its model, and the number of copies; SageMaker AI packs the copies onto instances efficiently. With managed instance scaling, the endpoint adds or removes instances as components scale, so capacity follows demand.
On Amazon Bedrock, Provisioned Throughput allocates capacity in model units, each providing a defined throughput, for workloads that need guaranteed capacity or that use custom models. The following table summarises the main settings.
| Setting | Effect |
|---|---|
| Instance type (GPU memory) | Which model sizes fit |
| tensor_parallel_degree | Split a model across GPUs |
| Quantization (int8, int4) | Less memory, small quality loss |
| max_rolling_batch_size | Concurrent sequences: throughput vs latency |
| Max model length | Longest prompt plus output; affects KV cache memory |
| Inference component accelerators and copies | GPU sharing and per-model scaling |
Fitting a 70B model
A team must host a 70-billion-parameter open model with 8,000-token contexts on SageMaker AI.
Weights at FP16: 70e9 x 2 bytes = ~140 GB -> does not fit on one 80 GB GPU
Option A: ml.p4d.24xlarge (8 x 40 GB = 320 GB), tensor_parallel_degree=8, FP16
Option B: ml.g6e.12xlarge (4 x 48 GB = 192 GB), tensor_parallel_degree=4, int8 weights (~70 GB)
Both leave memory for the KV cache; continuous batching raises throughputAfter an evaluation confirms int8 quality is acceptable, Option B is chosen as cheaper per hour. Trying to deploy at FP16 on a single GPU would fail with out-of-memory errors regardless of batch size.
How can a model's GPU memory footprint be reduced with a small loss in quality?
Show answer
With quantisation, which stores weights at lower precision.
Exam Tips
Remember for the exam
- Weights need roughly parameters x bytes per parameter of GPU memory, plus KV cache.
- Model too large for one GPU: tensor parallelism.
- Quantization reduces memory with small quality loss.
- Continuous batching improves LLM throughput.
- Share GPUs between models: inference components.