Skip to content
module

peft

40 members
lucid.peft

lucid.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-rr update s BAs\,BA — on GPT-2 small's c_attn at r=8r = 8, 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_skills low-rank skills and a router with a logit vector per task, PolyConfig / PolyModel; the call names its tasks with task_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 / gpt2 decoder 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.Linear is kept as base_layer with its own Parameter objects — 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 (B=0B = 0) the adapted model's output is the base model's, bit for bit.
  • Only the adapter trains. Every other parameter is frozen; the bias option and modules_to_save add 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_unload raises 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 head score becomes classifier; no other name or tensor changes.
  • "roformer" — the layouts agree, so a file converts by identity.
  • "t5" — the reference's block.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 the t5. trunk prefix.
  • "vit" — the separate query / key / value adapters are fused into the zoo's one qkv (exactly for LoRA; another method on those projections raises NotImplementedError), 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.

dataPeftConfig9 methods

What every adapter config holds, and the adapter_config.json round trip.

classPeftType

The parameter-efficient method an adapter file holds.

dataPromptLearningConfig

The fields of a method that learns an input rather than a weight.

classTaskType

The task an adapter was trained for, as adapter_config.json records it.

classPeftModel30 methods

A model with adapters, saved and loaded as the adapters alone.

classPeftModelForCausalLM29 methods

An adapted causal language model: the PeftModel for task_type="CAUSAL_LM".

classPeftModelForFeatureExtraction29 methods

An adapted feature encoder: the PeftModel for task_type="FEATURE_EXTRACTION".

classPeftModelForQuestionAnswering29 methods

An adapted question-answering model: the PeftModel for task_type="QUESTION_ANS".

classPeftModelForSeq2SeqLM29 methods

An adapted encoder-decoder model: the PeftModel for task_type="SEQ_2_SEQ_LM".

classPeftModelForSequenceClassification29 methods

An adapted sequence classifier: the PeftModel for task_type="SEQ_CLS".

classPeftModelForTokenClassification30 methods

An adapted token classifier: the PeftModel for task_type="TOKEN_CLS".

classAutoPeftModel1 methods

Load an adapter that has no task, with its base model.

classAutoPeftModelForCausalLM1 methods

Load a causal language model's adapter with its base model.

classAutoPeftModelForFeatureExtraction1 methods

Load a feature encoder's adapter with its base model.

classAutoPeftModelForQuestionAnswering1 methods

Load a question-answering model's adapter with its base model.

classAutoPeftModelForSeq2SeqLM1 methods

Load an encoder-decoder model's adapter with its base model.

classAutoPeftModelForSequenceClassification1 methods

Load a sequence classifier's adapter with its base model.

classAutoPeftModelForTokenClassification1 methods

Load 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).

family

LoRA

30 memberslucid.peft.tuners.lora

Hu, 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 AA from the top right-singular vectors.

family

AdaLoRA

6 memberslucid.peft.tuners.adalora

Zhang, 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,

family

DeLoRA

4 memberslucid.peft.tuners.delora

Bini, 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 λ\lambda,

family

GraLoRA

4 memberslucid.peft.tuners.gralora

Jung, 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 α/(r+hybrid_r)\alpha / (r + \text{hybrid\_r}).

family

HiRA

8 memberslucid.peft.tuners.hira

Huang, 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,

family

GLoRA

4 memberslucid.peft.tuners.glora

Chavan, 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,

family

DEFT

4 memberslucid.peft.tuners.deft

Kumar, 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 WW it learns a direction matrix P∈Rdout×rP \in \mathbb{R}^{d_{out} \times r} and an injection matrix R∈Rr×dinR \in \mathbb{R}^{r \times d_{in}} and uses

family

PEANuT

4 memberslucid.peft.tuners.peanut

Zhong, 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, W′=W+f(W;θ)W' = W + f(W; \theta), where ff is a small trained network, not a fixed low-rank product. At depth zero f(W)=s σ(W⊤A⊤) Bf(W) = s\,\sigma(W^\top A^\top)\,B with A∈Rr×doutA \in \mathbb{R}^{r \times d_{out}} and B∈Rdout×rB \in \mathbb{R}^{d_{out} \times r} (transposed back to the shape of WW); each unit of depth puts an encoder layer r→rr \to r before and a decoder layer after the middle, joined by residuals (appendix F), with the non-linearity act_fn between all of them. BB is zero when training begins, which makes the first update zero too.

family

AdaMSS

5 memberslucid.peft.tuners.adamss

Zheng, 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).

family

OFT

5 memberslucid.peft.tuners.oft

Qiu, 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: y=(WR⊤)x+by = (W R^\top) x + b with RR block-diagonal, each block an orthogonal matrix (I−Q)(I+Q)−1(I - Q)(I + Q)^{-1} of a learned skew-symmetric QQ. A rotation keeps the pairwise angles between the weight's neurons, which is what OFT tunes while the weight's spectrum stays. The QQs 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.

family

BOFT

5 memberslucid.peft.tuners.boft

Liu, 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 mm sparse orthogonal factors in butterfly order, so a small number of parameters spans a dense rotation of the input space:

family

HRA

5 memberslucid.peft.tuners.hra

Yuan, 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 rr Householder reflections,

family

RoAd

4 memberslucid.peft.tuners.road

Liao, 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),

family

PSOFT

5 memberslucid.peft.tuners.psoft

Wu, 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 AA and BB, and only an r×rr \times r matrix RR between them is trained:

family

OSF

4 memberslucid.peft.tuners.osf

Nayak, 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.

family

FRoD

4 memberslucid.peft.tuners.frod

Wan, 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).

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.

family

Prompt Tuning

4 memberslucid.peft.tuners.prompt_tuning

Lester, 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.

family

Prefix Tuning

3 memberslucid.peft.tuners.prefix_tuning

Li, 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).

family

P-Tuning

4 memberslucid.peft.tuners.p_tuning

Liu, 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.

family

Multitask Prompt Tuning

4 memberslucid.peft.tuners.multitask_prompt_tuning

Wang, 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 uk∈RL×ru_k \in \mathbb{R}^{L \times r}, vk∈Rr×dv_k \in \mathbb{R}^{r \times d}. Task kk's prompt is the shared one multiplied elementwise by ukvku_k v_k, so a new task adds r (L+d)r\,(L + d) 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.

family

CPT

3 memberslucid.peft.tuners.cpt

Blau, 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 d/2048\sqrt{d/2048}. The loss covers the output tokens of the prompt and of the batch, optionally down-weighted for earlier examples (opt_weighted_loss_type="decay").

family

Cartridge

7 memberslucid.peft.tuners.cartridge

Eyuboglu, 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.

family

VeRA

4 memberslucid.peft.tuners.vera

Kopiczko, 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 A∈Rr×dinA \in \mathbb{R}^{r \times d_{in}} and one B∈Rdout×rB \in \mathbb{R}^{d_{out} \times r} are drawn once and shared by every targeted layer (sliced to its size), and a layer learns only two vectors,

family

RandLoRA

4 memberslucid.peft.tuners.randlora

Albert, 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 n=⌈min⁡(dout,din)/r⌉n = \lceil \min(d_{out}, d_{in}) / r \rceil frozen random rank-rr pairs (Bi,Ai)(B_i, A_i), drawn once and shared by every targeted layer, and trains only a diagonal scale on each side,

family

VB-LoRA

4 memberslucid.peft.tuners.vblora

Li, 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 V∈RN×bV \in \mathbb{R}^{N \times b} of NN vectors of length bb. The factors A∈Rr×dinA \in \mathbb{R}^{r \times d_{in}} and B∈Rdout×rB \in \mathbb{R}^{d_{out} \times r} are cut into sub-vectors of length bb; each sub-vector is a softmax-weighted mix of the top-kk bank vectors picked by learned logits,

family

Uni-LoRA

4 memberslucid.peft.tuners.unilora

Li, 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 θd\theta_d of theta_d_length entries. A fixed projection, drawn once from proj_seed, assigns each entry of the flattened factors one scaled entry of θd\theta_d, so the adapter of the whole model is theta_d_length numbers.

family

PVeRA

4 memberslucid.peft.tuners.pvera

Fillioux, 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.

family

TinyLoRA

5 memberslucid.peft.tuners.tinylora

Morris, 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, W≈UΣV⊤W \approx U \Sigma V^\top, and trains only a vector vv of u numbers. Fixed random tensors PiP_i project it into an r×rr \times r matrix R=∑iviPiR = \sum_i v_i P_i, and the update is ΔW=UΣRV⊤\Delta W = U \Sigma R V^\top. weight_tying between 0 and 1 sets how much of vv the modules share; at 1 the whole model learns u numbers.

family

Lily

4 memberslucid.peft.tuners.lily

Zhong, 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 AA; num_B projections BB are shared by all layers, and a learned router mixes them with softmax weights into one combined BB per layer. The layer adds scaling⋅A Bcombined\text{scaling} \cdot A\,B_{\text{combined}} 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.

family

FourierFT

4 memberslucid.peft.tuners.fourierft

Gao, 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 c1…cnc_1 \dots c_n of a dout×dind_{out} \times d_{in} spectrum, at fixed pseudo-random locations, and the inverse 2-D Fourier transform of that sparse spectrum is the update,

family

C3A

4 memberslucid.peft.tuners.c3a

Chen, 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 dout×dind_{out} \times d_{in} update is cut into b×bb \times b blocks and each block is a circulant, fixed by its first row — a length-bb kernel. The layer trains doutdin/bd_{out} d_{in} / b numbers (bb kernels per block row and column), which is high rank, and applies them by FFT without building the matrix,

family

MiSS

4 memberslucid.peft.tuners.miss

Kang, 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 SS per layer and adds it to the weight in shards: the input axis is cut into runs of rr columns, and every run of every output row receives the same rr-vector,

family

Bone

4 memberslucid.peft.tuners.bone

Kang, 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.

family

SHiRA

5 memberslucid.peft.tuners.shira

Bhardwaj, 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 r (dout+din)r\,(d_{out}+d_{in}) entries of each targeted nn.Linear weight (as many parameters as a rank-rr LoRA pair has, hence the name of r), and the adapter is the values of those entries,

family

Super-Tuning

4 memberslucid.peft.tuners.supertuning

Ilin, 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).

family

WaveFT

4 memberslucid.peft.tuners.waveft

Bilican, 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).

family

Poly

4 memberslucid.peft.tuners.poly

Ponti, 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, y=Wx+1r x (∑smsAs)(∑smsBs)y = W x + \tfrac{1}{r}\,x\,(\sum_s m_s A_s)(\sum_s m_s B_s). 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 mm 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.

family

X-LoRA

3 memberslucid.peft.tuners.xlora

Buehler, 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).

family

IA3

6 memberslucid.peft.tuners.ia3

Liu, 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 ℓ\ell per targeted layer that rescales its output channels, y=ℓ⊙(Wx+b)y = \ell \odot (W x + b); for the feed-forward layers of a block it rescales the input instead, y=W(ℓ⊙x)+by = W (\ell \odot x) + b. 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.

family

LN Tuning

3 memberslucid.peft.tuners.ln_tuning

Zhao, 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 dd parameters per layer; "merging" makes the trained copy the layer.

family

Trainable Tokens

5 memberslucid.peft.tuners.trainable_tokens

Trainable 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,

family

BEFT

4 memberslucid.peft.tuners.beft

Huang, 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: y=Wx+b+βy = W x + b + \beta with one learned vector β\beta 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.

classNoMatchingPeftModuleError

An adapter's targets matched no module, or no parameter, of the model.

classPeftError

The base of the errors lucid.peft raises on its own account.

classPeftWarning

The base of the warnings lucid.peft issues on its own account.

classModulesToSaveWrapper9 methods

Hold module beside a trained copy per adapter; the active adapter's copy runs.

dataTunerLayerStatus2 methods

The state of one adapter layer.

dataTunerModelStatus1 methods

The state of the adapters of a whole model, folded from its layers.

fnget_base_model_state_dict→ dict of str to Tensor

Return the base model's state dict, under the key names it had before it was adapted.

fnset_base_model_state_dict→ _IncompatibleKeys

Load a state dict of the base model's original key names into an adapted model.

fnfind_kappa_target_modules→ dict of str to list of str or None

Choose what to adapt by the condition number of the weights (KappaTune).

fnload_peft_weights→ dict of str to Tensor

Read the tensors of a saved adapter, by their file keys.

fnget_peft_config→ PeftConfig

Build the adapter config a dict describes, of the class its peft_type names.

fnget_peft_model→ PeftModel or PeftMixedModel

Adapt model with the method peft_config names and return it wrapped as a lucid.peft.PeftModel (or, with mixed=True, a lucid.peft.PeftMixedModel).

fninject_adapter_in_model→ nn.Module

Put adapter layers into model in place and return it, without a wrapper.

fncast_mixed_precision_params→ None

Cast the model's frozen parameters to dtype and its trainable ones to float32.

fnprepare_model_for_kbit_training→ nn.Module

Freeze the base model, upcast its half-precision parameters to float32, and prepare quantized models for QLoRA.

fnshift_tokens_right→ Tensor

Shift token ids one place to the right, to make the decoder inputs of labels.

fnget_layer_status→ list of TunerLayerStatus

The state of each adapter layer of model: enabled, active, merged, trainable, and where.

fnget_model_status→ TunerModelStatus

The state of model's adapters as a whole, folded from its layers.

fnbloom_model_postprocess_past_key_value→ tuple of tuple of Tensor

Reshape a prefix-tuning prompt into the cache layout of the bloom family.

fnget_peft_model_state_dict→ dict of str to Tensor

Return the adapter's tensors under the keys an adapter file uses.

fnset_peft_model_state_dict→ _IncompatibleKeys

Load an adapter's tensors, keyed as an adapter file keys them, into model.

Attributes

MODEL_TYPE_TO_PEFT_MODEL_MAPPINGFinal[Mapping[TaskType, type[PeftModel]]]
Wrapper class by the task it serves, as the reference's table of the same name. Read-only.
PEFT_TYPE_TO_CONFIG_MAPPINGMapping[PeftType, type[PeftConfig]]
The config class of each method, by 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]]
The tuner of each method a 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]]
The tuner (the model class that puts a method's adapters into a model) of each method, by 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], ...]]]
A model family's 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.