AI on Kubernetes · GPU/NPULesson 15 of 20
Serving Many LoRA Adapters on One Base Model
LoRA fine-tuning leaves the base model alone and trains a small add-on, the adapter. Because adapters are small, one GPU can hold one copy of the base model and apply a different adapter to each request.
Requested model—
Adapters on GPU—
Extra costone full model per task
RequestResponse / reportWatchAppears in a later step
What you will learn
- Why a LoRA adapter is tiny next to the base model
- How a request picks an adapter by model name
- What --max-loras and --max-lora-rank limit
- What swapping adapters in and out costs
- Routing to replicas that already hold the adapter
- Versioning adapters so results do not change silently
vLLM LoRA settings
| Flag or setting | What it controls | Watch out |
|---|---|---|
--enable-lora | Turns on adapter support | Without it, adapter model names are unknown |
--lora-modules name=path | Adapters registered at startup | The name is what clients send as model |
--max-loras | Max different adapters in one batch (default 1) | Each slot reserves GPU memory, leaving less for the KV cache |
--max-lora-rank | Largest adapter rank accepted (default 16) | Set it to the largest rank you serve; higher wastes memory |
--max-cpu-loras | Adapters kept in host memory | Must be at least --max-loras; misses go to disk or the registry |
VLLM_ALLOW_RUNTIME_LORA_UPDATING=True | Enables /v1/load_lora_adapter and /v1/unload_lora_adapter | Lets callers load files; keep it in trusted networks only |
| Symptom | Likely cause | Fix |
|---|---|---|
| Latency spikes for some adapters only | Adapter swapped in on demand | More GPU slots, larger CPU cache, or adapter-aware routing |
| Adapter fails to load | Rank above --max-lora-rank, or trained on another base | Raise the limit, or retrain on the served base model |
| Same prompt, different answers across replicas | One adapter name, several file versions | Immutable names like sql-lora-v3 |
Try it yourself
# Serve a base model with one adapter registered at startup
vllm serve meta-llama/Llama-3.2-3B-Instruct --enable-lora \
--lora-modules sql-lora=jeeejeee/llama32-3b-text2sql-spider \
--max-loras 4 --max-lora-rank 64 --max-cpu-loras 8
curl -s localhost:8000/v1/models | jq '.data[] | {id, parent}' # Adapters appear with parent = base model
# Pick the adapter by model name
curl -s localhost:8000/v1/completions -H 'Content-Type: application/json' \
-d '{"model": "sql-lora", "prompt": "List all users older than 30 in SQL:", "max_tokens": 64}'
# Dynamic loading (only on a server started with VLLM_ALLOW_RUNTIME_LORA_UPDATING=True, trusted network)
curl -s -X POST localhost:8000/v1/load_lora_adapter -H 'Content-Type: application/json' \
-d '{"lora_name": "sql-lora-v3", "lora_path": "/adapters/sql-lora-v3"}'
curl -s -X POST localhost:8000/v1/unload_lora_adapter -H 'Content-Type: application/json' \
-d '{"lora_name": "sql-lora"}'
curl -s localhost:8000/metrics | grep vllm:lora_requests_info # Which adapters are running and waiting
Check yourself
Further reading: vLLM LoRA adapters · LoRA paper · Gateway API Inference Extension · Which Replica Gets the Request (Inference Routing) · Batching Requests (Continuous Batching)