peft
40 memberslucid.peftlucid.peft — parameter-efficient fine-tuning: LoRA and 44 other adapter methods, with one API.
Fine-tuning a pretrained model end to end updates, stores and ships every
weight. LoRA (Hu et al., 2021) freezes them and learns, beside each
chosen nn.Linear, a rank- update — on GPT-2
small's c_attn at , 294,912 parameters, 0.24 % of the
model — so a fine-tune is trained, saved and swapped as a few megabytes.
The API and the adapter file format are the reference adapter library's, names and defaults included, so a script written for it reads the same and an adapter directory moves between the two:
from lucid.peft import LoraConfig, PeftConfig, PeftModel, get_peft_model
config = LoraConfig(r=8, lora_alpha=16, target_modules=["c_attn"],
task_type="CAUSAL_LM")
model = get_peft_model(base_model, config) # base_model changed in place
model.print_trainable_parameters()
... # train: only the adapter learns
model.save_pretrained("my-adapter") # adapter_config.json + adapter_model.safetensors
PeftConfig.from_pretrained("my-adapter").base_model_name_or_path # which base it needs
model = PeftModel.from_pretrained(fresh_base_model, "my-adapter")
merged = model.merge_and_unload() # a plain model again, adapter folded in
Each method is a config class, a tuner and its layer classes, registered
by PeftType as they are defined (lucid.peft.tuners._base); the
entry points above dispatch on the method a config or a file names. The
layer classes of each are in lucid.peft.tuners.<method>. The methods,
by family:
-
LoRA family — a low-rank update beside each frozen weight. LoRA (
LoraConfig/LoraModel) and AdaLoRA, which allocates the rank per layer during training (AdaLoraConfig/AdaLoraModel). -
Orthogonal family — a rotation of each layer's input space instead of an addition to its weight. OFT (block-diagonal Cayley rotations,
OFTConfig/OFTModel), BOFT (their butterfly factorisation plus a row scale,BOFTConfig/BOFTModel) and HRA (a chain of Householder reflections,HRAConfig/HRAModel). -
LyCORIS family — a weight-shaped update from a structured factorisation. LoHa (a Hadamard product of low-rank products,
LoHaConfig/LoHaModel) and LoKr (a Kronecker product,LoKrConfig/LoKrModel). -
Shared-table tuners — one set of tensors for the whole model, held once by the tuner, and a few parameters per layer. VeRA (two vectors per layer over frozen random projections,
VeraConfig/VeraModel), RandLoRA (a full-rank update from frozen random bases and learned scales,RandLoraConfig/RandLoraModel) and VB-LoRA (every low-rank factor mixed from one vector bank,VBLoRAConfig/VBLoRAModel). -
Structured and sparse updates — a weight update with a fixed structure other than low rank. FourierFT (a few frequency-domain coefficients,
FourierFTConfig/FourierFTModel), C3A (block-circulant blocks,C3AConfig/C3AModel), MiSS (one matrix shared across the shards of a weight,MissConfig/MissModel), Bone (the method MiSS replaced, kept to read old adapter files,BoneConfig/BoneModel) and SHiRA (a sparse subset of the weight itself,ShiraConfig/ShiraModel). -
Scaling and selective tuning — a small part of the model itself. (IA)^3 (a learned rescaling vector per layer,
IA3Config/IA3Model), LN tuning (a trainable copy of each chosen normalisation layer,LNTuningConfig/LNTuningModel) and trainable tokens (a few rows of an embedding table,TrainableTokensConfig/TrainableTokensModel). -
Routing and mixing — several low-rank adapters combined per task or per token. Poly and Multi-Head Routing (every layer holds
n_skillslow-rank skills and a router with a logit vector per task,PolyConfig/PolyModel; the call names its tasks withtask_ids) and X-LoRA (trained LoRA adapters loaded by name and weighed per token by a classifier on the final hidden states,XLoraConfig/XLoraModel; only the classifier is saved). -
Adaption prompts — LLaMA-Adapter: the top attention layers of a
gpt/gpt2decoder attend to learned prompts through a gate that starts at zero (AdaptionPromptConfig/AdaptionPromptModel).
Everything below about adapters, switching, merging and files holds for all of them (LN tuning applies, and merges, one adapter at a time; adaption prompts apply one at a time; adaption prompts, Poly and X-LoRA cannot be merged into the weights).
Prompt learning is the last family. It learns an input rather than a weight and adds no
layer to the model: prompt tuning (PromptTuningConfig: virtual-token embeddings in front of
the input), prefix tuning (PrefixTuningConfig: virtual keys and values in front of every
attention layer) and p-tuning (PromptEncoderConfig: the virtual tokens produced by an MLP or
LSTM). The prompt is applied by hooks on the model's own call, so model(...) and the model's
generate both carry it; the adapter file holds the finished prompt as
prompt_embeddings. They train one prompt at a time, have nothing to merge, and
support the causal-LM, sequence-to-sequence, sequence-classification, token-classification
and question-answering tasks (the last two get logits as long as the input, the prompt's rows
cut off at the head). Multitask prompt tuning (MultitaskPromptTuningConfig) learns a shared
prompt and a low-rank factor pair per task, chosen per batch row by task_ids; context-aware
prompt tuning (CPTConfig) tunes a prompt of in-context examples with a bounded offset and
a loss over the examples' outputs:
config = PromptTuningConfig(num_virtual_tokens=20, task_type="CAUSAL_LM")
model = get_peft_model(base_model, config)
The methods the reference library has added since have an adapter too: DeLoRA, GraLoRA, HiRA, GLoRA,
DEFT and PEANuT (DeloraConfig …), Uni-LoRA, PVeRA, TinyLoRA and Lily, RoAd, PSOFT, OSF and FRoD,
Super-Tuning, WaveFT, BEFT and Cartridge (CartridgeConfig, CartridgeEncoder and the four
initialize_kv_prefix_* / compose_cartridge_adapters utilities) and AdaMSS (AdamssConfig,
AdamssModel). ShadowPEFT is refused for good — it needs the base model's decoder loop and a
second backbone beside it. The option classes of LoRA's extensions (ArrowConfig, BdLoraConfig,
KasaConfig, MontecloraConfig, VeloraConfig) are here too, for the LoraConfig fields
that hold them. Of those extensions Arrow is implemented (LoraConfig(arrow_config=...) makes an
adapter a router over the others, and create_arrow_model builds one from saved adapters); a
LoraConfig that sets one of the rest is refused.
What a LoRA layer guarantees:
- The base is untouched until merged. The wrapped
nn.Linearis kept asbase_layerwith its ownParameterobjects — not copies — so an optimizer built earlier, a tied embedding and Core ML's identity-keyed weight sharing all still see them, and with the default initialisation () the adapted model's output is the base model's, bit for bit. - Only the adapter trains. Every other parameter is frozen; the
biasoption andmodules_to_saveadd biases and whole modules. - A half-precision base gets a float32 adapter, computed in float32 and cast back to the base's output dtype.
- Merging refuses a shared weight. Folding the update into a weight
another module also uses (a tied LM head) would change that module;
merge_and_unloadraises instead.
A model holds any number of adapters, each under its own name:
model.add_adapter("style", LoraConfig(r=4, target_modules=["c_attn"]))
model.set_adapter("style") # compute with — and train — this one
model.add_weighted_adapter(["default", "style"], [0.7, 0.3], "mix")
model.save_pretrained("adapters") # "default" in adapters/, "style" in adapters/style/
model.load_adapter("adapters/style", "style-again")
The model class follows the task: get_peft_model returns a
PeftModelForCausalLM for task_type="CAUSAL_LM" (and the matching
PeftModelFor... class for the other tasks, which also train a
classification or question-answering head), and a config with no
target_modules takes the default for the base model's model_type.
An adapter directory that names its base model reopens in one call:
model = AutoPeftModelForCausalLM.from_pretrained("my-adapter")
LoRA layers exist for nn.Linear, nn.Embedding, nn.Conv1d /
Conv2d / Conv3d, their nn.ConvTranspose counterparts and
nn.MultiheadAttention (found by the module's
type in target_modules), and target_parameters adapts a raw
nn.Parameter of a module (lucid.peft.tuners.lora). Asking for
more — add_weighted_adapter over anything but nn.Linear layers, an
adapter file of a method this package lacks — raises NotImplementedError
rather than doing less than asked. Adapters are read from a local directory;
hub ids are not resolved.
modules_to_save trains whole modules (a classification head) beside the adapter; each
becomes a ModulesToSaveWrapper that keeps the original and a trained copy per adapter. An
adapter written by the reference library for a model of the zoo is converted to the zoo's
module layout as it is loaded (PeftModel.from_pretrained(..., convert=)). The reference
library and the zoo name some modules differently and lay a few out differently, so a
converter exists for each of these zoo model types (model.config.model_type):
"gpt2"— the sequence-classification headscorebecomesclassifier; no other name or tensor changes."roformer"— the layouts agree, so a file converts by identity."t5"— the reference'sblock.N.layer.M.<Module>nesting becomes the zoo's roles (blocks.N.self_attention,cross_attention,feed_forward,<sub-layer>_norm), and the text-to-text model's modules gain thet5.trunk prefix."vit"— the separatequery/key/valueadapters are fused into the zoo's oneqkv(exactly for LoRA; another method on those projections raisesNotImplementedError), and the remaining modules are renamed.
convert="auto" (the default) converts when the model's type has a converter and the file is
in a layout it changes, and reads any other file as it is, such as one saved by
save_pretrained. True always converts and raises ValueError for a model type with
no converter, or for a tensor the converter has no rule for. False reads the file as it
is. A model without a config.model_type is matched by the reference class that the
adapter's auto_mapping records.
A model can hold several adapters, switch between them, combine them
(add_weighted_adapter: svd, cat, linear and the TIES / DARE /
magnitude-prune types), and compute a batch whose rows each use a different
adapter (model(x, adapter_names=[...])). get_layer_status and
get_model_status report what each adapter layer, and the model, is doing.
Adapting a model a second time adds the new adapter beside the first, with a
warning.
A PeftModel holds the adapters of one method. get_peft_model(model, config, mixed=True)
(or PeftMixedModel itself) holds those of several at once, each module's layers stacked on
one another's — LoRA with a LoHa layer on it, an (IA)^3 scale above that:
model = get_peft_model(base_model, LoraConfig(r=8, target_modules=["c_attn"]), mixed=True)
model.add_adapter("loha", LoHaConfig(r=4, target_modules=["c_attn"]))
model.set_adapter(["default", "loha"]) # both in use, lowest layer first
PeftMixedModel.from_pretrained(fresh_base_model, "my-adapter") # a single-method file
The methods it can hold are the keys of PEFT_TYPE_TO_MIXED_MODEL_MAPPING (LoRA, LoHa,
LoKr, AdaLoRA for inference, SHiRA, OFT, (IA)^3, BEFT, RoAd, HiRA); any other is refused where it
is added. Adapters are read from the files single-method models write, before or after other
methods are stacked on their modules; a mixed model itself is not saved (the reference's is not
either), and it has no layer status.
The helpers a script moved from the reference library reaches for are here under its
names: PeftError / NoMatchingPeftModuleError / PeftWarning, the method tables
PEFT_TYPE_TO_CONFIG_MAPPING, PEFT_TYPE_TO_TUNER_MAPPING and
PEFT_TYPE_TO_MIXED_MODEL_MAPPING (read-only views),
get_peft_config, load_peft_weights, get_base_model_state_dict /
set_base_model_state_dict, cast_mixed_precision_params, shift_tokens_right,
prepare_model_for_kbit_training (freezes and upcasts; a quantized model is refused),
find_kappa_target_modules and the bloom prefix-tuning reshaper.
Guides
Core
The adapter configs, PeftModel and its task classes, and the AutoPeftModel loaders that reopen a saved adapter with its base model.
PeftConfig9 methodsWhat every adapter config holds, and the adapter_config.json round trip.
PeftTypeThe parameter-efficient method an adapter file holds.
PromptLearningConfigThe fields of a method that learns an input rather than a weight.
TaskTypeThe task an adapter was trained for, as adapter_config.json records it.
PeftModel30 methodsA model with adapters, saved and loaded as the adapters alone.
PeftModelForCausalLM29 methodsAn adapted causal language model: the PeftModel for task_type="CAUSAL_LM".
PeftModelForFeatureExtraction29 methodsAn adapted feature encoder: the PeftModel for task_type="FEATURE_EXTRACTION".
PeftModelForQuestionAnswering29 methodsAn adapted question-answering model: the PeftModel for task_type="QUESTION_ANS".
PeftModelForSeq2SeqLM29 methodsAn adapted encoder-decoder model: the PeftModel for task_type="SEQ_2_SEQ_LM".
PeftModelForSequenceClassification29 methodsAn adapted sequence classifier: the PeftModel for task_type="SEQ_CLS".
PeftModelForTokenClassification30 methodsAn adapted token classifier: the PeftModel for task_type="TOKEN_CLS".
AutoPeftModel1 methodsLoad an adapter that has no task, with its base model.
AutoPeftModelForCausalLM1 methodsLoad a causal language model's adapter with its base model.
AutoPeftModelForFeatureExtraction1 methodsLoad a feature encoder's adapter with its base model.
AutoPeftModelForQuestionAnswering1 methodsLoad a question-answering model's adapter with its base model.
AutoPeftModelForSeq2SeqLM1 methodsLoad an encoder-decoder model's adapter with its base model.
AutoPeftModelForSequenceClassification1 methodsLoad a sequence classifier's adapter with its base model.
AutoPeftModelForTokenClassification1 methodsLoad a token classifier's adapter with its base model.
Mixed adapters
PeftMixedModel, which get_peft_model(model, config, mixed=True) returns, holds the adapters of several methods on one model; it is not a PeftModel. The methods are the keys of PEFT_TYPE_TO_MIXED_MODEL_MAPPING (under Attributes): LoRA, LoHa, LoKr, AdaLoRA, SHiRA, OFT, IA3, BEFT, RoAd and HiRA. That is the set this library verifies; the reference's own table lists nine, without OFT, and its constructor refuses four of them. A method has one layer on each module it adapts, and the layers stand on one another in the order the methods were added, lowest first; a second adapter of a method goes into that method's layer. HiRA reads the weight beneath it, so it can only be the lowest layer, and AdaLoRA takes part for inference only (its rank allocator and orthogonality loss are not run). A mixed model loads the plain single-method adapter files a PeftModel writes, also after another method is stacked on the module, and it does not save: save_pretrained raises NotImplementedError, as the reference's does. merge_and_unload folds each module's layers lowest first and drops the adapters it does not fold in, and a merge that would fold an update under a layer that transforms it is refused before any weight is written.
LoRA family
A low-rank update learned beside each frozen weight, the variant that moves rank between layers while it trains, and the methods that bound it (DeLoRA), grid it (GraLoRA), correct the bias too (GLoRA), modulate the weight with it (HiRA), project a subspace out (DEFT), generate it from the weight (PEANuT) or cluster the SVD into subspaces (AdaMSS).
LoRA
30 memberslucid.peft.tuners.loraHu, Edward J., et al. "LoRA: Low-Rank Adaptation of Large Language Models." [arXiv:2106.09685](https://arxiv.org/abs/2106.09685), 2021.
EVA (Paischer et al., 2024, arXiv:2410.07170) runs an incremental SVD over calibration activations to redistribute the LoRA rank budget across layers according to their explained variance ratios and initialise from the top right-singular vectors.
AdaLoRA
6 memberslucid.peft.tuners.adaloraZhang, Qingru, et al. "Adaptive Budget Allocation for Parameter-Efficient Fine-Tuning." [arXiv:2303.10512](https://arxiv.org/abs/2303.10512), 2023.
AdaLoRA (Zhang et al., 2023, arXiv:2303.10512) writes the update of a
targeted nn.Linear (or nn.Conv2d) as a truncated SVD,
DeLoRA
4 memberslucid.peft.tuners.deloraBini, Massimo, et al. "DeLoRA: Decoupling Angles and Strength in Low-rank Adaptation." [arXiv:2503.18225](https://arxiv.org/abs/2503.18225), 2025.
DeLoRA (Bini et al., 2025, arXiv:2503.18225 — Decoupled Low-rank Adaptation) normalises each rank-one component of the LoRA update and scales the sum by a learned boundary ,
GraLoRA
4 memberslucid.peft.tuners.graloraJung, Yeonjoon, et al. "GraLoRA: Granular Low-Rank Adaptation for Parameter-Efficient Fine-Tuning." [arXiv:2505.20355](https://arxiv.org/abs/2505.20355), 2025.
GraLoRA (Jung et al., 2025, arXiv:2505.20355 — Granular Low-Rank Adaptation) cuts a weight into a
gralora_k by gralora_k grid of sub-blocks and gives every block its own low-rank pair of rank
r / gralora_k, with information exchanged between the blocks. The parameter count is that of a
rank-r LoRA, while the update can reach about gralora_k times its effective rank. With
hybrid_r > 0 a plain LoRA of that rank is added (Hybrid GraLoRA); the update is scaled by
.
HiRA
8 memberslucid.peft.tuners.hiraHuang, Qiushi, et al. "HiRA: Parameter-Efficient Hadamard High-Rank Adaptation for Large Language Models." ICLR, 2025.
HiRA (Huang et al., 2025, ICLR — Hadamard High-Rank Adaptation) multiplies the frozen weight elementwise by a low-rank matrix,
GLoRA
4 memberslucid.peft.tuners.gloraChavan, Arnav, et al. "One-for-All: Generalized LoRA for Parameter-Efficient Fine-tuning." [arXiv:2306.07967](https://arxiv.org/abs/2306.07967), 2023.
GLoRA (Chavan et al., 2023, arXiv:2306.07967 — Generalized LoRA) corrects the weight and the bias of a layer with learned terms,
DEFT
4 memberslucid.peft.tuners.deftKumar, Komal, et al. "DEFT: Decompositional Efficient Fine-Tuning for Text-to-Image Models." [arXiv:2509.22793](https://arxiv.org/abs/2509.22793), 2025.
DEFT (Kumar et al., 2025, arXiv:2509.22793 — Decompositional Efficient Fine-Tuning) injects knowledge through a residual projection. For a frozen weight it learns a direction matrix and an injection matrix and uses
PEANuT
4 memberslucid.peft.tuners.peanutZhong, Yibo, et al. "PEANuT: Parameter-Efficient Adaptation with Weight-aware Neural Tweakers." [arXiv:2410.01870](https://arxiv.org/abs/2410.01870), 2024.
PEANuT (Zhong et al., 2024, arXiv:2410.01870, section 3.3; later versions of the paper call it
Neat) writes the update as a function of the frozen weight, , where
is a small trained network, not a fixed low-rank product. At depth zero
with and
(transposed back to the shape of ); each
unit of depth puts an encoder layer before and a decoder layer after the
middle, joined by residuals (appendix F), with the non-linearity act_fn between all of
them. is zero when training begins, which makes the first update zero too.
AdaMSS
5 memberslucid.peft.tuners.adamssZheng, Jingjing, et al. "AdaMSS: Adaptive Multi-Subspace Approach for Parameter-Efficient Fine-Tuning." NeurIPS, 2025.
AdaMSS (Zheng et al., 2025, NeurIPS — Adaptive Multi-Subspace Approach for Parameter-Efficient
Fine-Tuning) takes the SVD of each weight (joined to its bias as one more column), clusters the rows of its
top-r left singular directions into num_subspaces subspaces, and learns an independent
rank-subspace_rank update inside each one while the weight stays frozen. With use_asa, an adaptive
allocation freezes the less important subspaces during training, down to about asa_target_subspaces
trainable ones in all.
Orthogonal family
A rotation of each layer's input space instead of an addition to its weight: block-diagonal Cayley rotations (OFT), their butterfly factorisation (BOFT) and a chain of Householder reflections (HRA); and, newer, rotations of output pairs (RoAd), of the principal subspace (PSOFT), a constrained fine-tune of the low singular directions (OSF) and a sparse rotation over a shared basis (FRoD).
OFT
5 memberslucid.peft.tuners.oftQiu, Zeju, et al. "Controlling Text-to-Image Diffusion by Orthogonal Finetuning." [arXiv:2306.07280](https://arxiv.org/abs/2306.07280), 2023.
OFT (Qiu et al., 2023, arXiv:2306.07280 — Orthogonal Finetuning) rotates the input space of each targeted layer instead of adding to its weight: with block-diagonal, each block an orthogonal matrix of a learned skew-symmetric . A rotation keeps the pairwise angles between the weight's neurons, which is what OFT tunes while the weight's spectrum stays. The s start at zero, so the adapted model starts as the base; the rotation folds into the weight, so a merged model costs what the base does.
BOFT
5 memberslucid.peft.tuners.boftLiu, Weiyang, et al. "Parameter-Efficient Orthogonal Finetuning via Butterfly Factorization." [arXiv:2311.06243](https://arxiv.org/abs/2311.06243), 2023.
BOFT (Liu et al., 2023, arXiv:2311.06243 — Butterfly Orthogonal Finetuning) factors the orthogonal matrix OFT builds block-diagonally into a product of sparse orthogonal factors in butterfly order, so a small number of parameters spans a dense rotation of the input space:
HRA
5 memberslucid.peft.tuners.hraYuan, Shen, et al. "Bridging the Gap between Low-rank and Orthogonal Adaptation via Householder Reflection Adaptation." [arXiv:2405.17484](https://arxiv.org/abs/2405.17484), 2024.
HRA (Yuan et al., 2024, arXiv:2405.17484 — Householder Reflection Adaptation) multiplies each targeted weight from the right by a chain of Householder reflections,
RoAd
4 memberslucid.peft.tuners.roadLiao, Baohao, et al. "3-in-1: 2D Rotary Adaptation for Efficient Finetuning, Efficient Batching and Composability." [arXiv:2409.00119](https://arxiv.org/abs/2409.00119), 2024.
RoAd (Liao and Monz, 2024, arXiv:2409.00119 — 2D Rotary Adaptation) pairs the output features of a layer into 2-D vectors and rotates and scales each pair (section 3.2, Eq. 3),
PSOFT
5 memberslucid.peft.tuners.psoftWu, Fei, et al. "Efficient Orthogonal Fine-Tuning with Principal Subspace Adaptation." [arXiv:2505.11235](https://arxiv.org/abs/2505.11235), 2025.
PSOFT (Wu et al., 2025, arXiv:2505.11235 — Efficient Orthogonal Fine-Tuning with Principal Subspace
Adaptation, section 4) rotates a weight inside its principal subspace only. An SVD of the weight gives its top-r
directions as frozen factors and , and only an matrix between them
is trained:
OSF
4 memberslucid.peft.tuners.osfNayak, Nikhil Shivakumar, et al. "Sculpting Subspaces: Constrained Full Fine-Tuning in LLMs for Continual Learning." [arXiv:2504.07097](https://arxiv.org/abs/2504.07097), 2025.
OSF (Orthogonal Subspace Fine-tuning; Nayak et al., 2025, arXiv:2504.07097 — Sculpting Subspaces, section 3)
is constrained full fine-tuning for continual learning. It takes the SVD of each weight, freezes the top
effective_rank singular directions, which carry what the model already knows, and trains the rest, with
gradients projected orthogonally to the frozen directions so that a new task does not overwrite an old one.
The trainable rank is min(weight.shape) - effective_rank; no parameter is added to the model.
FRoD
4 memberslucid.peft.tuners.frodWan, Guoan, et al. "FRoD: Full-Rank Efficient Fine-Tuning with Rotational Degrees for Fast Convergence." [arXiv:2512.23485](https://arxiv.org/abs/2512.23485), 2025.
FRoD (Wan et al., 2025, arXiv:2512.23485 — Full-Rank Efficient Fine-Tuning with Rotational Degrees, Eq. 6-8)
reaches a full-rank update with few parameters. A basis shared by the layers of one kind is built from the
base weights, and a sparse trainable rotation matrix, with a fraction sparse_rate of its off-diagonal
entries free, turns that basis into the weight update. The sparsity pattern is drawn from
projection_prng_key.
LyCORIS family
A weight-shaped update built from a structured factorisation: a Hadamard product of low-rank products (LoHa) or a Kronecker product (LoKr).
LoHa
6 memberslucid.peft.tuners.lohaHyeon-Woo, Nam, et al. "FedPara: Low-Rank Hadamard Product for Communication-Efficient Federated Learning." [arXiv:2108.06098](https://arxiv.org/abs/2108.06098), 2021.
LoHa (Hyeon-Woo et al., 2021, arXiv:2108.06098 — the FedPara parameterisation, in the LyCORIS form) learns a weight-shaped update as the Hadamard product of two low-rank products,
LoKr
7 memberslucid.peft.tuners.lokrYeh, Shih-Ying, et al. "Navigating Text-To-Image Customization: From LyCORIS Fine-Tuning to Model Evaluation." [arXiv:2309.14859](https://arxiv.org/abs/2309.14859), 2023.
LoKr (Yeh et al., 2023, arXiv:2309.14859 — LyCORIS) learns a weight-shaped update as a Kronecker product,
Prompt learning
An input learned instead of a weight, with no layer added to the model: virtual tokens in front of the embeddings, virtual keys and values in every attention layer, tokens an encoder produces, or one prompt shared across tasks, or a prompt of in-context examples with a bounded learned offset (CPT). A Cartridge, a trained key-value cache that stands in for a long document, is listed here too, with the utilities that start one from a text and join several.
Prompt Tuning
4 memberslucid.peft.tuners.prompt_tuningLester, Brian, et al. "The Power of Scale for Parameter-Efficient Prompt Tuning." [arXiv:2104.08691](https://arxiv.org/abs/2104.08691), 2021.
Prompt tuning (Lester et al., 2021, arXiv:2104.08691) freezes the model and
learns num_virtual_tokens embedding vectors that are put in front of
the input embeddings: the only trained parameters are
num_virtual_tokens * token_dim numbers, and a task is a file of that size.
An encoder-decoder model gets them in front of the encoder's input.
Prefix Tuning
3 memberslucid.peft.tuners.prefix_tuningLi, Xiang Lisa, and Percy Liang. "Prefix-Tuning: Optimizing Continuous Prompts for Generation." [arXiv:2101.00190](https://arxiv.org/abs/2101.00190), 2021.
Prefix tuning (Li and Liang, 2021, arXiv:2101.00190) learns
num_virtual_tokens key and value vectors for every attention layer
and puts them in front of that layer's own, so the whole network can attend
to them: num_virtual_tokens * 2 * num_layers * token_dim numbers. With
prefix_projection the vectors are produced from a smaller embedding by a
two-layer MLP while training, which the paper found steadier; the file
still stores the finished vectors. An encoder-decoder model gets the prefix
on the decoder's self-attention, so num_layers left out is the decoder's
layer count when the model's config declares one (num_decoder_layers).
P-Tuning
4 memberslucid.peft.tuners.p_tuningLiu, Xiao, et al. "GPT Understands, Too." [arXiv:2103.10385](https://arxiv.org/abs/2103.10385), 2021.
P-tuning (Liu et al., 2021, arXiv:2103.10385) puts num_virtual_tokens
learned embeddings in front of the input like prompt tuning, but produces
them through an encoder — an MLP, or a bidirectional LSTM followed by one —
so the tokens depend on each other. The encoder is only used while
training: the file stores the prompt it produced.
Multitask Prompt Tuning
4 memberslucid.peft.tuners.multitask_prompt_tuningWang, Zhen, et al. "Multitask Prompt Tuning Enables Parameter-Efficient Transfer Learning." [arXiv:2303.02861](https://arxiv.org/abs/2303.02861), 2023.
Multitask prompt tuning (Wang et al., 2023, arXiv:2303.02861) learns one
prompt shared by every task and, per task, a low-rank factor pair
, .
Task 's prompt is the shared one multiplied elementwise by
, so a new task adds numbers, and a prompt
trained on source tasks can start a target task (prompt_tuning_init and
prompt_tuning_init_state_dict_path). Which task each row of a batch is
comes from the task_ids argument of the model's call.
CPT
3 memberslucid.peft.tuners.cptBlau, Tsachi, et al. "Context-Aware Prompt Tuning: Advancing In-Context Learning with Adversarial Methods." [arXiv:2410.17222](https://arxiv.org/abs/2410.17222), 2024.
CPT (Blau et al., 2024, arXiv:2410.17222) tunes a prompt made of in-context examples: the
prompt's tokens start as the embeddings of cpt_token_ids and a trainable delta is
added to each. Each token has a type (cpt_tokens_type_mask, read modulo 4: 1 an input
template, 2 an input, 3 an output template, 0 or 4 an output or padding) that
says which deltas train (types 1-3 only) and how far a delta may move: after every step its
norm is projected back onto a ball of radius opt_projection_epsilon (inputs) or
opt_projection_format_epsilon (templates), scaled by . The loss
covers the output tokens of the prompt and of the batch, optionally down-weighted for earlier
examples (opt_weighted_loss_type="decay").
Cartridge
7 memberslucid.peft.tuners.cartridgeEyuboglu, Sabri, et al. "Cartridges: Lightweight and General-Purpose Long Context Representations via Self-Study." [arXiv:2506.06266](https://arxiv.org/abs/2506.06266), 2025.
A Cartridge (Eyuboglu et al., 2025, arXiv:2506.06266 — Cartridges: Lightweight and general-purpose long
context representations via self-study) is a trained key-value cache. num_virtual_tokens learned
key/value pairs per attention layer are put in front of the model's cache, in place of a long document the
model would otherwise read at every query. The first num_frozen_tokens of them stay fixed; the paper
recommends freezing one as an attention sink. The cache is laid out as in prefix tuning, and starting it from
text or from a past cache is a separate step.
Shared-table tuners
One set of tensors for the whole model, such as random projections or a vector bank, held once by the tuner; each layer adds only a few parameters of its own. Uni-LoRA, PVeRA, TinyLoRA and Lily read their adapters out of such shared banks.
VeRA
4 memberslucid.peft.tuners.veraKopiczko, Dawid J., et al. "VeRA: Vector-based Random Matrix Adaptation." [arXiv:2310.11454](https://arxiv.org/abs/2310.11454), 2023.
VeRA (Kopiczko et al., 2023, arXiv:2310.11454 — Vector-based Random Matrix Adaptation) freezes the model and the low-rank pair: one random matrix and one are drawn once and shared by every targeted layer (sliced to its size), and a layer learns only two vectors,
RandLoRA
4 memberslucid.peft.tuners.randloraAlbert, Paul, et al. "RandLoRA: Full-rank Parameter-Efficient Fine-Tuning of Large Models." [arXiv:2502.00987](https://arxiv.org/abs/2502.00987), 2025.
RandLoRA (Albert et al., 2025, arXiv:2502.00987) reaches a full-rank update with few parameters: instead of one trainable low-rank pair it sums frozen random rank- pairs , drawn once and shared by every targeted layer, and trains only a diagonal scale on each side,
VB-LoRA
4 memberslucid.peft.tuners.vbloraLi, Yang, et al. "VB-LoRA: Extreme Parameter Efficient Fine-Tuning with Vector Banks." [arXiv:2405.15179](https://arxiv.org/abs/2405.15179), 2024.
VB-LoRA (Li et al., 2024, arXiv:2405.15179 — Vector Bank LoRA) builds every low-rank factor of every layer out of one shared vector bank of vectors of length . The factors and are cut into sub-vectors of length ; each sub-vector is a softmax-weighted mix of the top- bank vectors picked by learned logits,
Uni-LoRA
4 memberslucid.peft.tuners.uniloraLi, Kaiyang, et al. "Uni-LoRA: One Vector Is All You Need." [arXiv:2506.00799](https://arxiv.org/abs/2506.00799), 2025.
Uni-LoRA (Li et al., 2025, arXiv:2506.00799 — One Vector Is All You Need) reads every LoRA factor of
every adapted layer out of a single trainable vector of theta_d_length entries. A
fixed projection, drawn once from proj_seed, assigns each entry of the flattened factors one scaled
entry of , so the adapter of the whole model is theta_d_length numbers.
PVeRA
4 memberslucid.peft.tuners.pveraFillioux, Leo, et al. "PVeRA: Probabilistic Vector-Based Random Matrix Adaptation." [arXiv:2512.07703](https://arxiv.org/abs/2512.07703), 2025.
PVeRA (Fillioux et al., 2025, arXiv:2512.07703 — Probabilistic Vector-Based Random Matrix
Adaptation) makes VeRA probabilistic. As in VeRA, two frozen random projections shared by all layers and two
learned vectors per layer give the update; but the rank-r latent between them is the mean and
log-variance of a Gaussian, sampled in training in the manner of a variational encoder. At inference the
learned mean is used unless sample_at_inference is set.
TinyLoRA
5 memberslucid.peft.tuners.tinyloraMorris, John X., et al. "Learning to Reason in 13 Parameters." [arXiv:2602.04118](https://arxiv.org/abs/2602.04118), 2026.
TinyLoRA (Morris et al., 2026, arXiv:2602.04118 — Learning to Reason in 13 Parameters) freezes the
rank-r SVD of each adapted weight, , and trains only a vector
of u numbers. Fixed random tensors project it into an matrix
, and the update is . weight_tying between
0 and 1 sets how much of the modules share; at 1 the whole model learns u numbers.
Lily
4 memberslucid.peft.tuners.lilyZhong, Yibo, et al. "Low-Rank Interconnected Adaptation across Layers." [arXiv:2407.09946](https://arxiv.org/abs/2407.09946), 2024.
Lily (Zhong et al., 2024, arXiv:2407.09946 — Low-Rank Interconnected Adaptation across Layers)
breaks LoRA's pairing of a down- and an up-projection to one layer. Every stride_A consecutive layers
share one low-rank projection ; num_B projections are shared by all layers, and a
learned router mixes them with softmax weights into one combined per layer. The layer adds
to its output, so a layer's update draws on adapters
other layers train too.
Structured and sparse updates
A weight update with a fixed structure other than low rank: a few frequency-domain coefficients (FourierFT), block-circulant blocks (C3A), shared shards (MiSS, and Bone, the method it replaced) or a sparse subset of the weight itself (SHiRA). Super-Tuning (the entries of largest magnitude, with an optional LoRA beside them) and WaveFT (a few coefficients of an inverse wavelet transform) are here too.
FourierFT
4 memberslucid.peft.tuners.fourierftGao, Ziqi, et al. "Parameter-Efficient Fine-Tuning with Discrete Fourier Transform." [arXiv:2405.03003](https://arxiv.org/abs/2405.03003), 2024.
FourierFT (Gao et al., 2024, arXiv:2405.03003) learns the weight update in the frequency domain: a handful of coefficients of a spectrum, at fixed pseudo-random locations, and the inverse 2-D Fourier transform of that sparse spectrum is the update,
C3A
4 memberslucid.peft.tuners.c3aChen, Aochuan, et al. "Parameter-Efficient Fine-Tuning via Circular Convolution." [arXiv:2407.19342](https://arxiv.org/abs/2407.19342), 2024.
C3A (Chen et al., 2024, arXiv:2407.19342 — Circular Convolution Adaptation) makes the weight update a block-circulant matrix: the update is cut into blocks and each block is a circulant, fixed by its first row — a length- kernel. The layer trains numbers ( kernels per block row and column), which is high rank, and applies them by FFT without building the matrix,
MiSS
4 memberslucid.peft.tuners.missKang, Jiale, et al. [arXiv:2409.15371](https://arxiv.org/abs/2409.15371), 2024 (the paper that introduced Bone, revised as MiSS).
MiSS (Kang et al., 2024, arXiv:2409.15371 — Matrix Shard Sharing, the
successor of Bone) learns a single (r, d_out) matrix per layer and
adds it to the weight in shards: the input axis is cut into runs of
columns, and every run of every output row receives the same
-vector,
Bone
4 memberslucid.peft.tuners.boneKang, Jiale. [arXiv:2409.15371](https://arxiv.org/abs/2409.15371), 2024 (the paper that introduced Bone; MiSS is its successor).
Bone (Kang, 2024 — Block Affine) is the method MiSS (lucid.peft.MissConfig)
renamed and extended; the reference library no longer ships it. It is kept here
because adapter files written under the name still exist: a Bone adapter is a MiSS
adapter of the balance (init_weights=True) or "bat" variant with the block
stored as bone_block. New work should use MiSS.
SHiRA
5 memberslucid.peft.tuners.shiraBhardwaj, Kartikeya, et al. "Sparse High Rank Adapters." [arXiv:2406.13175](https://arxiv.org/abs/2406.13175), 2024.
SHiRA (Bhardwaj et al., 2024, arXiv:2406.13175 — Sparse High Rank Adapters) trains a
sparse subset of the weight itself: a fixed mask picks
entries of each targeted nn.Linear weight (as many parameters as a rank-
LoRA pair has, hence the name of r), and the adapter is the values of those
entries,
Super-Tuning
4 memberslucid.peft.tuners.supertuningIlin, Ivan, et al. "Super-Tuning: From Activation-Aware Pruning to Sparse Fine-Tuning." [arXiv:2607.09287](https://arxiv.org/abs/2607.09287), 2026.
Super-Tuning (Ilin et al., 2026, arXiv:2607.09287 — From Activation-Aware Pruning to Sparse
Fine-Tuning) freezes the base weight and trains a sparse support of its entries: the 1 - sparsity
fraction with the largest magnitude (select_top), as an additive update that starts at zero. With r
set, a LoRA pair is added beside it (the paper's Supra hybrid).
WaveFT
4 memberslucid.peft.tuners.waveftBilican, Ahmet, et al. "Exploring Sparsity for Parameter Efficient Fine Tuning Using Wavelets for Vision." [arXiv:2505.12532](https://arxiv.org/abs/2505.12532), 2025.
WaveFT (Bilican et al., 2025, arXiv:2505.12532 — Exploring Sparsity for Parameter Efficient Fine
Tuning Using Wavelets) learns n_frequency coefficients of the weight update in a discrete wavelet basis,
at random positions of the coefficient matrix, and rebuilds the update by an inverse 2-D wavelet transform of
the chosen wavelet_family. The update is multiplied by scaling and starts at zero. The number of
coefficients, not a rank, sets the parameter count of a layer.
Routing and mixing
Several low-rank adapters combined per task or per token: skills mixed by a learned per-task router (Poly, Multi-Head Routing), or trained LoRA experts weighed per token by a classifier on the hidden states (X-LoRA).
Poly
4 memberslucid.peft.tuners.polyPonti, Edoardo M., et al. "Combining Modular Skills in Multitask Learning." [arXiv:2202.13914](https://arxiv.org/abs/2202.13914), 2022.
Polytropon (Ponti et al., 2022, arXiv:2202.13914) gives each targeted layer n_skills
low-rank adapters (skills) and a router that holds one learned logit vector per task; the
layer's update for a task is the router-weighted mixture of the skills,
. Multi-Head Routing
(Caccia et al., 2022, arXiv:2211.03831) splits every skill into n_splits blocks along the
feature axis, each routed on its own: n_splits > 1. The weights are the
sigmoid of the task's logits, normalised to sum to one — in training a relaxed Bernoulli
sample of them instead, which makes the routing stochastic.
X-LoRA
3 memberslucid.peft.tuners.xloraBuehler, Eric L., and Markus J. Buehler. "X-LoRA: Mixture of Low-Rank Adapter Experts, a Flexible Framework for Large Language Models with Applications in Protein Mechanics and Molecular Design." [arXiv:2402.07148](https://arxiv.org/abs/2402.07148), 2024.
X-LoRA (Buehler & Buehler, 2024, arXiv:2402.07148) keeps several trained LoRA adapters (the
experts) and a small classifier on the base model's final hidden states that scales each
expert per token: a scalings pass computes the hidden states with the experts held at a
fixed value, the classifier turns them into one weight per expert (per adapted layer if
layerwise_scalings), and the real pass adds each expert's update with its weight. Only the
classifier trains unless use_trainable_adapters.
Adaption prompts
Learned prompts inside the model: the top attention layers of a decoder attend to them through a gate that starts at zero (LLaMA-Adapter).
Scaling and selective tuning
Methods that train a small part of the model itself: a learned rescaling vector per layer (IA3), a trainable copy of each chosen normalisation layer (LN tuning), a few rows of an embedding table (trainable tokens), or one bias added to the value projections (BEFT).
IA3
6 memberslucid.peft.tuners.ia3Liu, Haokun, et al. "Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learning." [arXiv:2205.05638](https://arxiv.org/abs/2205.05638), 2022.
(IA)^3 (Liu et al., 2022, arXiv:2205.05638 — "Infused Adapter by Inhibiting and Amplifying Inner Activations") freezes the model and learns one vector per targeted layer that rescales its output channels, ; for the feed-forward layers of a block it rescales the input instead, . The vector starts at ones, so the adapted model starts as the base, and it folds into the weight (and bias), so a merged model costs what the base does.
LN Tuning
3 memberslucid.peft.tuners.ln_tuningZhao, Bingchen, et al. "Tuning LayerNorm in Attention: Towards Efficient Multi-Modal LLM Finetuning." [arXiv:2312.11420](https://arxiv.org/abs/2312.11420), 2023.
LN tuning (Zhao et al., 2023, arXiv:2312.11420 — "Tuning LayerNorm in Attention") trains the normalisation layers of a model and nothing else: each targeted layer gets a copy of itself that trains while the original stays frozen. The method adds no tensor of its own, so it is a few parameters per layer; "merging" makes the trained copy the layer.
Trainable Tokens
5 memberslucid.peft.tuners.trainable_tokensTrainable tokens re-train existing token embeddings, or the fresh ones a resized vocabulary added, without training the whole table: the listed rows are copied into a small parameter, the layer reads those rows from it instead of from the frozen table, and only the copy is trained and saved,
BEFT
4 memberslucid.peft.tuners.beftHuang, Baichuan, et al. "BEFT: Bias-Efficient Fine-Tuning of Language Models in Low-Data Regimes." [arXiv:2509.15974](https://arxiv.org/abs/2509.15974), 2025.
BEFT (Huang et al., 2025, arXiv:2509.15974 — Bias-Efficient Fine-Tuning of Language Models in Low-Data Regimes) trains nothing but a bias added to chosen linear layers, the value projections by default: with one learned vector of the layer's output width, zero at the start. It adds the fewest parameters of any method here.
Refused
A method whose config is read and written, so a file of it loads, but whose adapter is not built: ShadowPEFT needs the base model's decoder loop and a second backbone beside it.
Utilities
Entry points that adapt a model without wrapping it, the adapter state-dict helpers, and the status reports of a model's adapter layers.
NoMatchingPeftModuleErrorAn adapter's targets matched no module, or no parameter, of the model.
PeftErrorThe base of the errors lucid.peft raises on its own account.
PeftWarningThe base of the warnings lucid.peft issues on its own account.
ModulesToSaveWrapper9 methodsHold module beside a trained copy per adapter; the active adapter's copy runs.
TunerLayerStatus2 methodsThe state of one adapter layer.
TunerModelStatus1 methodsThe state of the adapters of a whole model, folded from its layers.
get_base_model_state_dict→ dict of str to TensorReturn the base model's state dict, under the key names it had before it was adapted.
set_base_model_state_dict→ _IncompatibleKeysLoad a state dict of the base model's original key names into an adapted model.
find_kappa_target_modules→ dict of str to list of str or NoneChoose what to adapt by the condition number of the weights (KappaTune).
load_peft_weights→ dict of str to TensorRead the tensors of a saved adapter, by their file keys.
get_peft_config→ PeftConfigBuild the adapter config a dict describes, of the class its peft_type names.
get_peft_model→ PeftModel or PeftMixedModelAdapt model with the method peft_config names and return it wrapped as a lucid.peft.PeftModel (or, with mixed=True, a lucid.peft.PeftMixedModel).
inject_adapter_in_model→ nn.ModulePut adapter layers into model in place and return it, without a wrapper.
cast_mixed_precision_params→ NoneCast the model's frozen parameters to dtype and its trainable ones to float32.
prepare_model_for_kbit_training→ nn.ModuleFreeze the base model, upcast its half-precision parameters to float32, and prepare quantized models for QLoRA.
shift_tokens_right→ TensorShift token ids one place to the right, to make the decoder inputs of labels.
get_layer_status→ list of TunerLayerStatusThe state of each adapter layer of model: enabled, active, merged, trainable, and where.
get_model_status→ TunerModelStatusThe state of model's adapters as a whole, folded from its layers.
bloom_model_postprocess_past_key_value→ tuple of tuple of TensorReshape a prefix-tuning prompt into the cache layout of the bloom family.
get_peft_model_state_dict→ dict of str to TensorReturn the adapter's tensors under the keys an adapter file uses.
set_peft_model_state_dict→ _IncompatibleKeysLoad an adapter's tensors, keyed as an adapter file keys them, into model.
Attributes
PEFT_ TYPE_ TO_ CONFIG_ MAPPINGMapping[PeftType, type[PeftConfig]]PeftType: a read-only view of the registry that PeftConfig subclasses join as they are defined, so a method added later appears here.PEFT_ TYPE_ TO_ MIXED_ MODEL_ MAPPINGMapping[PeftType, type[_BaseTuner]]lucid.peft.PeftMixedModel can hold, by PeftType: a read-only view of the registry a tuner joins with mixed=True as it is defined, so a method declared later appears here. These are the methods whose layers stack on one another's and have passed the pair contract (LoRA, LoHa, LoKr, AdaLoRA, SHiRA, OFT, (IA)^3, BEFT, RoAd and HiRA). The reference's table lists nine, without OFT, and four of those (IA3, BEFT, HiRA, RoAd) are refused where its constructor and add_adapter take a config; this table is exactly what the class accepts.PEFT_ TYPE_ TO_ TUNER_ MAPPINGMapping[PeftType, type[_AdapterHost] | type[_WithheldTuner]]PeftType: a read-only view of the tuner registries, like PEFT_TYPE_TO_CONFIG_MAPPING. A method whose adapter is refused has a tuner class here too: it raises NotImplementedError when built, saying why.TRANSFORMERS_ MODELS_ TO_ PREFIX_ TUNING_ POSTPROCESS_ MAPPINGdict[str, Callable[[tuple[Tensor, ...]], tuple[tuple[Tensor, Tensor], ...]]]model_type -> the function that turns a prefix-tuning prompt into that family's cache layout. A plain dict, as the reference's: add a family by assigning to it.