How do you serve hundreds of fine-tuned LoRA adapters on one base model efficiently?
Written by the mlprep team · Updated
Your platform lets each customer fine-tune the same base LLM with LoRA. You now have hundreds of adapters. Deploying a separate copy of the model for each customer is far too expensive. How do you serve them all efficiently?
What a LoRA adapter is#
LoRA freezes the base weight matrix and learns a low-rank update for selected layers:
With a small rank, an adapter is a tiny fraction of the base model's size. That asymmetry is the opportunity: the expensive part, the base weights, is identical for every customer.
Option 1: merge adapters into the weights#
Compute once and serve the merged model. There is zero extra inference cost, but each adapter becomes a full model copy. That is fine for a few high-traffic tenants and impossible for hundreds.
Option 2: keep adapters separate and batch across them#
Keep one copy of the base weights on the GPU and apply each request's adapter on the fly:
where is the adapter for that request. The base matmul is batched across all requests regardless of adapter. The adapter path is a small extra computation per request.
The difficulty is that a batch now contains requests for many different adapters. Looping over adapters one at a time launches many tiny kernels and wastes the GPU. Systems like Punica and S-LoRA introduced custom kernels that gather each request's adapter weights and compute all of the low-rank products for a heterogeneous batch in one launch. vLLM and other serving engines expose multi-LoRA serving built on the same idea.
Why this works economically#
Decode is memory-bandwidth-bound: each step streams the base weights from HBM. Batching requests from many customers over one copy of those weights amortizes that cost, exactly like continuous batching does for a single model. The adapter math adds a small overhead that grows with rank and with how many distinct adapters are in the batch.
You have far more adapters than fit in GPU memory alongside the KV cache. How do you manage adapter memory, and how do you route requests?
A memory hierarchy for adapters#
Treat adapters like a cache:
- GPU: the currently active and hot adapters.
- CPU memory: a much larger set, loaded to the GPU over PCIe when needed.
- Disk or object storage: everything else.
Loading an adapter from CPU memory adds latency to that request's first token, so prefetch adapters for queued requests and evict with an LRU or frequency-based policy.
Adapters and the KV cache compete for the same GPU memory. S-LoRA's unified paging manages both in one paged memory pool, so memory moves to whichever needs it, instead of statically reserving space for adapters and starving the KV cache, or the reverse.
Routing across replicas#
With multiple GPU servers:
- Route requests for the same adapter to the same subset of replicas (adapter affinity) so hot adapters stay resident and cache hits stay high.
- Spread very hot adapters across several replicas so one customer doesn't create a hot spot.
- Treat cold-adapter load time as part of the time-to-first-token SLO, and give large customers with strict SLOs pinned capacity or a merged dedicated deployment.
Trade-offs to state#
- Mixing many distinct adapters in one batch costs some throughput compared with a single merged model.
- Different ranks across adapters complicate batching kernels. Many platforms constrain the allowed ranks.
- Isolation: one tenant's traffic spike affects others on shared replicas, so you need per-tenant rate limits and fair scheduling.
Interview red flags#
- Proposing one deployment per customer without recognizing that the base weights are shared.
- Merging adapters into the base weights for hundreds of tenants, which turns each adapter into a full model copy.
- Assuming requests for different adapters can't share a batch.
- Ignoring that adapters and the KV cache compete for the same GPU memory.
- No answer for what happens when a request's adapter isn't loaded.
Go deeper: Continuous batching covers the iteration-level scheduling this builds on; PagedAttention covers the paged KV cache that unified paging extends to adapters.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Serve many LoRA adapters by keeping one shared copy of the base weights and applying each request's low-rank update on the fly. Batch requests for different adapters together with kernels built for heterogeneous adapters (Punica, S-LoRA, vLLM multi-LoRA), cache adapters across GPU, CPU, and storage with prefetching, manage adapter and KV cache memory from one pool, and route with adapter affinity. Merge adapters only for a few very high-traffic tenants.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- How does LoRA rank affect serving cost, and would you restrict the ranks customers can train with?
- How would you guarantee one tenant's traffic spike doesn't break another tenant's latency SLO?
- When would you switch a customer from a shared multi-LoRA deployment to a dedicated merged model?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
How does continuous batching work and why does static batching waste GPU utilization?
How would you design an LLM serving system for millions of users?
Explain PagedAttention and how vLLM eliminates KV cache memory fragmentation
How do you measure and optimize TTFT, TPOT, and goodput under production SLA constraints?