On this page
Fine-tuning with LoRA is cheap, so teams end up with many fine-tunes: one per customer, per language, per task. The naive way to serve them is one deployment per fine-tune, which means one GPU (or more) each, mostly idle. With 50 fine-tunes, that's 50 GPUs serving traffic that one or two could handle.
Multi-LoRA serving fixes this: one copy of the base model, many adapters, all batched together.
#Why adapters are small
LoRA freezes the base weights and learns a low-rank update for selected matrices: instead of changing a matrix, it learns two thin matrices of shapes and , where the rank is small (8 to 64 is typical). Each adapted matrix adds parameters (LoRA and QLoRA in depth).
For a Llama-class 8B model (32 layers, hidden size 4,096, MLP size 14,336, 8 KV heads) with LoRA on all seven linear layers per block, the parameters per layer at rank are:
| Matrix | Shape | LoRA parameters |
|---|---|---|
| Query, output | 4,096 × 4,096 | each |
| Key, value | 4,096 × 1,024 | each |
| Gate, up, down | 4,096 × 14,336 | each |
| Total per layer |
At rank 16 over 32 layers, that's about 42 million parameters: about 84 MB in BF16, against 16 GB for the base model. You could hold 100 such adapters in about 8.4 GB.
#How multi-LoRA batching works
The output of an adapted layer is the base output plus the adapter's contribution:
where is the adapter for that request. The expensive part, , is the same for every request, so the whole batch shares one large matrix multiply against the base weights. Only the small part differs per request.
Doing that small part efficiently for a batch where every request may use a different adapter needs special kernels. The Punica project introduced a "segmented gather" kernel that applies each request's adapter in one launch, and the S-LoRA paper showed a single server handling thousands of adapters by paging them between CPU and GPU memory. vLLM and SGLang use kernels in the same spirit.
The result: a batch can mix requests for many adapters with modest overhead compared with serving the base model alone. The overhead grows with rank and with the number of different adapters active in one step, so measure it at your settings.
#The vLLM settings that matter
| Setting | What it controls |
|---|---|
--enable-lora |
Turns on adapter support |
--lora-modules name=path |
Adapters to load at startup, each exposed as its own model name |
--max-loras |
Adapters that can be active in one batch, held in GPU memory |
--max-lora-rank |
Largest rank allowed; memory is reserved for this size |
--max-cpu-loras |
Adapters kept cached in CPU memory for fast swapping |
Clients pick an adapter by setting the model field of an OpenAI-style request to the adapter's name. vLLM can also load and unload adapters at runtime through an API when runtime updating is enabled; check your version's documentation for the exact switches. SGLang and LoRAX offer similar features under different names.
Two settings are easy to get wrong:
max-lora-rankset far above what you use. vLLM reserves memory for the maximum rank, so setting 256 when your adapters are rank 16 wastes memory that could hold KV cache.max-lorastoo low for your traffic mix. If more distinct adapters are requested at once than fit, requests wait for a slot or adapters thrash in and out of GPU memory. Watch latency per adapter.
#Where the overhead comes from
Two costs, and they behave differently.
Extra compute is tiny. For one token through one adapted matrix, the base multiply costs FLOPs and the adapter adds . For a 4,096 × 4,096 query projection at rank 16, that's about 33.6 million FLOPs for the base and 0.26 million for the adapter: under 1%. Across the whole 8B model the adapter adds about 0.5% to the compute per token.
Extra memory reads grow with the number of distinct adapters in a step. Decode is bandwidth-bound (why memory bandwidth decides LLM speed), and each adapter used in a step must be read:
| Distinct adapters in one decode step | Adapter bytes read (rank 16, 8B model) | Extra over the 16 GB base |
|---|---|---|
| 1 | about 84 MB | about 0.5% |
| 8 | about 0.67 GB | about 4% |
| 32 | about 2.7 GB | about 17% |
So a batch where every request uses a different adapter is noticeably slower per step than one where requests share adapters. Routing requests for the same adapter to the same replica (and the same steps) keeps this down.
#Choosing a rank
| Rank | Adapter size (all linear layers, 8B model, BF16) | Typical use |
|---|---|---|
| 8 | about 42 MB | Style, format, simple tasks |
| 16 | about 84 MB | A common default |
| 64 | about 336 MB | Harder tasks, more new behaviour |
Higher rank isn't automatically better quality, and it costs memory and bandwidth at serving time. Choose rank during training based on evaluation results, then set the server's maximum rank to match (training recipes for LoRA).
#Calling an adapter
Each adapter appears as its own model name, so clients choose one per request:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "customer-a", "messages": [{"role": "user", "content": "Summarise this ticket."}]}'Requests that name the base model get no adapter. To add adapters without restarting, vLLM can load and unload them through API calls when runtime updating is enabled (an environment variable turns it on); this is how platforms add a new customer's fine-tune within seconds. Treat that endpoint as an admin API and keep it away from the public internet.
#Merge, or serve dynamically?
| Approach | Best when | Trade-off |
|---|---|---|
| Merge the adapter into the weights | One fine-tune gets nearly all the traffic | Zero adapter overhead; one deployment per fine-tune |
| Multi-LoRA on a shared base | Many fine-tunes, each with modest traffic | Small per-token overhead; huge saving in GPUs |
| Hybrid | A few heavy adapters plus a long tail | Merge the heavy ones into dedicated deployments; serve the tail together |
#Operational patterns
- Store adapters in object storage with versioned paths, and load them on demand. Treat each adapter version as an immutable artefact.
- Route by adapter affinity when you have several replicas, so requests for the same adapter land where it's already loaded (and where its prefix cache is warm).
- Pin all adapters to one base model version. An adapter trained on one base checkpoint gives wrong results on another, sometimes subtly.
- Monitor per adapter: request rate, latency and error rate. One misbehaving adapter can hide inside an aggregate dashboard.
- Validate quality on load. A small smoke test per adapter catches a corrupted or mismatched file before customers do.
- Quantised bases work too. Serving adapters on an FP8 or 4-bit base is common, but check quality, since the adapter was usually trained against higher-precision weights.
#A quick sizing example
Suppose 200 customer adapters on an 8B base, rank 16, with traffic concentrated in about 20 adapters at any moment. On one 80 GB GPU in BF16:
- Base weights: 16 GB.
- 32 active adapters on the GPU (
--max-loras 32): about 2.7 GB. - The other adapters cached in CPU memory (
--max-cpu-loras 200): about 17 GB of host RAM. - The rest of GPU memory goes to KV cache, as usual.
Compared with 200 separate deployments, that's one GPU (or a few replicas for traffic) instead of hundreds. The cost per adapter is close to zero; capacity is set by total traffic, as for any single model (how many GPUs do you need).
#The cost difference
At an illustrative $2.50 per GPU-hour, 200 dedicated single-GPU deployments running all month cost about $365,000. Four shared replicas cost about $7,300. Even if per-token speed drops by 10 to 20% from adapter overhead, the shared design is around 50 times cheaper. Dedicated deployments only make sense for the few adapters with enough traffic to keep their own GPUs busy.
#Common mistakes
- One deployment per fine-tune when traffic per fine-tune is low.
max-lora-rankfar above the real ranks, wasting KV cache memory.- Adapters trained on a different base checkpoint than the one being served.
- No per-adapter metrics, so one broken adapter hides in the averages.
- Ignoring tokenizer and chat template changes. If fine-tuning added tokens or changed the template, the server must use the same ones.
#FAQ
Does multi-LoRA serving reduce quality compared with a merged model? No. Applying the adapter at runtime computes the same result as merging it, up to floating-point rounding.
Can adapters be used with speculative decoding or prefix caching? Generally yes, though support for combining features varies by engine and version. Prefix caches are kept per adapter, since the same text gives different keys and values under different adapters.
What about full fine-tunes? They change every weight, so they can't share a base model. Each needs its own deployment, which is one of the strongest practical reasons to fine-tune with LoRA (LoRA and QLoRA in depth).
#Go deeper
Multi-LoRA and adapter serving covers the kernels, scheduling and memory management in depth, and the LoRA and QLoRA lesson covers training the adapters.
lorafine-tuningmulti-tenantvllminference-engineering
Found this useful?
Send it to someone who is learning the same thing.
Next: learn it step by step, free
Prefill, decode and the roofline
Why decode is memory-bound, with worked numbers for real GPUs. The idea the rest builds on. A free lesson with step-through diagrams and a quiz.