Hosting Large Language Models on SageMaker AI
This lesson explains the building blocks for self-hosting a foundation model on SageMaker AI, chosen when Bedrock does not offer the model or the required control, or for hybrid designs.
Learning outcomes
After completing this lesson, you will be able to:
- Deploy models from SageMaker JumpStart.
- Use large model inference containers.
- Deploy and scale models with inference components.
SageMaker JumpStart
SageMaker JumpStart is a hub of pre-trained models, including many open-weight foundation models, each with tested deployment and fine-tuning configurations. Deploying a JumpStart model creates a real-time SageMaker AI endpoint on a recommended GPU instance type, with an inference container already optimised for that model, in a few clicks in SageMaker Studio or a few lines of the SageMaker Python SDK. The developer does not need to choose a container, work out how many GPUs the model needs or tune the serving engine.
JumpStart also provides fine-tuning recipes for many models, and the resulting model can be deployed in the same way. It is the fastest path to a self-hosted foundation model and suits proofs of concept and teams that want sensible defaults. Teams that later need finer control can move to large model inference containers with their own configuration, described next, without changing the endpoint interface their applications use.
Large model inference containers
Serving a large language model efficiently is difficult: the model may not fit on one GPU, requests have very different lengths, and memory for each request's attention cache must be managed carefully. SageMaker AI large model inference (LMI) containers package model servers and inference engines, such as vLLM and TensorRT-LLM, that solve these problems.
Their key features are continuous (rolling) batching, which adds new requests to a running batch as others finish instead of waiting for the whole batch, greatly improving GPU utilisation; paged attention, which manages the key-value (KV) cache memory in small blocks so more concurrent requests fit; tensor parallelism, which splits a model too large for one GPU across all the GPUs of an instance; quantisation, which reduces memory by using lower-precision weights; token streaming; and serving of LoRA adapters. Configuration is given as environment variables or in a serving.properties file, as in the following example.
# Environment for an LMI container serving a model across 4 GPUs with vLLM
HF_MODEL_ID=s3://my-bucket/models/llama-70b-finetuned/
OPTION_ROLLING_BATCH=vllm
OPTION_TENSOR_PARALLEL_DEGREE=4
OPTION_MAX_ROLLING_BATCH_SIZE=64
OPTION_MAX_MODEL_LEN=8192
OPTION_QUANTIZE=fp8The following diagram compares static batching with continuous batching.

LMI container techniques
Inference components and scaling
An inference component deploys a model onto an endpoint with its own compute allocation (accelerators, CPU and memory) and copy count. Several models or adapters can share one endpoint's instances, each scaling its copies independently, which improves GPU utilisation. Inference components can scale down to zero copies when idle and back up when requests arrive.
Auto scaling uses target tracking on metrics such as invocations per copy or concurrent requests, because CPU utilisation does not reflect GPU-bound LLM load. For long-running or large requests, asynchronous inference endpoints queue requests and write results to S3. Hybrid designs combine a SageMaker AI endpoint for a specialised fine-tuned model with Bedrock for general tasks behind one API. The following table compares the hosting choices.
| Choice | Control | Effort | Typical use |
|---|---|---|---|
| Bedrock on-demand | Model choice and parameters | Lowest | Most applications |
| Bedrock Custom Model Import | Own weights, managed serving | Low | Fine-tuned supported architectures |
| SageMaker JumpStart endpoint | Instance and configuration | Medium | Open-weight models with defaults |
| SageMaker AI LMI endpoint | Container, engine, parallelism, quantisation | Higher | Custom serving needs and many adapters |
Sharing endpoint capacity
A model not on Bedrock
A research team needs a specialised open-weight biomedical model that Bedrock does not offer. It needs streaming responses and must serve three LoRA variants for different departments, with traffic only during working hours.
A SageMaker AI endpoint with an LMI container provides streaming and adapter serving; the base model and three adapter inference components share the instances; and scaling the components to zero outside working hours controls cost. JumpStart can supply the deployment configuration if the model is in the hub.
Which SageMaker AI feature lets several models share instances, scale independently and scale to zero?
Show answer
Inference components.
Exam Tips
Remember for the exam
- Fastest self-hosted FM: SageMaker JumpStart.
- LMI containers: continuous batching, tensor parallelism, quantisation, streaming, LoRA.
- Inference components share instances and scale independently, including to zero.
- Scale LLM endpoints on concurrency or invocations, not CPU.