Skip to content

Training Stability & Auto-Tuning (v0.32.0)

Pre-flight tuning + in-training stability nets. All flags are opt-in. Not all of them do something at v0.78.0: warmup_auto and convergence_detection are accepted by the schema, but nothing in v0.78.0 reads warmup_auto (it loads with a deprecation warning since v0.78.0) or acts on convergence_detection, the two convergence tunables are refused at load when set away from their defaults, and the loss watchdog, loss-spike hint and VRAM advisory are refused at config load on the tasks and backend that cannot run them (on MLX the watchdog runs on text SFT since v0.77.0; the other two stay refused there). Each section below says which.

LR Range Finder

Run a fast.ai-style geometric LR sweep before the real training run. Soup writes a JSON report with the recommended LR, the loss curve, and the divergence point.

bash
soup train --config soup.yaml \
  --find-lr \
  --find-lr-start 1e-7 \
  --find-lr-end 1e-1 \
  --find-lr-steps 100 \
  --find-lr-output ./lr_finder.json

The report contains the geometric lrs[], raw + EMA-smoothed losses[], the recommended LR (steepest negative gradient before divergence), the LR with min loss, and the divergence point if any.

v0.33.0: --find-lr now runs an in-process LR-sweep training loop. NaN/Inf loss terminates the sweep early so diverged_at is honest.

Since v0.76.0 (#1203) it refuses instead of inventing a curve. If the sweep cannot run at all (the config does not load, the model or dataset cannot be loaded, torch is missing), --find-lr names the cause, exits 1 and writes no report; through v0.75.2 it wrote a placeholder curve and exited 0. The sweep takes one training row per step: with fewer rows than --find-lr-steps it runs one step per row over the same range and says so, and the recommendation needs at least 4 points, so --find-lr-steps must be at least 4 and a training set of fewer than 4 rows is refused before the model loads. If the loss turns non-finite partway through, the report covers the steps before it; if that leaves fewer than 4, the command says where it diverged instead of writing a report. See Training methods.

Warmup (warmup_auto is deprecated, not read)

yaml
training:
  warmup_ratio: 0.03   # 3% of total update steps (default)

warmup_ratio (0.0 to 0.5) sets warmup as a fraction of the optimizer steps the run really executes. Since v0.76.0 (#1431) Soup passes the fraction to the trainer and transformers resolves it as ceil(real_optimizer_steps x warmup_ratio), with no clamp, so a run with fewer than 34 optimizer steps at the default 0.03 gets exactly one warmup step, and that first step trains at learning rate 0. Through v0.75.2 the ratio was turned into a fixed step count from the raw dataset rows before the trainer existed, so a run whose real step count differed (GRPO, where prompts repeat num_generations times; SFT with packing or multipack; pretrain with packing) got a warmup that was too short or covered the whole run; if the learning curve looked flat or never took off on one of those, re-run. warmup_auto: true is accepted by the schema, but nothing in v0.78.0 reads it, so setting it changes nothing about a training run. Since v0.78.0 it loads with a warning, and upstream says v0.79.0 refuses it (#2814): training.warmup_auto: true has no effect: no trainer reads it, and training.warmup_ratio already sets the warmup over the real optimizer steps. Remove the line. Soup v0.79.0 will refuse it. (soup doctor --config exits 0 and prints it; so does soup train.) Delete the line and set warmup_ratio. warmup_auto: false, the default, loads without a message, and soup autopilot writes warmup_auto: false into the config it generates (the decision that would set it is never made, read from the code), so that file loads silently. (Since closed in v0.78.0: through v0.77.2 the key loaded in silence and upstream named no release for refusing it.) A helper that clamps warmup to [10, 1000] steps exists as library code, but no training path and no command calls it, and soup autopilot writes no warmup value.

Auto mixed-precision

yaml
training:
  auto_mixed_precision: true

Picks bf16 on Ampere+, fp16 on Turing or known fp16-stable models (Qwen2 / Qwen2.5 / Phi-3 / Phi-3.5), no on pre-Pascal. Multi-version pairs match the longest substring deterministically.

fp16 on a card that also has bf16 (v0.78.0, #2858, #2921). With auto_mixed_precision: true, an SFT or TTS LoRA run that picks fp16 on a card that also has bf16 (Qwen2, Qwen2.5, Phi-3 and Phi-3.5 on Ampere or newer) loads its unquantized frozen base in fp16, the dtype it trains in, as it already did on a card without bf16. The base used to stay in bf16, so fp16 autocast kept an fp16 copy of every frozen weight through the step, which the VRAM pre-flight did not price. The pick is asked once per run (a 4-bit or 8-bit run prints Auto mixed-precision picked once, not twice), and a quantized base loads and trains as before. Existing runs of this kind, including the sft and tts configs soup autopilot writes for those models, now store the frozen base in fp16 and train with fp16 rather than fp32 hidden states, so they are not bit-comparable with v0.77.2. auto_mixed_precision: false keeps the base in bf16 and computes in bf16 as well: it does not restore the old bf16-storage, fp16-compute state. Upstream's changelog reports one measurement of the memory change on one setup and no benchmarks/ record backs it, so this page prints no figure for it; it is not a speed claim.

Only task: sft reads it, and task: tts, which trains through the SFT trainer. Setting auto_mixed_precision: true on any other task is refused at config load (v0.76.0, #1618): through v0.75.2 a DPO, GRPO or KTO run carrying the key trained at its trainer's default bf16 or fp16 choice with nothing said. It is also refused together with quantization_aware: quest.

Loss spike recovery hint

Builds on the loss watchdog. The watchdog itself stops the run when the loss stays above loss_watchdog_threshold (default 3.0) for loss_watchdog_patience (default 5) consecutive loss reports (one every logging_steps): the comparison is strictly loss > threshold, a report at or below it resets the count, and a report with no loss neither advances nor resets it. loss_spike_recovery does not change that: it makes the watchdog also write a spike_recovery.json hint next to the run output, so that you (or a wrapper script) can relaunch with a lower learning rate.

yaml
training:
  loss_watchdog: true                   # required
  loss_spike_recovery: true
  loss_spike_recovery_max_attempts: 3
  loss_spike_recovery_lr_decay: 0.5

The hint records the loss at the spike, the previous learning rate, a recommended one (the previous rate times loss_spike_recovery_lr_decay), and an attempt counter against loss_spike_recovery_max_attempts. Soup does not decay the learning rate or resume the run by itself: relaunch with the recommended lr and --resume yourself. Since v0.77.0 the hint carries its attempt count across those relaunches: a relaunched run writing to the same output directory reads attempts back from the existing spike_recovery.json at its first spike, keeps counting, and records should_recover: false (printing max attempts N reached) once loss_spike_recovery_max_attempts is used up, so a wrapper script that relaunches on should_recover stops (#1971). Through v0.76.1 nothing read the file back, so each relaunch started again at 1. Within one run the counter advances by one at most, because the run stops on the first firing. Since v0.77.1 the hint is written atomically and a symbolic link at spike_recovery.json is refused (#2169, by @Nari-Ab): the other hard links to the file and the previous hint are kept when a write fails, a failed write does not consume an attempt, and it is logged as a warning instead of stopping the run. Since v0.76.0 every trainer that attaches the live training callback reads loss_spike_recovery (#802): the SFT trainer (and task: tts, which trains through it), pretrain, DPO, IPO, ORPO, SimPO, KTO, BCO, online DPO, GRPO, PPO, reward-model, embedding, classifier (which also serves reranker and cross_encoder), distill and ASR trainers, and so task: preference, which hands off to the paired-loss trainers. Through v0.75.2 only the SFT trainer read it. task: prm, task: unlearn and task: moe_lora_routing attach no live callback, so those three refuse loss_watchdog, loss_spike_recovery and grad_accum_auto_tune at config load, naming the reason (they used to be accepted and never read). backend: mlx refuses loss_spike_recovery and grad_accum_auto_tune, and loss_watchdog everywhere except MLX text SFT, which has a native watchdog since v0.77.0 (see the MLX page). task: tts is not in that refused list: it trains through the SFT trainer, so it reads all three exactly as sft does. On an SFT run, soup rewind can show which dataset rows sat in a step whose loss spiked: see soup rewind.

Convergence detector (accepted, not enforced; its two tunables are refused at load)

yaml
training:
  convergence_detection: true
  convergence_window: 50        # shown at its default: any other value is refused at load
  convergence_rel_tol: 0.005    # shown at its default: any other value is refused at load

These keys are accepted by the schema, but nothing in v0.78.0 acts on them: the only reader is a startup check in soup train that prints a note when convergence_detection is set ("set but not enforced during training in this build"), and no advice is surfaced during a run. The plateau-detection logic that would produce continue / early_stop / lower_lr advice exists as library code that no training path calls. Since v0.77.0 a convergence_window or convergence_rel_tol that differs from its default stops the load (training.convergence_window is accepted but read by nothing; refused as of v0.77. Delete the line., #808; it warned in v0.76), so soup train exits 1 and soup doctor --config exits 2; delete the two tunables. convergence_detection itself still loads, with the soup train note, and upstream names no release for refusing it.

VRAM pressure advisory

yaml
training:
  grad_accum_auto_tune: true
  grad_accum_pressure_threshold: 0.92

Records peak memory each step. When pressure crosses the threshold, recommends a new (batch, accum) pair preserving effective batch (capped at accum=1024). It is an advisory printed once per run on CUDA, not an automatic change (restart with the new pair to take effect). Since v0.76.0 every trainer that attaches the live callback reads grad_accum_auto_tune (task: tts too, through the SFT trainer), and prm, unlearn, moe_lora_routing and backend: mlx refuse it at config load (MLX has no VRAM total to measure pressure against on unified memory; that is unchanged at v0.77.0). Pressure is now the peak allocated memory divided by the total memory of the CUDA device the run uses, read on the first advisory call, and the advisory prints the measured numbers (peak 7.8 of 8.0 GB (97%)). Through v0.75.2 the total was a fixed 24 GB (#1620), so on every card smaller than about 24 GB the advisory could never fire, and on a 40 to 80 GB card it fired at about 22 GB of peak use.

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.