Skip to content

Optimizer Zoo (v0.41.0)

A closed allowlist of 24 optimizers: HF-native (8), bitsandbytes-backed (8), the v0.41 additions that still work (6), and two that only the MLX backend builds (adamw_hf and muon). So 22 are usable on the transformers and unsloth backends. The allowlist was 32 through v0.75.2; ten names were removed or restricted in v0.76.0 (below).

Supported optimizers

HF-native (8): adamw_torch, adamw_torch_fused, adamw_torch_xla, adamw_anyprecision, adafactor, sgd, adagrad, rmsprop.

bitsandbytes-backed (8): adamw_bnb_8bit, adamw_8bit, lion_8bit, lion_32bit, paged_adamw_8bit, paged_adamw_32bit, paged_lion_8bit, paged_lion_32bit.

Still available from v0.41 (6):

  • APOLLO (apollo_adamw) — gradient-scaled training in low rank
  • lomo / adalomo — low-memory optimization with optional adaptive scaling
  • grokadamw — Grokfast-style AdamW
  • schedule_free_adamw / schedule_free_sgd

MLX backend only (2): adamw_hf and muon. Both are refused at config load on backend: transformers and backend: unsloth (#1283); on backend: mlx they load.

adafactor also has an MLX equivalent. On backend: mlx it applies the configured learning rate, warmup and schedule since v0.77.2 (#2484, by @vaputa); through v0.77.1 it did not, so an existing MLX Adafactor run trains differently now, in the release notes' words. That is a statement from upstream's changelog and code: it was not run here, because it needs Apple Silicon.

yaml
training:
  optimizer: adamw_bnb_8bit

validate_optimizer_name rejects non-string / empty / null-byte / >64-char inputs with actionable messages and lowercases for deterministic lookup. Unknown names fail at config-load.

Refused since v0.76.0

Eight names the v0.41 release added, or that had always been listed, are refused at config load because transformers 5.x rejects them in TrainingArguments after the model has loaded (#1269): badam, adam_mini, dion, came_pytorch, adamw_apex_fused and the three TorchAO names ao_adamw_fp8, ao_adamw_4bit, ao_adamw_8bit. Through v0.75.2 a config naming one of them loaded and then died inside the trainer. The error names adamw_torch, adamw_torch_fused, adamw_bnb_8bit and adafactor as working alternatives.

loraplus_lr_ratio cannot be combined with apollo_adamw, lomo or adalomo (#1210): LoRA+ builds its optimizer without the model, and transformers can only build those three from the model.

Per-module LR groups (refused since v0.77.0)

training.lr_groups is refused at load since v0.77.0 when it is set: training.lr_groups is accepted but read by nothing; refused as of v0.77. Delete the line. (#761; soup train exits 1 and soup doctor --config exits 2). No optimizer ever built parameter groups from it, so every parameter trained at training.lr; it had no reader at v0.75.2 either, so a page that said it routed learning rates by pattern was describing a feature that did not run, and v0.76 only warned. Deleting the key changes nothing about what trains. To train the LoRA A and B matrices at different rates use training.loraplus_lr_ratio.

What the schema checked while the key still loaded (through v0.76.x): at most 32 entries, each lr in (0, 1] and finite (NaN and ±inf rejected, bool rejected), duplicates rejected.

Each pattern must compile, and since v0.75.1 it is then checked structurally: the pattern is parsed, and nested or alternating repetition, backreferences and more than three unbounded repeats are refused. The check never runs the pattern. That is the whole point of the change, because the previous guard did run it, against a 128-character probe, which is exactly how a pattern like (a+)+b could hang config loading rather than be caught by it. A guard that executes untrusted input to decide whether executing it is safe is the vulnerability.

LoftQ quantization-aware LoRA init

yaml
training:
  quantization: none       # required: PEFT LoftQ quantizes the base itself
  lora:
    init_strategy: loftq   # random | pissa | olora | loftq
    loftq_iter: 5          # [1, 10]
    loftq_bits: 4          # 2 | 4 | 8

Builds the LoftQ config via peft (lazy import); incompatible with DoRA + VeRA. Through v0.75.2 init_strategy, loftq_iter and loftq_bits reached no trainer, so a run that set them trained plain random-init LoRA (see LoRA quality). Since v0.76.0 (#1037) the strategy is checked at config load: loftq and pissa need quantization: none (the default 4bit is refused, because both compute on the floating-point base weights), and any non-random init_strategy is refused on backend: unsloth and backend: mlx. olora still loads at 4bit. See LoRA quality.

LLaMA Pro block expansion

yaml
training:
  quantization: none            # required with expand_layers
  expand_layers: 4              # [1, 64]
  freeze_trainable_layers: 4    # must equal expand_layers
  lora:
    r: 0                        # required since v0.77.0: a LoRA rank freezes the appended blocks again

Schema landed in v0.41.0 and the block-expansion patch is applied by the SFT trainer. These rules are enforced at config load:

  • freeze_trainable_layers must equal expand_layers (#1409). It is a flag, not a count of layers: it freezes every parameter of the original model and trains only the appended blocks, and it does not select the top-N or bottom-N layers. Any other value, including 0 or a negative one, is refused. Without expand_layers the field is refused too (#1396).
  • expand_layers needs quantization: none (#1237). Under the default 4bit the zeroed residual projections of the appended blocks decode to -absmax rather than 0, so the new blocks are not identity.
  • No LoRA rank (since v0.77.0, #1326, #1783). get_peft_model runs after the block expansion and freezes the appended blocks again, so under LoRA only adapters on the original layers trained while the appended blocks stayed the identity. Set lora.r: 0 with quantization: none; any rank is refused at load, and the default lora.r is 64, so a config with no lora block is refused too.
  • Scope: task: sft, backend: transformers, modality: text. task: pretrain is refused since v0.77.0 (#1813, #1875): its trainer runs the expansion, but it always attaches an adapter, which freezes the new blocks, and it has no lora.r: 0 branch. Any other combination is refused, as before.

Through v0.75.2 the field was read only for its sign: 1, 2 and 4 all trained just the appended blocks, and 0 or a negative value silently trained the whole expanded model. (That held at lora.r: 0. With a LoRA rank, the default, only adapters on the original layers trained and the appended blocks stayed the identity, through v0.76.1; since v0.77.0 that combination is refused, #1783.) A config with expand_layers: N and a different freeze_trainable_layers trained something other than its author expected; see Re-run this. If you trained LLaMA Pro with a LoRA rank, on task: sft or task: pretrain, before v0.77.0, the appended blocks never trained: re-run it on task: sft with lora.r: 0 and quantization: none. The example that stood on this page through v0.76.1 had no lora block, so it was such a config.

Mixture-of-Depths: use_mod

training.use_mod: true installs a per-layer top-k token router; mod_capacity_factor (default 0.125) is the share of tokens that get the residual update. It is validated on Llama, Qwen and Mistral (another architecture warns and skips the patch), and only some routes install the router. Since v0.77.0 every other route is refused at config load, naming training.use_mod, the task and what to change (#1752, #1757):

Configuse_mod: true
task: sft, backend: transformers, modality: text, no layer streaming, lora.r of 1 or more, no LISA, no unfrozen_parametersapplied
task: tts (transformers, lora.r of 1 or more; not tts_family: sesame_csm, which refuses it)applied, through the SFT LoRA arm
task: pretrain, backend: transformers, LoRA or LISAapplied
SFT with vision or audio, stream_layers, LISA, Spectrum or lora.r: 0; backend: unsloth or mlxrefused
any other taskrefused

Through v0.76.1 the flag loaded on every route and only these installed a router, so such a run trained without one. Deleting the line from a refused config changes nothing about what trains. No speed or quality figure is published for it.

Where NEFTune and ReLoRA apply (v0.77.0)

Two more training-signal settings are now refused where they never acted:

  • training.neftune_alpha is applied by nine tasks: sft, tts (not with tts_family: sesame_csm, which refuses it), dpo, ipo, kto, orpo, simpo, bco and preference. On the 14 others it is refused at config load since v0.77.0, any value including 0.0 (#1883); through v0.76.1 it was accepted there and dropped. See NEFTune.
  • training.relora_steps is refused where trl reads the loss's frozen reference from the policy's own base weights: dpo, ipo, kto, bco, grpo with grpo_beta above 0, and a preference run whose loss or blend names dpo, ipo or bco (#1891), because every restart merges the adapter into the weights the reference is read from. See ReLoRA.

Friendly load_in_X aliases

load_in_8bit: true remaps quantization → 8bit. load_in_16bit: true remaps to none. Mutually exclusive. Combining either with gptq, awq, an hqq:* value, aqlm, eetq, mxfp4 or fp8 raises. An explicit quantization: 4bit or 8bit is not checked: the alias replaces it without a message.

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.