---
myst:
  html_meta:
    description: "How vLLM Neuron serves several LoRA adapters on one base model: adapter slots, per-token routing, adapter loading, scheduling, and the LoRA kernels."
    keywords: "vLLM, Neuron, multi-LoRA, LoRA, adapters, slots, NKI, design"
    date-modified: "2026-11-18"
---

# Deep dive: Multi-LoRA serving on Neuron

<!-- Content type: conceptual-deep-dive -->

This topic explains how vLLM Neuron serves several LoRA adapters on one base
model. It covers the adapter slots, the configuration path, adapter loading,
the scheduler, the model runner, and the kernels. Some experience with LoRA
and with the vLLM LoRA interface is necessary to understand it in full.

For user configuration, see
[Multi-LoRA serving](../../guides/features-guide.md#multi-lora). For a
step-by-step example, see the
[multi-LoRA tutorial](../../tutorials/tutorial-multi-lora-llama-3-1-8b.md).

## What you should know before reading

- **LoRA:** A LoRA adapter adds `x @ A @ B * scaling` to the output of a
  projection. `A` has the shape `[in, r]` and `B` has the shape `[r, out]`,
  where `r` is the rank.
- **vLLM LoRA interface:** `--enable-lora`, `--max-loras`, `--max-lora-rank`,
  `--lora-modules`, and `LoRARequest`. See the
  [vLLM LoRA documentation](https://docs.vllm.ai/en/stable/features/lora/).
- **Prefill and decode graphs:** vLLM Neuron compiles fixed-shape graphs for
  prefill and decode. See
  [Bucketing and dynamic shapes](../../guides/features-guide.md#bucketing-and-dynamic-shapes).

## Overview

vLLM on GPU wraps each linear layer in a LoRA module. Neuron models use
functional operations and plain `nn.Parameter` weights, not `nn.Linear`
modules. Thus vLLM Neuron uses a different design:

- Each target projection gets LoRA weights for a fixed number of *slots*. The
  shapes are `[max_loras + 1, in, max_lora_rank]` for `A` and
  `[max_loras + 1, max_lora_rank, out]` for `B`.
- Slot 0 always holds zeros. It serves the base model, because it adds no LoRA
  contribution.
- Each step gives the model an `adapter_ids` tensor with one slot index for
  each token. The kernels read the `A` and `B` of that slot for the token.
- The slot weights are inputs of the compiled graphs, not constants. A new
  adapter changes the values in a slot, and the compiled graphs stay the same.

Thus a load or a swap of an adapter does not cause a recompile. One decode
batch can mix base requests and requests for different adapters.

## Configuration path

The configuration path runs once, when the model loads. Model Runner V1 and
Model Runner V2 use the same functions. vLLM Neuron reads only the vLLM LoRA
arguments, as vLLM on GPU does. No LoRA key is in `neuron_config`.

1. vLLM builds its `LoRAConfig` from `--enable-lora`, `--max-loras`,
   `--max-lora-rank`, `--lora-target-modules`, and `--lora-dtype`. The
   `neuron_config` has no LoRA keys. vLLM Neuron ignores `--max-cpu-loras`.
2. `validate_lora_config` rejects a configuration that the LoRA path does not
   support. It collects all problems into one `ValueError`: decode-context
   parallelism, attention or MLP data parallelism, speculative decoding,
   jump-forward decoding, and pooling models.
3. The model factory checks its own limits. The Llama factory rejects a
   quantized model, a model dtype other than bfloat16, and a LoRA dtype other
   than bfloat16.
4. `build_lora_model_config` runs on the built model, before the weight load.
   It calls `check_model_supports_lora`, which requires vLLM's `SupportsLoRA`
   and the Neuron method `get_lora_layout()`. Then it resolves
   `--lora-target-modules` against the LoRA modules of the model, and sets the
   slot count, the rank, and the LoRA dtype.
5. `apply_lora_to_model` adds the zero-filled slot weights to the module of
   each LoRA base weight, after the base checkpoint loads and before the model
   moves to the device.

`get_lora_layout()` lists the base weights whose kernels apply LoRA. For
Llama, these are `qkv_proj_weight`, `o_proj_weight`, `gate_proj_weight`,
`up_proj_weight`, and `down_proj_weight`. The framework derives the rest of the
LoRA plan from the model:

- The weight loader of each base weight gives the tensor-parallel split.
- `packed_modules_mapping` gives the PEFT projection names of a fused weight,
  as on upstream vLLM. For example, `qkv_proj` holds `q_proj`, `k_proj`, and
  `v_proj`. One target projection of a packed weight selects all of its
  projections.

The slot weights are `nn.Parameter(requires_grad=False)` tensors, not buffers.
The compiler folds a buffer value into the graph as a constant, so an adapter
in a buffer would need a recompile. A parameter stays a graph input.

## Tensor-parallel sharding

The adapter loader shards the LoRA weights with the weight loader of the base
weight. Thus the LoRA weights get the same shards and the same padding as the
base weight. At startup, `check_lora_sharding` tests each loader.

| Base weight | Parallel type | `A` | `B` |
|---|---|---|---|
| Column-parallel, for example `qkv_proj`, `gate_proj`, `up_proj` | Column-parallel | Full | Sharded on the output dimension |
| Row-parallel, for example `o_proj`, `down_proj` | Row-parallel | Sharded on the input dimension | Full |

The column-parallel output needs no reduction across ranks. The row-parallel
output uses the same all-reduce as the base projection. With grouped-query
attention, several ranks can share one KV head. These ranks then read the same
rows of the `k_proj` and `v_proj` `B` weights, as the base loader does.

Multi-LoRA does not support MoE expert weights.

## Adapter loading

vLLM Neuron loads an adapter in two cases. `add_lora` loads it at once: the
server calls `add_lora` at startup for each `--lora-modules` adapter, and for
each `/v1/load_lora_adapter` call. A step loads each adapter of its requests
that is not resident. The load does these steps:

1. Resolve `LoRARequest.lora_path` with vLLM's `get_adapter_absolute_path`,
   as the vLLM `WorkerLoRAManager` does. A local directory is used as it is.
   Another relative path is a Hugging Face Hub repo ID, and vLLM downloads it
   to the local cache. The directory must hold `adapter_config.json`.
2. Read `adapter_config.json`. Reject DoRA, `rank_pattern`, `alpha_pattern`,
   `modules_to_save`, a LoRA bias, and an adapter without a rank. Reject a rank
   larger than `--max-lora-rank`.
3. Compute the scaling: `lora_alpha / r` for LoRA, or `lora_alpha / sqrt(r)`
   for rsLoRA. The loader multiplies `B` by the scaling, so the kernels do not
   apply it.
4. Read the weights from `adapter_model.safetensors`, or from
   `adapter_model.bin` if no `.safetensors` file exists. The loader
   memory-maps a `.safetensors` file and slices the shard of each
   tensor-parallel worker before it reads the data.
5. Zero-pad the rank dimension to `--max-lora-rank`. The kernel always reads the
   full rank width. The device copy of a slot changes only where the host
   write covers it, so a partial write would leave old values in the padding.
6. Write each slot tensor whole from a host block. Set each slot tensor that
   the adapter does not cover to zeros.
7. Skip the adapter weights of a projection that is not a target, with a
   warning. Reject an adapter that has weights only outside the targets.
   Ignore full `embed_tokens` and `lm_head` weights, with a warning.

All tensor-parallel workers on a host load the same adapter at the same time.
Two measures keep this load fast:

- **Host staging:** The first worker copies the `.safetensors` file into a
  host-memory (tmpfs) directory under a file lock. The other workers wait on
  the lock and use the copy, so the network file is read once for each host.
  The cache key includes the path, the size, and the modification time. The
  cache removes the least recently used copies when it has more files or more
  bytes than its limits.
- **One CPU thread for each worker:** Each worker does its host tensor work on
  one CPU thread. Many workers with many threads each would use more threads
  than the host has cores.

The load is synchronous, inside the model execution of the step.

## Slot manager

`NeuronLoRAManager` has the same external contract as the vLLM
`WorkerLoRAManager`: add, remove, list, and set the active adapters.

- The manager keys each adapter by its `lora_int_id`. A `lora_int_id` belongs
  to its adapter name until the adapter is removed, also after an eviction. A
  request that uses the ID under another name raises an error, because the
  slot would serve the wrong weights.
- The manager resolves the path before it takes a slot, so a bad path evicts
  nothing.
- Before a step, the manager makes all adapters of the step resident. It marks
  the adapters of the step and the adapters of all live requests as most
  recently used, so a new load cannot evict them.
- When no slot is free, the manager evicts the least recently used adapter.
  Before it overwrites the slot, it waits for the device to finish the queued
  steps. A step in flight can still read the old slot, for example with
  asynchronous scheduling.
- If a load fails, the manager sets the slot to zeros and frees it. A free slot
  always holds zeros.
- `add_lora` with `load_inplace=True` loads a resident adapter again from its
  `lora_path` into its slot. A generate request does not load a resident
  adapter again.

All slots are in HBM. The manager has no CPU LoRA cache, so `--max-cpu-loras`
has no effect. A reload of an evicted adapter reads the adapter file again. The
manager does not support pinned adapters.

## Scheduler

The vLLM scheduler limits the number of different adapters to `max_loras`
among the requests that it can see. A Neuron prefill step holds one request
and does not show the running decodes to the vLLM scheduler. Without more
control, a new prefill could add one more adapter than the slots can hold. The
next decode step would then fail.

The Neuron scheduler checks each waiting request against the adapters of all
running requests. If the request needs a new adapter and `max_loras` adapters
are in use, the request waits. The scheduler continues with the requests
behind it, so one blocked request does not stop the queue. The blocked request
goes back to the front of the queue for the next step.

## Model runner

The model runner builds the `adapter_ids` tensor for each step:

- **Prefill:** The step holds one request. Every token, padding included, gets
  the slot of that request. A prefill step with more than one request raises
  an error.
- **Decode:** Each row gets the slot of its request. A base request and a
  padding row get slot 0.
- **Warmup:** A synthetic warmup input has no requests. It gets slots 0 and 1
  in turn, so the trace sees the same shape and dtype as a real step.

Model Runner V2 also gives a data-parallel dummy step slot 0.

## Kernel path

The NKI Library kernels apply the LoRA weights. The base projection and the
LoRA contribution run in the same kernel call.

- **Decode attention:** The fused decode attention block applies the QKV LoRA
  and the `o_proj` LoRA. It reads the slot of each token from `adapter_ids`.
  With an FP8 KV cache, vLLM Neuron divides the `o_proj` LoRA `A` by the
  V scale, the same as the base `o_proj` weight.
- **Decode MLP:** At or below 96 tokens, the MLP decode kernel applies the
  gate, up, and down LoRA for each token. Above 96 tokens, the MLP prefill
  kernel runs the step. This kernel also routes the LoRA for each token.
- **Prefill:** The QKV projection kernel applies the QKV LoRA. The MLP prefill
  kernel gets `lora_shared_adapter=True`, because all tokens use one adapter.
  The `o_proj` LoRA runs in PyTorch: it selects the `A` and `B` of the slot
  once and does two dense matrix multiplications.

Above 128 tokens, the decode attention block computes the LoRA in blocks of
128 tokens. Thus multi-LoRA sets no limit on the number of sequences in one
step.

## Limits and future work

The current limits are in
[Multi-LoRA](../../guides/features-guide.md#multi-lora). Areas for future work
include:

- LoRA on MoE expert weights and on quantized base weights.
- Speculative decoding with LoRA.
- Faster prefill for large hidden sizes at LNC 1.

## Related concepts

- [Neuron scheduler](neuron-scheduler.md) — the holdback queue and admission
  control.
- [Async scheduling and execution](async-scheduling-and-async-execution.md) —
  why a step can be in flight when a slot changes.
- [KV cache quantization](kv-cache-quantization.md) — the FP8 KV scales.
