Optimizer Zoo (v0.41.0)

A closed allowlist of 32 optimizers covering HF-native (10), bitsandbytes-backed (8) and the v0.41 additions (14).

Supported optimizers

HF-native: adamw_torch, adamw_torch_fused, adafactor, sgd, and the rest of the HF set.

bitsandbytes-backed: adamw_bnb_8bit, paged_adamw_8bit, lion_8bit, etc.

New in v0.41:

  • BAdam — block-coordinate descent for full-parameter fine-tuning
  • APOLLO (apollo_adamw) — gradient-scaled training in low rank
  • Adam-mini — half the optimizer memory of AdamW
  • lomo / adalomo — low-memory optimization with optional adaptive scaling
  • grokadamw — Grokfast-style AdamW
  • schedule_free_adamw / schedule_free_sgd
  • muon, dion, came_pytorch
  • TorchAO ao_adamw_fp8 / ao_adamw_4bit / ao_adamw_8bit
yaml
training:
  optimizer: muon

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.

Per-module LR groups

Map regex patterns → learning rates with first-match-wins routing.

yaml
training:
  lr: 2e-4   # base / fallback
  lr_groups:
    - { pattern: "model\\.embed_tokens", lr: 5e-5 }
    - { pattern: ".*lora_A.*", lr: 1e-3 }
    - { pattern: ".*lora_B.*", lr: 1e-3 }

Capped at 32 entries. Each lr ∈ (0, 1], finite-only (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:
  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.

LLaMA Pro block expansion

yaml
training:
  expand_layers: 4              # [1, 64]
  freeze_trainable_layers: 32   # required when expand_layers set

Schema landed in v0.41.0 and the block-expansion patch is applied live by the SFT and pretrain trainers.

Friendly load_in_X aliases

load_in_8bit: true remaps quantization → 8bit. load_in_16bit: true remaps to none. Mutually exclusive. Combining either with an explicit Quant Menu format raises rather than silently overriding.

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.