Skip to content
SurogateSurogateDocs
↑↓ to move↵ to openesc to close

Optimizers

Surogate gives you two optimizers: AdamW 8-bit and NorMuon. Both store their state in 8-bit quantized form, which cuts memory use without hurting training stability.

Pick one with the optimizer option (all optimizer keys are in the config reference):

yaml
optimizer: adamw_8bit # Default
# or
optimizer: normuon

AdamW 8-bit is the default. It is standard AdamW with the optimizer states stored in 8-bit blockwise quantization, following the bitsandbytes approach.

AdamW keeps two state tensors per parameter:

  • First moment (m): an exponential moving average of the gradients
  • Second moment (v): an exponential moving average of the squared gradients

Both are quantized to 8-bit with dynamic block quantization and per-block absmax scaling. That makes optimizer state about 4x smaller than in full-precision AdamW, with the same training quality.

Each block of 32 elements keeps two FP32 scales: the largest |m| and the largest √v. Until 2026-11 these scales were FP16. FP16 rounds to 0 below 2.98e-8, and LoRA gradients on long sequences sit below that per coordinate, so a block lost its moments at every step; its updates were too large and no longer followed the gradient. A checkpoint with FP16 scales still loads (the scales widen exactly), but moments it already lost stay lost, and the trainer reports how many blocks are affected. To restart Adam cleanly, load the adapter alone.

The moments are still 8-bit relative to their block’s largest element, so √v resolves down to about 1/510 of that element. With up to 100x spread between neighbours in one block, updates stay within cos 0.98 and 4 % in norm of full-precision Adam. On real LoRA gradients (7 groups of long rows), every update over 100 steps stayed within cos 0.9997 and 0.4 % in norm (integration-tests "[optim][flash]").

The update rule is:

m = β₁ · m + (1 - β₁) · g
v = β₂ · v + (1 - β₂) · g²
p = p - lr · m / (√v + ε) - lr · wd · p
OptionDefaultDescription
learning_rate#2e-4Initial learning rate
adamw_beta1#0.9Exponential decay rate for first moment
adamw_beta2#0.999Exponential decay rate for second moment
adamw_epsilon#1e-8Small constant for numerical stability
weight_decay#0.1Weight decay coefficient (decoupled from gradient)
yaml
optimizer: adamw_8bit
learning_rate: 2e-4
adamw_beta1: 0.9
adamw_beta2: 0.999
adamw_epsilon: 1e-8
weight_decay: 0.1
  • General fine-tuning: it works well for most tasks.
  • LoRA training: it is the recommended choice for adapters.
  • Stability: it copes better with small learning rates and noisy gradients.
  • Familiarity: its behavior is well understood and well researched.

NorMuon (Normalized Momentum with Orthogonalization) applies orthogonalized momentum updates to 2D weight matrices. It is inspired by the Muon optimizer and uses the Polar Express algorithm to orthogonalize matrices efficiently.

NorMuon treats parameters in two groups:

  • 2D weight matrices (attention projections, MLP weights) get orthogonalized momentum updates.
  • 0D/1D parameters (embeddings, layer norms, biases, lm_head) get standard AdamW 8-bit updates.

For each 2D weight, every update runs these steps:

  1. Momentum update: smooth the gradients with an exponential moving average.
  2. Polar Express orthogonalization: map the momentum matrix to its nearest orthogonal matrix with Newton-Schulz iterations.
  3. Variance reduction: apply Adafactor-style adaptive scaling from row and column statistics.
  4. Cautious weight decay: apply weight decay only where the update direction matches the parameter sign.

Orthogonalization keeps the weight matrices well conditioned during training, which can help transformer models converge.

OptionDefaultDescription
learning_rate#2e-4Learning rate for AdamW parameters (embeddings, norms, lm_head)
normuon_momentum#0.95Momentum coefficient (β₁) for NorMuon 2D updates
normuon_beta2#0.95EMA coefficient for variance estimation
normuon_cautious_wd#trueEnable cautious (sign-aware) weight decay
weight_decay#0.1Weight decay coefficient

NorMuon also scales the learning rate by weight shape, √(max(1, rows/cols)), which raises the effective learning rate for weights with more inputs than outputs.

yaml
optimizer: normuon
learning_rate: 2e-4
normuon_momentum: 0.95
normuon_beta2: 0.95
normuon_cautious_wd: true
weight_decay: 0.1
  • Full fine-tuning: it can converge better when you train the whole model.
  • Pre-training: it was designed for training transformers from scratch.
  • Large models: the benefit of orthogonalization grows with model size.
  • Multi-GPU training: it works with data-parallel training.

With normuon_cautious_wd on (the default), weight decay applies only where the update direction agrees with the parameter sign:

mask = sign(update) == sign(param)
p = p - lr · wd · p · mask - lr · update

Weight decay then never pulls against the gradient direction, which can make training more stable.


These options apply to both optimizers:

OptionDefaultDescription
max_grad_norm#0.0Maximum gradient norm for clipping (0 = disabled)
gradient_accumulation_steps#4Number of micro-steps before optimizer update
warmup_steps#0Linear warmup steps from 0 to learning_rate
warmup_ratio#0.0Warmup as fraction of total steps
lr_scheduler_type#linearLearning rate schedule: linear, cosine, or wsd
cooldown_steps#0Linear cooldown steps at end of training
final_lr_fraction#0.0Final LR as fraction of initial (for cooldown)

Both optimizers keep 8-bit states, which take roughly:

  • AdamW 8-bit: 2.25 bytes per parameter (1 byte for m, 1 byte for v, two FP32 scales per 32 parameters)
  • NorMuon: ~2 bytes per parameter for 2D weights, ~2 bytes per parameter for AdamW-managed parameters

NorMuon needs some extra memory on top:

  • Variance buffers: O(max(rows, cols)) per 2D weight tensor
  • Polar Express workspace: temporary buffers for the matrix operations

If memory is tight:

  • Set offload_optimizer: true to keep optimizer state in pinned host memory (see Offloading).
  • Increase gradient_accumulation_steps to reduce activation memory.

AspectAdamW 8-bitNorMuon
Memory~2 bytes/param~2 bytes/param + workspace
SpeedFaster~15% slower due to orthogonalization
StabilityVery stableStable with proper hyperparameters
Best forLoRA, general fine-tuningFull fine-tuning, pre-training

Both optimizers work with data-parallel multi-GPU training. Gradients are synchronized across GPUs before the optimizer step, and with ZeRO each GPU holds its own shard of the optimizer state.

To train on several GPUs:

yaml
gpus: 4 # Number of GPUs to use
zero_level: 1 # ZeRO optimization level (1, 2, or 3)