Thursday, November 12, 2026

Manage Multiple LoRA Adapters With vLLM: A Practical Guide

Say a team has fine-tuned one 3B model five times: once for SQL generation, once for support replies, once each for three customers’ writing styles. Deploying five full copies of the model means five times the GPU memory, and most of those copies sit idle most of the day.

LoRA adapters and vLLM solve this together. Because each fine-tune is a LoRA adapter, a few megabytes of extra weights on top of a shared base model, vLLM can load the base model once and apply a different adapter to each request in the same batch. You turn it on with enable_lora=True, size it with max_loras and max_lora_rank, and pick the adapter per request with a LoRARequest or, on the server, with the model field. This guide shows both setups with the current vLLM API, explains each setting and covers loading adapters at runtime.

Key Takeaways

  • A LoRA adapter stores only a low-rank update to a model’s weights, so many adapters can share one copy of the base model in GPU memory.
  • In Python, create the model with LLM(..., enable_lora=True) and pass lora_request=LoRARequest(name, id, path) to generate. A list of requests applies a different adapter to each prompt.
  • max_loras sets how many adapters can run in one batch (default 1), max_lora_rank the largest adapter rank supported (default 16) and max_cpu_loras how many adapters stay cached in CPU memory.
  • With vllm serve --enable-lora --lora-modules name=path, each adapter appears as its own model name in the OpenAI-compatible API.
  • Adapters can be loaded and unloaded at runtime, but the vLLM docs warn that this carries security risks outside a fully trusted environment.

What Is a LoRA Adapter?

LoRA (Low-Rank Adaptation) is a fine-tuning method that freezes a model’s original weights and trains a pair of low-rank matrices for selected layers instead. The trained matrices are the adapter. At inference time, their product is added to the frozen weights.

The method comes from “LoRA: Low-Rank Adaptation of Large Language Models” by Edward Hu and colleagues (2021). For GPT-3 175B, the paper reports that LoRA cut the number of trainable parameters by 10,000 times and GPU memory needs during training by 3 times compared with full fine-tuning, while matching or exceeding full fine-tuning quality on the tasks tested.

The rank is the key number. A weight matrix of 3,072 by 3,072 has about 9.4 million values. A rank-8 LoRA update for it is two matrices of 3,072 by 8 and 8 by 3,072, about 49,000 values, roughly 0.5% of the original. That is why one GPU can hold a base model plus many adapters.

Why Serve Multiple Adapters on One Model?

Without multi-LoRA support, you have two options, and both are poor. You can merge each adapter into its own full copy of the model and deploy them separately, paying for GPU memory for every copy. Or you can swap adapters in and out of one deployment, which forces requests for different adapters to wait for each other.

vLLM takes a third path. The base model is loaded once, adapters are kept in a cache, and requests that use different adapters can be batched together. The vLLM documentation describes adapters as served “on a per-request basis with minimal overhead”. The base model’s weights are shared, so adding the fifth adapter in the opening example costs a few megabytes, not another full model.

Offline Inference With Multiple LoRA Adapters

The example below follows the pattern in the vLLM LoRA documentation, using its Llama 3.2 3B Instruct base model and a public text-to-SQL adapter. It needs a CUDA GPU and access to the Llama 3.2 model on Hugging Face. We checked it against the current vLLM source (version 0.32 on PyPI) and compiled it, but could not run it without a GPU.

pip install vllm
from huggingface_hub import snapshot_download
from vllm import LLM, SamplingParams
from vllm.lora.request import LoRARequest

# A text-to-SQL adapter for Llama 3.2 3B Instruct, used in the vLLM docs.
sql_lora_path = snapshot_download(repo_id="jeeejeee/llama32-3b-text2sql-spider")

llm = LLM(
    model="meta-llama/Llama-3.2-3B-Instruct",
    enable_lora=True,
    max_loras=2,       # adapters that can be active in the same batch
    max_lora_rank=8,   # must be at least the rank of every adapter you load
    max_cpu_loras=4,   # adapters kept in the CPU cache, must be >= max_loras
)

# LoRARequest(name, unique integer ID, local path). Two names over the same
# weights, as in vLLM's multilora example; in practice each points to its own adapter.
sql_a = LoRARequest("sql-lora", 1, sql_lora_path)
sql_b = LoRARequest("sql-lora-2", 2, sql_lora_path)

sampling_params = SamplingParams(temperature=0, max_tokens=256, stop=["[/assistant]"])

prompts = [
    "[user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_74 (icao VARCHAR, airport VARCHAR)\n\n question: Name the ICAO for lilongwe international airport [/user] [assistant]",
    "[user] Write a SQL query to answer the question based on the table schema.\n\n context: CREATE TABLE table_name_11 (nationality VARCHAR, elector VARCHAR)\n\n question: When Anchero Pantaleone was the elector what is under nationality? [/user] [assistant]",
]

# 1. Base model only: no lora_request.
base_outputs = llm.generate(prompts, sampling_params)

# 2. One adapter for every prompt.
outputs = llm.generate(prompts, sampling_params, lora_request=sql_a)

# 3. A different adapter per prompt, in the same batch.
mixed_outputs = llm.generate(prompts, sampling_params, lora_request=[sql_a, sql_b])

for output in mixed_outputs:
    print(output.outputs[0].text)

Three things in this code matter in production:

  • The integer ID must be unique per adapter. vLLM uses it, not the name, to identify the adapter in its cache. The source notes this is not enforced, so two different adapters with the same ID can lead to the wrong weights being used.
  • The path is a local directory. snapshot_download fetches the adapter from Hugging Face and returns where it was saved.
  • A list of requests is matched to prompts in order. The first prompt uses sql_a and the second uses sql_b, in one call.

For an engine-level example that adds requests one at a time, see vLLM’s multilora_offline.py example, which mixes base-model and adapter requests in a single run.

The LoRA Settings That Control Memory

vLLM reserves GPU memory for adapters when the engine starts, so these settings decide both capacity and memory use:

Setting Default What it controls
enable_lora False Turns on LoRA support. Without it, LoRA requests fail.
max_loras 1 How many different adapters can be active in the same batch. Each slot needs its own preallocated GPU memory.
max_lora_rank 16 The largest adapter rank supported. Every adapter you load must have a rank at or below it. Accepted values are 1, 8, 16, 32, 64, 128, 256, 320 and 512. Higher values use more memory for every slot.
max_cpu_loras None (falls back to max_loras) How many adapters stay cached in CPU memory, ready to move to the GPU. Must be at least max_loras.

Here is how max_loras plays out. With max_loras=1, the official multi-LoRA example notes that requests for a second adapter run only after all requests for the first adapter finish. With max_loras=2, both adapters can share a batch. Set it to the number of adapters you expect to see at the same time, not the total number you have, and use max_cpu_loras to keep the rest close at hand.

For max_lora_rank, the vLLM example recommends setting it as low as possible if all your adapters share the same rank. If you trained adapters at rank 8, setting 64 only wastes memory.

Serve Multiple LoRA Adapters With the vLLM Server

For most applications you will run vLLM’s OpenAI-compatible server instead of the Python API. Register adapters at startup with --lora-modules, and pass the same capacity settings as flags:

vllm serve meta-llama/Llama-3.2-3B-Instruct \
    --enable-lora \
    --lora-modules sql-lora=jeeejeee/llama32-3b-text2sql-spider \
    --max-loras 2 \
    --max-lora-rank 8

Each adapter appears as its own model in /v1/models, next to the base model. To use one, put the adapter’s name in the model field of a normal request:

curl http://localhost:8000/v1/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "sql-lora",
        "prompt": "San Francisco is a",
        "max_tokens": 7,
        "temperature": 0
    }'

Requests for the base model and for adapters are processed together, following the server’s max_loras setting. Because the API is OpenAI-compatible, any client that lets you set a base URL and a model name works without code changes.

The --lora-modules flag also accepts JSON, which lets you record the base model for each adapter so that /v1/models shows it as the adapter’s parent:

--lora-modules '{"name": "sql-lora", "path": "jeeejeee/llama32-3b-text2sql-spider", "base_model_name": "meta-llama/Llama-3.2-3B-Instruct"}'

Load and Unload LoRA Adapters at Runtime

To add adapters without restarting the server, set an environment variable before starting it:

export VLLM_ALLOW_RUNTIME_LORA_UPDATING=True

Then load and unload adapters with two endpoints:

curl -X POST http://localhost:8000/v1/load_lora_adapter \
    -H "Content-Type: application/json" \
    -d '{"lora_name": "sql_adapter", "lora_path": "/path/to/sql-lora-adapter"}'

curl -X POST http://localhost:8000/v1/unload_lora_adapter \
    -H "Content-Type: application/json" \
    -d '{"lora_name": "sql_adapter"}'

Passing "load_inplace": true when loading replaces an existing adapter of the same name with new weights, which the docs describe for setups where adapters are retrained continuously. vLLM also supports resolver plugins that load an adapter automatically the first time a request names it, from a local directory or a Hugging Face repository.

The vLLM documentation is explicit about the risk: runtime updating “should not be used in production unless it is an isolated, fully trusted environment.” Anyone who can reach these endpoints can load weights into your server. Keep them on an internal network, behind authentication, or turn the feature off and register adapters at startup.

Practical Tips Before You Deploy

  • Train adapters on the exact base model you serve. An adapter trained on one model version will not work correctly on another, even with the same architecture name.
  • Standardize the rank. Adapters with the same rank let you set max_lora_rank tightly and keep memory predictable.
  • Measure with your traffic. Throughput depends on how many distinct adapters appear in each batch. Test with a realistic mix before you size the GPU.
  • Pick the base model with adapters in mind. A compact base model with several adapters often costs far less than one large general model. Our comparison of Gemma, Llama and Mistral covers common choices, and our piece on enterprise AI infrastructure explains why serving costs shape these decisions.

Back to the Five Fine-Tunes

The team with five fine-tuned versions of a 3B model no longer needs five deployments. One vLLM server holds the base model once, the five adapters are registered with --lora-modules, max_loras is set to the number they expect in the same batch, and each application calls its own model name. A sixth fine-tune becomes one more adapter directory and one more entry in the startup command.

Frequently Asked Questions

Does vLLM Support LoRA Adapters?

Yes. vLLM supports LoRA adapters for models that implement its SupportsLoRA interface, which includes many popular open model families. Enable it with enable_lora=True in Python or --enable-lora on the server.

How Many LoRA Adapters Can vLLM Serve at Once?

max_loras sets how many different adapters can be active in one batch, and max_cpu_loras sets how many stay cached in CPU memory. You can use more adapters than fit in those slots; vLLM loads adapters into the slots as requests need them, so a request for an adapter that is not loaded may wait for a free slot.

Do I Need to Merge a LoRA Adapter Before Serving It With vLLM?

No. vLLM loads the adapter files directly and applies them at inference time. Merging is only useful if you serve a single adapter and want to remove the per-request LoRA computation entirely.

What Is the Integer ID in LoRARequest?

It is a globally unique number that vLLM uses to identify the adapter in its cache. Give every distinct adapter its own ID, starting at 1, and reuse the same ID whenever you refer to the same adapter.

Disclaimer: The content on this website reflects the views of contributing authors and not necessarily those of Generative AI Lab. This site may contain sponsored content, affiliate links, and material created with generative AI. Thank you for your support.

Generative AI Lab mascot
Generative AI Lab Editorial Team
Articles researched, written and edited by the Generative AI Lab team. About Generative AI Lab

Must read

- Advertisement -spot_img

More articles

- Advertisement -spot_img

Latest articles

Available for Amazon Prime