0%
LLM Inference and Serving: GPUs, Batching, and Cost
How Inference Works
Hardware and Memory
Making Inference Fast
Multi LoRA Serving
Many products want a model that behaves differently for each customer, task or domain: one that writes in a brand voice, one that extracts fields from a specific document type, one that follows a particular support policy. Fine tuning delivers this, but serving a separate full copy of the model for each variant is expensive. Low rank adapters, usually called LoRA, make it possible to keep one shared base model and swap in small task specific weights per request. This lesson covers how adapters work, how serving systems host many of them at once, how batching works when requests use different adapters, and how to run an adapter fleet in production.
Why fine tune at all
Prompting a general model can get far, but some behaviors are hard to prompt reliably: a consistent output format across thousands of edge cases, a specialized vocabulary, a house style, or a classification scheme with many subtle labels. Fine tuning on labeled examples teaches the model these behaviors directly. A fine tuned small model can match or beat a much larger prompted model on a narrow task, which cuts cost and latency. Fine tuning also shortens prompts, since instructions and examples that used to fill the context window are now baked into the weights, which saves tokens on every request.
The cost of full fine tuning
Full fine tuning updates every weight in the model. For a model with eight billion parameters in sixteen bit precision, that is about sixteen gigabytes of weights per variant. Serving ten variants means loading ten copies, each needing its own GPU memory, and each running as a separate deployment with its own replicas, autoscaling and idle capacity. Low traffic variants still need at least one replica, so the fleet fills with mostly idle GPUs. Training is expensive too, since gradients and optimizer state for every parameter must fit in memory. For products with many variants, full fine tuning quickly becomes impractical.
Parameter efficient fine tuning
Parameter efficient methods train only a small number of new parameters while freezing the base model. Adapters, prefix tuning and prompt tuning are examples, and LoRA has become the most widely used because it is simple, effective and adds no latency when merged. A LoRA adapter for an eight billion parameter model might hold tens of millions of parameters, well under one percent of the base, taking tens to a few hundred megabytes. Training fits on smaller GPUs, finishes faster and produces artifacts that are cheap to store and move.
What adapters can and cannot do
Adapters are good at shaping behavior: style, format, task focus, domain vocabulary and following specific instructions. They are weaker at adding large amounts of new factual knowledge, for which retrieval is usually a better fit. They inherit the base model strengths and weaknesses, so a weak base gives weak adapters. The quality gap between LoRA and full fine tuning is small for most behavior shaping tasks, especially at moderate ranks, which is why many teams use LoRA by default and reserve full fine tuning for cases where evaluation shows a real gap.
The multi tenant opportunity
Because adapters are small and the base is shared, one deployment of the base model can serve many adapters. A platform offering customer specific fine tunes can host hundreds or thousands of them on the same GPUs, loading each adapter when a request needs it. Traffic from all customers is pooled on shared replicas, so utilization stays high even if each customer sends only a trickle. This is the core idea of multi LoRA serving, and it changes the economics of per customer customization from one GPU per customer to a shared fleet.
Where multi LoRA shows up
Several patterns use many adapters. Fine tuning platforms let customers upload data and get a private adapter served on shared infrastructure. Products with many tasks, such as a writing tool with summarization, rewriting and extraction, can use one adapter per task on a shared base. Enterprises with many teams may give each team an adapter for their domain. Evaluation and experimentation also benefit: many adapter variants can be tested side by side on one deployment without spinning up new hardware for each experiment.
A cost comparison
Consider a platform with two hundred customers, each wanting a fine tuned eight billion parameter model, and a combined traffic that keeps about four GPUs busy. With full fine tuning, each customer needs at least one replica, so the fleet needs two hundred GPUs, and the average utilization is about two percent. With multi LoRA serving, the same traffic runs on four or five GPUs that host all two hundred adapters, with headroom for spikes. The difference, roughly forty times fewer GPUs, is the reason fine tuning platforms built their offerings around adapters. Even with some throughput overhead from mixed adapter batching, the savings are enormous.
Training costs compared
Training also gets cheaper. Full fine tuning of an eight billion parameter model in sixteen bit precision needs memory for weights, gradients and optimizer state, often well over a hundred gigabytes, requiring several large GPUs. LoRA training keeps the base frozen, so gradients and optimizer state are needed only for the small adapter, and the base can even be quantized. A LoRA run on the same model often fits on one GPU and finishes in minutes to hours for typical datasets of thousands of examples. This makes it practical to train adapters per customer, retrain them often and experiment with many variants.
Data requirements
Adapters need far less data than pretraining but still need good data. A few hundred to a few thousand high quality examples often suffice for format and style tasks, while classification with many labels or complex extraction may need more. Quality matters more than quantity: consistent labels, representative inputs and examples that cover edge cases. Noisy or contradictory data teaches the adapter inconsistent behavior. Platforms that train customer adapters benefit from data validation tools that flag duplicates, empty outputs, label imbalance and examples far longer than the context window.
Choosing the base model
The base model choice shapes everything. A stronger base gives stronger adapters but costs more to serve. A base that is too large for the task wastes money on every token, while one that is too small caps the achievable quality. Many platforms offer a few bases in different sizes and let customers pick based on evaluation. The base should also have a stable support horizon, since every adapter is tied to it, and frequent base changes force frequent retraining. Licensing terms of open weight bases matter too, especially for commercial platforms.
Adapters versus long prompts
An adapter can replace a long prompt full of instructions and few shot examples. That saves input tokens on every request, which reduces cost and time to first token, and it removes the risk of the model ignoring instructions buried in a long context. The tradeoff is flexibility: changing a prompt takes seconds, while changing an adapter takes a training run and an evaluation. Teams often prototype with prompts, then move stable, high volume behaviors into adapters once the requirements settle and enough examples have accumulated from production.
Common mistakes
Common mistakes with adapters include training on data that does not match production inputs, so the adapter performs well offline and poorly live; overfitting to a small dataset, which shows up as repetitive outputs or poor handling of new cases; skipping comparison with a simple prompting baseline, which sometimes turns out to be just as good; and forgetting that the adapter is tied to a base version. A disciplined pipeline with held out evaluation and baselines avoids most of these.
With a shared base, adding a variant means training and uploading a small file. The fleet size follows total traffic, not the number of variants.