LoRA-Drop¶
At a glance
LoRA-Drop: droppable layers run in full every few tokens, and in between reuse their last output plus a LoRA correction.
| Registered name | Family | Saves | Lossless | Trainable | Configuration |
|---|---|---|---|---|---|
loradrop |
dynamic-depth | compute or latency | no | updates | LoRADropConfig |
Backends (default configuration): transformers: real · gguf: no · mlx: no · onnx: no · sglang: no · trtllm: no · vllm: no
LoRA-Drop (Rajabzadeh et al., 2026) runs a set of droppable layers in full only every period generated tokens.
Decoding goes in cycles of period tokens, and the first token of a cycle, the anchor, runs every layer. At a
droppable layer l, every other token of the cycle skips the layer and leaves it as
h_l(anchor) + B A x * alpha / rank: the anchor's output of layer l plus a low-rank map of the token's own layer
input x. The droppable layers default to the paper's choice, every layer except the first three and the last. The
prompt runs every layer. The saving is the droppable layers of every non-anchor token, about
(period - 1) / period of them.
LoRA-Drop is lossy: a dropped token reuses an earlier token's state, so its output can differ from the base model's. Training fits the low-rank maps to imitate the layers they replace, with the base model frozen. One deviation from the paper: dropped tokens still write K/V at the layers they skip, while the paper writes none there.
Setup¶
Every tutorial starts from the same model and prompt:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import economize
device = "cuda" if torch.cuda.is_available() else "cpu"
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B", dtype=torch.bfloat16, device_map=device)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B")
ids = tokenizer("Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. "
"How many clips did Natalia sell altogether?", return_tensors="pt").input_ids.to(device)
Training data is a flat file of uint32 token ids, the format of nanoGPT-style pretraining shards, and calibration
data is a [N, S] tensor of token ids. Both are made here from GSM8K:
import numpy as np
from datasets import load_dataset
texts = [f"{row['question']}\n{row['answer']}" for row in load_dataset("openai/gsm8k", "main", split="train")]
tokens = np.concatenate([tokenizer(t + tokenizer.eos_token).input_ids for t in texts]).astype(np.uint32)
tokens[: len(tokens) * 9 // 10].tofile("train.bin")
tokens[len(tokens) * 9 // 10 :].tofile("val.bin")
calibration = torch.from_numpy(tokens[: 128 * 2048].astype(np.int64)).view(128, 2048)
Quick start¶
The base model's greedy output is the reference for quality, so generate it before the technique is applied:
reference = base.generate(ids, max_new_tokens=64, do_sample=False)[0, ids.shape[1]:]
B starts at zero, so before training a dropped token takes the anchor's layer output unchanged. That already saves
compute, and training then reduces the error it makes:
from economize.techniques.dynamic_depth import LoRADropConfig, token_mismatch
model = economize.apply(base, LoRADropConfig(period=2, rank=16))
result = model.decode(ids[0], 64)
print(tokenizer.decode(result.tokens))
summary = model.techniques["loradrop"].cost_summary(result)
print(token_mismatch(result.tokens, reference)) # fraction of positions that differ from the base model
print(summary["relative_effective_layer_tokens"]) # layer applications relative to plain decoding
print(summary["phases"]["decode"]) # layer-token counts of the decoding steps alone
Measuring quality and saving¶
token_mismatch is CALM's token-level consistency loss: the fraction of the positions of the longer generation at
which the two generations differ, with a missing token counted as a difference. Greedy decoding compounds every early
difference, so it is worth averaging it over prompts from the target workload. relative_effective_layer_tokens
divides the layer applications that ran by those of plain decoding of the same output, prompt included, and
kv_fill_layer_tokens counts the dropped layers that still computed K/V.
Training¶
fit without an objective uses LoRADropObjective(): the language-model loss of the model with the dropped
positions of every droppable layer taking the low-rank update. kl_weight adds a KL divergence to the base model's
distribution, and ce_weight scales the language-model loss:
from economize.techniques.dynamic_depth import LoRADropObjective
from economize.train import fit
fit(model, "train.bin", objective=LoRADropObjective(kl_weight=1.0), steps=2000, batch_size=8, seq_len=1024, seed=0)
result = model.decode(ids[0], 64)
print(token_mismatch(result.tokens, reference))
Choosing the layers¶
The paper picks the droppable layers by how little they change their input. redundant_layers ranks the layers by
the mean cosine similarity of their input and output on calibration data and returns the count most similar ones.
It reads the model through its architecture adapter, and exclude_first keeps the first layers out:
from economize.arch import adapter_for
from economize.techniques.dynamic_depth import redundant_layers
layers = redundant_layers(adapter_for(base), calibration[:8, :512].cuda().split(2), 12, exclude_first=3)
print(layers)
model.detach()
model = economize.apply(base, LoRADropConfig(layers=layers, period=3, rank=32, alpha=32.0))
fit(model, "train.bin", steps=2000, batch_size=8, seq_len=1024, seed=0)
period=3 runs the droppable layers in full for every third token, and period=1 leaves the model unchanged.
rank and alpha set the size and the scale alpha / rank of the low-rank maps. skip_prompt=True drops layers
in the prompt as well.
Saving and loading¶
save_pretrained writes the configuration and the low-rank maps:
model.save_pretrained("loradrop_model")
model.detach()
model = economize.load(base, "loradrop_model")
Combining with other techniques¶
Only one dynamic-depth technique is used per model. LoRA-Drop composes with drafters and with KV-cache techniques. Anchors are kept per row with their positions, so a verification pass over several drafted tokens uses the same anchors as one-token decoding, and greedy verification reproduces the output of LoRA-Drop alone. Here the drafter is an untrained EAGLE-3 head (train it as in EAGLE-3 before use) and the cache is quantized to 4 bits:
from economize.techniques.eagle3 import Eagle3Config
from economize.techniques.kv_quant.kivi import KIVIConfig
model.detach()
model = economize.apply(base, LoRADropConfig(), KIVIConfig(bits=4), Eagle3Config(),
decoding=economize.DecodeConfig(cycle_length=6))
combined = model.decode(ids[0], 64)
Serving¶
LoRA-Drop runs on the Hugging Face path only, and a model with it decodes without CUDA graphs:
print(economize.backend_support(LoRADropConfig()))
Configuration¶
LoRADropConfig
dataclass
¶
LoRADropConfig(layers: tuple[int, ...] = (), skip_prompt: bool = False, period: int = 2, rank: int = 16, alpha: float = 16.0)
LoRA-Drop.
Attributes:
| Name | Type | Description |
|---|---|---|
layers |
tuple[int, ...]
|
Droppable layers (empty: all but the first three and the last, as in the paper;
:func: |
period |
int
|
A droppable layer runs in full for every |
rank |
int
|
Rank of the low-rank update. |
alpha |
float
|
Scale |
skip_prompt |
bool
|
Drop layers in the prompt too ( |
droppable_layers
¶
droppable_layers(num_layers: int) -> tuple[int, ...]
The droppable layers (:meth:layer_set).
References¶
- Rajabzadeh, H., Dialameh, M., Park, C. B., Kim, I.-M., & Kwon, H. J. (2026). LoRA-Drop: Temporal LoRA decoding for efficient LLM inference (arXiv:2601.02569). arXiv. https://doi.org/10.48550/arXiv.2601.02569