Skip to content

LoRA Quality — PiSSA, ReLoRA, Per-Pattern Rank, Surgical Patches (v0.39.0)

Five PEFT-surface improvements that LlamaFactory and Axolotl maintain.

yaml
training:
  quantization: none              # required: the schema default is 4bit; PiSSA and ReLoRA need a float base
  lora:
    init_strategy: pissa          # 'random' (default), 'pissa', 'olora'
    rank_pattern:                 # per-target-module rank override; keys are REGEXES
    # Since v0.75.1 each key is length-capped at 512, compiled explicitly, and
    # put through the same structural regex check as lr_groups, because peft
    # matches every key as a regex against every module name in the model.
      q_proj: 8
      v_proj: 16
    alpha_pattern:                # per-target-module alpha override
      q_proj: 16
  relora_steps: 500               # merge and re-initialise the adapter every 500 steps
  relora_warmup_ratio: 0.1        # skip first 10% of training
  relora_prune_ratio: 0.9         # deprecated: kept so old YAML loads, ignored
  relora_reset_optimizer: true    # clear optimizer state after each restart

PiSSA

PiSSA initializes the LoRA pair from the SVD of the base weight, giving faster early convergence than random init at the cost of one extra SVD pass on the first epoch.

If you set one of these before v0.76.0, the adapter you got was plain LoRA. Through v0.75.2 lora.init_strategy (pissa, olora, loftq), lora.use_olora, lora.loftq_iter, lora.loftq_bits and lora.use_vera were accepted by the schema and read by no trainer, so a run that set one trained an ordinary random-init LoRA, exit 0, normal loss curve. v0.76.0 sends every transformers trainer's adapter through one builder: PiSSA, OLoRA and LoftQ change the base weight at attach time, and VeRA builds a PEFT VeraConfig instead of a LoRA one. Re-run to get the variant.

Since v0.76.0 (#1037) the strategy is checked when the config loads. pissa and loftq need training.quantization: none, because PEFT computes on the floating-point base weights: under the default 4bit the config is refused with training.lora.init_strategy='pissa' requires training.quantization='none'. A non-random init_strategy and use_vera are refused on backend: unsloth and backend: mlx, which build their own adapters. use_dora is refused on backend: unsloth, and on backend: mlx except text SFT at quantization: none or 4bit, which builds DoRA natively since v0.77.0 (see DoRA on MLX). olora still loads at 4bit.

init_strategy: olora is also accepted; setting the legacy use_olora: true auto-aligns for back-compat.

Merging such an adapter. soup merge --low-memory refuses an adapter whose init_lora_weights rewrites the base at attach time (PiSSA and OLoRA from lora.init_strategy, CorDA, LoftQ, LoRA-GA) since v0.78.0 (#2722, #2732); use the regular soup merge for these. On v0.77.2, the version checked, such a merge wrote wrong weights at exit 0, in upstream's words "silently writing wrong weights"; merge it again without --low-memory.

ReLoRA

ReLoRA fires every N global steps. Each restart merges the LoRA update (B @ A, with PEFT scaling) into the frozen base weight, re-initialises lora_A (Kaiming) and lora_B (zeros), optionally clears the optimizer state of those adapter parameters (relora_reset_optimizer, default true), and re-warms the learning rate: the first post-restart step uses 1/(W+1) of the target rate for a warmup of W steps, then rises by that increment to the full rate. Useful for very long training runs where the LoRA capacity saturates.

ReLoRA is a behaviour break in v0.76.0 (#693). Through v0.75.2 it magnitude-pruned the adapter instead of restarting it, and relora_prune_ratio set how much; that key is now deprecated and ignored (a restart no longer prunes). If you ran with relora_steps before, you trained a different procedure than the one now described.

  • relora_steps requires an explicit quantization: none, since a merge needs a writable float base; under the default 4bit the config is refused. It is also refused with lora.use_vera, lora.use_dora, stream_layers and use_fsdp2_compile, and on backend: mlx.
  • Since v0.77.0 it is refused where the loss has a frozen reference (#1835, #1891): on dpo, ipo, kto and bco, on grpo with grpo_beta above 0, and on a preference run whose loss or blend names dpo, ipo or bco. trl reads those references from the policy's own base weights, and every ReLoRA restart merges the trained adapter into them, so upstream says "from the first restart on the reference was the policy as of that step, without an error". sft, orpo, simpo, grpo with grpo_beta: 0 and a simpo / orpo preference run keep ReLoRA. If you trained one of the refused shapes with relora_steps on v0.76.0 or v0.76.1 (the merging restart arrived in v0.76.0), re-run it without the key.
  • Restarts accumulate faithfully only on an fp32 base; a bf16 or fp16 base loses the merge delta to rounding.
  • The final output is a standalone dense model: Soup merges the active adapter into the accumulated in-memory base and saves it. Load or export that output directly; do not run soup merge on it.
  • --resume and --hf-resume are refused when relora_steps is set, because intermediate checkpoints do not encode the accumulated restart state.

ReLoRA is wired into the preference and RL trainers too; since v0.77.0 it is refused on the losses listed above.

Per-pattern rank/alpha

Map module name patterns to integer ranks. Useful in MoE configs where expert FFNs need lower rank than attention.

Caps: 256 keys × value 1024. bool rejected on values. Incompatible with use_vera (VeRA shares one rank). Since v0.76.0 (#923) the two pattern keys are applied by every trainer that attaches a LoRA adapter, asr, classifier, distill, embedding, ppo, unlearn and layer streaming included. Through v0.75.2 only SFT and pretraining built their adapter through the shared builder, so on dpo, orpo, simpo, kto, bco, ipo, grpo, ppo, online_dpo, reward_model, embedding, classifier, distill and asr the keys were ignored and the adapter was uniform-rank; re-run if you set them there. All of that is on backend: transformers: backend: mlx (#1996) and backend: unsloth (#2153) build one scalar-rank adapter, and through v0.76.1 dropped both keys without a word, so the run trained a uniform-rank adapter. Since v0.77.0 they refuse the keys at config load (training.lora.rank_pattern is not applied by backend: mlx ...); an empty {} sets nothing and still loads. Upstream calls this a stop-gap until those trainers apply the patterns (MLX: tracked as #1996).

Freezing layers under LoRA (v0.77.0)

training.freeze_layers / freeze_ratio with LoRA are applied since v0.77.0 (#1432, #2145): a frozen layer gets no adapter, so freeze_layers: 16 with LoRA trains adapters only on the layers above the bottom 16. Through v0.76.1 the freeze was set before peft attached the adapter, which then put a trainable adapter on every targeted module in every layer, the frozen ones included, so the run trained more than it said. Such a config now trains fewer layers than before, which is what the option always documented, and its results change. The keys are read by task: sft (and tts) on the transformers text path without layer streaming, as before.

yaml
training:
  freeze_layers: 16
  lora:
    r: 16
    alpha: 32
    target_modules: [q_proj, k_proj, v_proj, o_proj]   # a list: peft restricts a list by layer

The adapter follows the freeze for a list of module names, and since v0.78.0 (#2201, by @xiemocun) for a string target too (all-linear, a regular expression, or what auto resolves to on some architectures): Soup resolves the string to the module names peft would pick, drops the ones outside the trainable layers, and prints Freeze-scoped targets: N module(s) resolved from target_modules='all-linear' inside layers C..T-1. Refused when the model is built, after the config loads (so soup train --dry-run does not catch it): a string that reaches no trainable layer (the message names the range it resolved against), a list target that resolves only outside a numbered decoder layer (such as embed_tokens; a top-level lm_head target is accepted), lora.target_parameters, lora.use_vera, and a plan that freezes every layer. (Since closed in v0.78.0: through v0.77.2 a string target was refused here.) Full fine-tuning (lora.r: 0) is unchanged.

rsLoRA on MLX and Unsloth (v0.77.0)

lora.use_rslora: true scales by alpha / sqrt(r) on every backend since v0.77.0. Through v0.76.1 backend: mlx and backend: unsloth loaded the flag and never read it, so an rsLoRA run there trained at the plain-LoRA scale alpha / r, an 8x smaller update at the default r: 64, alpha: 16 (#1899). Such a config's results change on v0.77.0: re-run if you wanted rsLoRA, or drop the flag to keep the old scale. See rsLoRA.

LoRA-FA (frozen-A LoRA)

training.use_lorafa: true (v0.76.0, #725) freezes the random LoRA A matrices and trains only the B matrices, using PEFT's create_lorafa_optimizer (arXiv:2308.03303).

yaml
training:
  lr: 2e-4
  use_lorafa: true
  lora:
    r: 64
    alpha: 16

It needs backend: transformers and a LoRA adapter (lora.r of at least 1), and it applies to sft, pretrain and embedding. It is refused with loraplus_lr_ratio (LoRA+ tunes the A matrices that LoRA-FA freezes), use_galore, lora.use_vera, a non-AdamW optimizer, lora.r: 0 and backend: mlx. It has not been validated under stream_layers: true.

Upstream's only measurement is a micro-benchmark on a 2-layer, hidden-256 model (record). It is not a total or peak VRAM saving, a throughput result or a quality claim, and this site quotes no figure from it; task quality and end-to-end throughput against standard LoRA are unmeasured.

Fast-LoRA kernels: training.fast_lora (v0.77.0)

training.fast_lora: true runs a LoRA's projections through Soup's own autograd functions instead of peft's modules: q/k/v with one shared input, gate/up/down as one SwiGLU block, and every other adapted Linear as a single projection (#792, #1973, by @ybai08). Setup prints what each kernel took over and refuses the run when none did. Off by default.

yaml
training:
  fast_lora: true
  quantization: 4bit      # or none
  lora:
    dropout: 0            # required: Soup's default is 0.05

Scope, refused at load otherwise, with the reason: task: sft, backend: transformers, modality: text, quantization none or 4bit, a LoRA (lora.r of at least 1) and lora.dropout: 0 (peft gives every projection its own dropout, so q/k/v and gate/up would no longer share the one input the kernels read). It is also refused beside use_liger, DoRA, VeRA, lora.target_parameters, Spectrum's unfrozen_parameters, LISA and quantization_aware: fp8. It runs on the resident and the layer-streamed SFT paths.

What is verified, and what is not. Upstream's statement: the correctness checks were run on CPU (float32 and float64 against peft), the correctness half is still listed as open (#792), and no speedup and no end-to-end result is claimed. Two CUDA readings exist since v0.78.0 (below), and they disagree on direction, so no speed or memory figure is published here.

Two things were added around it in v0.77.2, and neither is a result. First, a timing and memory harness for the Q/K/V path (benchmarks/harness/fast_lora_qkv_bench.py, #838) is in upstream's benchmarks/ directory; at v0.77.2 its index said it had not yet been run on a GPU and that there was no record for it (Since closed in v0.78.0: the index now records one run, described below). Second, a CPU measurement record (fast-lora-cpu-bf16-2026-10-29.md, by @kok-o, #2354, for issue #2187) looked at the bf16 MLP kernel test: on one Ryzen 7 7840HS, seed 4 of twelve fails with torch 2.8.0+cpu and all twelve pass with torch 2.14.1+cpu, but the seeded bf16 input itself changes between those two versions, so the record says the observation does not show the kernel's numerical behaviour improved on an identical input. It proposes no kernel or criterion change and claims no CUDA, speed, memory or quality result. The upstream release notes still carry fast_lora with no speedup claim and no end-to-end claim, and its correctness half open (#792).

Two kernel changes in v0.78.0 make a fast_lora run not bit-comparable with v0.77.2 (upstream's list, #2383 and #2546). A 4-bit base projection now returns to the input dtype before the LoRA add (it used to round the LoRA branch's input to bitsandbytes' compute dtype), and the SwiGLU LoRA input gradient is added to the base gradient in fp32 and rounded once (upstream says the earlier bf16 rounding lost an ulp in one gradient and left the bf16 MLP parity test failing on one seed). Neither entry states a measured result, and the correctness half of fast_lora is still listed as open. The seed-4 record above is unchanged by this; #2546 changed the kernel after it.

Two CUDA readings, and they point in different directions. (1) The benchmarks index records one run of the Q/K/V harness on an RTX 3060 Laptop GPU (6144 MiB, driver 610.60, on mains; two passes of three processes per cell): faster in all eight cells in both passes, no void, crashed or out-of-memory row, fast over plain 0.8798 to 0.9779, and peak allocated memory 32 to 37 MB lower on the fast arm. There is no record file for it: the results are in two GitHub issue comments (#838) and an index row, which calls it a new baseline, not comparable with other cards, with no end-to-end claim; the four NF4 cells are to be run again now that #2383 landed. (2) fast-lora-mlp-cuda-t4-2026-11-08.md (#837, by @capyriver, #2621) measured one synthetic Llama-3.1-8B-shaped SwiGLU block on one Colab Tesla T4, with no language model loaded, in emulated bf16 and in NF4: no measurable difference in time (one process per dtype, no noise threshold set beforehand, so the record gives no speed verdict), outputs matching plain PEFT exactly, a lower raw saved-tensor count for Fast-LoRA, and a higher peak allocated memory in both dtypes, whose cause the record says remains unknown because no allocation breakdown was captured. Both are one block on one card and neither is an end-to-end training result, so this page claims neither a speedup nor a memory saving.

Surgical patches

  • Gemma 4 ClippableLinear swap (auto-detected via word-boundary regex on model name)
  • Fused-MoE 3-D expert lora_dropout strip

Both auto-fire when the model name and architecture match. Both are gated and silent on unrelated models.

Template registry

The 21 built-in templates now live as soup_cli/templates/*.yaml with a manifest.json index. soup init --template <name> reads the YAML; the inline copies in schema.py stay as a back-compat fallback, deprecated in favour of the YAML registry.

load_template containment-checks the resolved path against _templates_dir() so a tampered manifest.json cannot read files outside the package directory.

Scope

Wired into the SFT trainer + transformers backend in v0.39.0. ReLoRA is wired into the preference and RL trainers too, except on the losses v0.77.0 refuses it for (see ReLoRA). The MLX backend refuses relora_steps, the non-random init_strategy values and, since v0.77.0, rank_pattern / alpha_pattern at config load.

Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.