Skip to main content
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
Replica 1 · one GPU hostApplicationsSQL bot · support botGateway + EPPpicks a replicaBase modelGBs · loaded onceGPU LoRA slots--max-lorassql-loraMBssupport-loraMBsCPU adapter cache--max-cpu-lorasReplica 2other adapters loadedLoRA trainingtrains A and B onlyAdapter registryversioned filesone 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 settingWhat it controlsWatch out
--enable-loraTurns on adapter supportWithout it, adapter model names are unknown
--lora-modules name=pathAdapters registered at startupThe name is what clients send as model
--max-lorasMax different adapters in one batch (default 1)Each slot reserves GPU memory, leaving less for the KV cache
--max-lora-rankLargest adapter rank accepted (default 16)Set it to the largest rank you serve; higher wastes memory
--max-cpu-lorasAdapters kept in host memoryMust be at least --max-loras; misses go to disk or the registry
VLLM_ALLOW_RUNTIME_LORA_UPDATING=TrueEnables /v1/load_lora_adapter and /v1/unload_lora_adapterLets callers load files; keep it in trusted networks only
SymptomLikely causeFix
Latency spikes for some adapters onlyAdapter swapped in on demandMore GPU slots, larger CPU cache, or adapter-aware routing
Adapter fails to loadRank above --max-lora-rank, or trained on another baseRaise the limit, or retrain on the served base model
Same prompt, different answers across replicasOne adapter name, several file versionsImmutable 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

  1. Why can one GPU serve dozens of LoRA fine-tunes but not dozens of full fine-tunes?
  2. A server has --max-loras 2. Three requests for three different adapters arrive at once. What happens?
  3. Why should the gateway route sql-lora requests to replicas that already have sql-lora loaded?

Further reading: vLLM LoRA adapters · LoRA paper · Gateway API Inference Extension · Which Replica Gets the Request (Inference Routing) · Batching Requests (Continuous Batching)