soup/soup_cli
Alpamys e406688f2d feat(training): stability auto-tuning live (v0.33.0 Part E)
Closes #56, #57, #58, #59.

#56 Live --find-lr in-process LR-sweep:
- New utils/lr_finder.run_lr_sweep(model, dataloader, schedule,
  optimizer_factory, device): per-step LR mutation + forward + backward,
  records loss until exhaustion or NaN/Inf divergence.
- commands/train.py wires it via _live_lr_sweep_from_config (loads model
  + tokenizer + first N rows of cfg.data.train), with synthetic-curve
  fallback so users without GPU/torch still get a parseable report.

#57 Loss-spike recovery hint:
- SoupTrainerCallback gains spike_recovery / spike_recovery_max_attempts
  / spike_recovery_lr_decay; on watchdog fire writes
  output_dir/spike_recovery.json with previous_lr, recommended_lr (per
  SpikeRecoveryStrategy.compute_new_lr), should_recover, attempts. A
  wrapper / re-launch can resume with the decayed LR. Live optimizer
  rewind is intentionally NOT done — HF Trainer has no safe public API
  for mid-loop optimizer-state mutation; the JSON hint is the contract.

#58 auto_mixed_precision push to TrainingArguments:
- New SFTTrainerWrapper._resolve_mixed_precision: when
  tcfg.auto_mixed_precision is True, queries torch.cuda compute
  capability and calls pick_mixed_precision(base, cc) to set
  bf16=/fp16= flags. CPU short-circuits to (False, False). When the
  flag is False, legacy default preserved (bf16=cuda).

#59 Grad-accum advisory (Phase 1):
- SoupTrainerCallback gains grad_accum_auto_tune /
  grad_accum_pressure_threshold / grad_accum_total_vram_gb /
  grad_accum_current_steps / grad_accum_current_batch.
- on_log samples torch.cuda.max_memory_allocated each step; if
  GradAccumMonitor.should_adjust crosses the threshold once,
  prints (batch, accum) -> (new_batch, new_accum) advisory and
  short-circuits (one-shot). Phase 2 (live DataLoader rebuild)
  needs a small TRL upstream PR — tracked as a known limitation.

Wiring:
- soup_cli/trainer/sft.py: _resolve_mixed_precision helper, batch_size
  preserved on self, SoupTrainerCallback constructor passes through new
  spike + grad-accum knobs.
- soup_cli/monitoring/callback.py: rich Console import added (was
  previously module-relative); spike + grad-accum state fields and
  one-shot helpers.

Tests: +15 in tests/test_part_e.py covering the LR-sweep loop with
mocked model + optimizer (records, divergence break), mixed-precision
resolver across cpu/cuda + auto-flag combinations + qwen2 fp16 quirk on
Ampere, spike recovery hint write + attempts increment + disabled
no-op, grad-accum advisory one-shot semantics + threshold + cuda-absent
+ disabled.

Known limitations (release notes):
- #57 spike recovery is a JSON hint, not in-process optimizer rewind
- #59 Phase 2 (live DataLoader rebuild on advisory) deferred

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 18:33:39 +05:00
..
autopilot feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
cans feat(cans): soup can run + publish (v0.33.0 Part A wave 2) 2026-04-27 18:19:39 +05:00
commands feat(training): stability auto-tuning live (v0.33.0 Part E) 2026-04-27 18:33:39 +05:00
config feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
data feat(v0.26.0): Parts B-E — Eval Gate, Trace-to-Pref, Quant-Check, Soup Cans 2026-04-20 21:37:05 +05:00
eval feat(eval,registry): live gate scoring + registry attach (v0.33.0 Part A wave 1) 2026-04-27 18:06:27 +05:00
experiment feat(v0.25.0): Beyond the Wrapper — 8 major features 2026-04-13 12:58:11 +05:00
migrate feat: v0.21.0 — migrate, recipes, NEFTune, rsLoRA 2026-04-02 14:08:36 +05:00
monitoring feat(training): stability auto-tuning live (v0.33.0 Part E) 2026-04-27 18:33:39 +05:00
recipes feat(recipes): v0.31.0 — Model & Recipe Breadth 2026-04-25 19:03:23 +05:00
registry feat(eval,registry): live gate scoring + registry attach (v0.33.0 Part A wave 1) 2026-04-27 18:06:27 +05:00
trainer feat(training): stability auto-tuning live (v0.33.0 Part E) 2026-04-27 18:33:39 +05:00
ui fix(security): apply escapeHtml to all server-supplied innerHTML injections 2026-04-07 19:56:51 +05:00
utils feat(training): stability auto-tuning live (v0.33.0 Part E) 2026-04-27 18:33:39 +05:00
__init__.py feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
__main__.py Add Phase 3.1: friendly errors, soup doctor, soup quickstart, UX polish (v0.3.1) 2026-03-05 19:10:36 +05:00
cli.py Feature: add "soup cost" command for cloud GPU training cost estimation (#42) 2026-04-22 23:11:14 +05:00