soup/soup_cli/utils
Alpamys 1f050fc235 feat(v0.40.3): Stub-to-live wave 1 (#33, #64; #65 still deferred)
Three v0.X.0 deferred-stub features become live runtime — closes #33
(harvester judge filter + serve trace log) and #64 (live CUDA OOM probe).
#65 (multipack live wiring in HF Trainer) remains deferred to v0.40.4
after the adversarial 5th-review pass surfaced a Sampler[int] vs
list[list[int]] shape mismatch with HF Trainer's DataLoader; helpers
(`make_multipack_trainer_class`, `attach_multipack_state`,
`lengths_from_dataset`, `detect_arch_name`) ship as a stub used by
unit tests, but the SFT/Pretrain wrappers print a yellow advisory and
fall back to the standard sampler when `multipack: true`.

Live CUDA OOM probe (#64): `make_cuda_probe_fn` builds a closure that
runs ONE forward+backward+step on a synthetic batch per candidate.
`model.zero_grad(set_to_none=True)` runs BEFORE forward; intermediate
ids/attn/labels/outputs are del-ed before `loss.backward()` so peak
VRAM reflects a realistic training step (matches v0.35.0 #45 policy).
`pad_id` is bounded by `len(tokenizer)` (not `vocab_size`) so extended
vocabs (Llama-3 + `<|pad|>`) don't fold pad to a random byte token.
SFT-only this release.

Trace-to-Preference judge filter (#33 (a)): `judge_filter_pairs` reuses
v0.19.0 JudgeEvaluator backends (openai/server/ollama). Threshold
rejects bool/NaN/out-of-[0,1]; `_MAX_BATCH=100_000` cap applied via
lazy `itertools.islice`; per-pair backend exceptions caught and DEBUG-
logged (matches v0.33.0 #47 policy); `judge_provider` validated against
the allowlist at the CLI boundary BEFORE constructor with a Rich-escape
error message; yellow projected-call-count warning before the loop
(2× per pair).

Inference Server trace log (#33 (b)): `TraceLogWriter` is thread-safe
(single-process lock — multi-worker documented as known limitation);
path containment via shared `is_under_cwd`; null-byte/empty/non-string
path rejected; cap_mb bounds [1, 10000] with explicit bool rejection.
Rotation (one backup retained) refuses symlink at the backup path via
`os.lstat + stat.S_ISLNK` (matches v0.33.0 #22 TOCTOU policy). Secret
redaction (`hf_*` ≥8, `sk-*` ≥16, `Bearer …` ≥8 with `.` excluded so
end-of-sentence period survives) applied to prompt + response and
recursively to caller-supplied `extra` dict values. Streaming SSE path
also records (was a coverage gap caught in adversarial review).

Behaviour change: v0.40.2 users with `auto_batch_size_strategy: probe`
were silently getting the static fallback. v0.40.3 actually runs a
CUDA probe on first run (~5–30s, cached per (model, max_length, quant,
lora_r, gpu) tuple).

Reviews: 5 agents (python, code, security, tdd, verification-loop).
Verification-loop run twice — once shallow smoke (PASS), once
adversarial bug-hunt which found C1/C2 (multipack live wiring crash —
demoted to v0.40.4), H1 (streaming SSE missing trace log — fixed),
H4 (vocab_size vs len(tokenizer) on extended vocabs — fixed), H3
(Bearer regex consumed trailing period — fixed), H2 (judge cost
shock — warning added), M2 (empty lengths accepted — rejected), L1
(extra dict bypassed redaction — recursive walk added).

Tests: 4756 → 4855 (+99 net new) across test_v0403_part_a/b/c.py.
Lint clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 16:02:45 +05:00
..
__init__.py Initial project setup: CLI skeleton + config + trainer + data pipeline 2026-02-20 16:14:56 +05:00
activation_offload.py feat(training): Training Speed & Memory — CCE, FP8, grad-ckpt tiers, kernel picker, cross-doc attn, activation offload (v0.28.0) 2026-04-22 22:51:15 +05:00
auto_quant.py feat(trainers): v0.35.0 — Trainer Coverage (closes #60, #61, #45) 2026-04-28 15:01:42 +05:00
batch_probe.py feat(v0.40.3): Stub-to-live wave 1 (#33, #64; #65 still deferred) 2026-05-08 16:02:45 +05:00
constants.py feat: add GitHub repo link to CLI output, bump version to v0.17.3 2026-03-26 15:48:04 +05:00
convergence.py feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
crash.py feat(observability): v0.34.0 — Observability & Dev UX (7 Parts) 2026-04-28 13:14:49 +05:00
cross_doc_attn.py feat(training): Training Speed & Memory — CCE, FP8, grad-ckpt tiers, kernel picker, cross-doc attn, activation offload (v0.28.0) 2026-04-22 22:51:15 +05:00
curriculum.py feat: v0.23.0 — AWQ/GPTQ Export, Sample Packing, Data Split, Curriculum Learning 2026-04-03 13:55:01 +05:00
cut_ce.py feat(training): Training Speed & Memory — CCE, FP8, grad-ckpt tiers, kernel picker, cross-doc attn, activation offload (v0.28.0) 2026-04-22 22:51:15 +05:00
deepspeed.py feat(v0.27.0): Multi-GPU Mastery — topology, ZeRO++, FSDP2+compile, MII, PP, recipes 2026-04-21 14:54:34 +05:00
dpo_variants.py feat(preference): v0.40.0 — Preference Variety (4 Parts: BCO + dispatcher + DPO variants + multi-objective) 2026-05-01 22:26:30 +05:00
encoding.py fix(v0.40.1): QA Hardening — UTF-8 bootstrap, schema strictness, multi-objective preference runtime, CLI UX 2026-05-08 12:03:16 +05:00
errors.py v0.10.3: Fix PPO trl >=0.28 API compat, improve GRPO CPU error message 2026-03-24 14:27:39 +05:00
flash_attn.py fix: rename APIs to match test plan, fix RoPE factor detection 2026-03-26 15:14:24 +05:00
fp8.py feat(fp8): add rowwise and rowwise_with_gw_hp scaling recipes for FP8 training (#62) 2026-04-28 20:16:43 +05:00
freeze.py feat: v0.24.0 — Dataset Hub, Freeze Training, Loss Watchdog, Dataset Registry 2026-04-03 16:35:23 +05:00
fsdp.py feat(v0.27.0): Multi-GPU Mastery — topology, ZeRO++, FSDP2+compile, MII, PP, recipes 2026-04-21 14:54:34 +05:00
galore.py v0.12.0: ORPO/SimPO/IPO trainers + DoRA/LoRA+/GaLore 2026-03-25 18:12:36 +05:00
gpu.py v0.10.1: Fix 6 bugs from manual testing report 2026-03-24 12:31:37 +05:00
grad_accum.py feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
gradient_ckpt.py feat(speed,memory): v0.28.0 features go multi-trainer (v0.33.0 Part C) 2026-04-27 18:55:50 +05:00
hf.py feat(hf): v0.29.0 — HuggingFace Hub Deep Integration 2026-04-23 16:17:28 +05:00
hf_space.py feat(v0.40.2): Quick polish + v0.40.1 carry-overs (#36, #50, #51 + 7 papercuts) 2026-05-08 13:20:21 +05:00
jinja_analyzer.py feat(multipack): v0.37.0 — Multipack (5 Parts A/B/C/D/E) 2026-04-30 13:48:16 +05:00
kernel_picker.py feat(trainers): v0.35.0 — Trainer Coverage (closes #60, #61, #45) 2026-04-28 15:01:42 +05:00
launcher.py feat(v0.27.0): Multi-GPU Mastery — topology, ZeRO++, FSDP2+compile, MII, PP, recipes 2026-04-21 14:54:34 +05:00
liger.py fix: rename APIs to match test plan, fix RoPE factor detection 2026-03-26 15:14:24 +05:00
log_level.py feat(v0.40.2): Quick polish + v0.40.1 carry-overs (#36, #50, #51 + 7 papercuts) 2026-05-08 13:20:21 +05:00
long_context.py fix: rename APIs to match test plan, fix RoPE factor detection 2026-03-26 15:14:24 +05:00
lr_finder.py fix(v0.33.0): review-wave findings (CRITICAL + HIGH + MEDIUM + LOW) 2026-04-27 19:57:57 +05:00
metrics.py feat(inference): v0.30.0 — Inference Excellence 2026-04-24 23:39:04 +05:00
mii.py fix(v0.33.0): review-wave findings (CRITICAL + HIGH + MEDIUM + LOW) 2026-04-27 19:57:57 +05:00
mixed_precision.py feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
mlx.py feat(v0.25.0): Beyond the Wrapper — 8 major features 2026-04-13 12:58:11 +05:00
moe.py feat: v0.14.0 — pre-training + MoE support 2026-03-25 22:26:01 +05:00
multipack.py feat(multipack): v0.37.0 — Multipack (5 Parts A/B/C/D/E) 2026-04-30 13:48:16 +05:00
multipack_sampler.py feat(multipack): v0.37.0 — Multipack (5 Parts A/B/C/D/E) 2026-04-30 13:48:16 +05:00
multipack_trainer.py feat(v0.40.3): Stub-to-live wave 1 (#33, #64; #65 still deferred) 2026-05-08 16:02:45 +05:00
neat_packing.py feat(multipack): v0.37.0 — Multipack (5 Parts A/B/C/D/E) 2026-04-30 13:48:16 +05:00
ollama.py feat: add Ollama integration — deploy GGUF models in one command (v0.18.0) 2026-04-01 13:47:40 +05:00
paths.py feat(v0.26.0): Parts B-E — Eval Gate, Trace-to-Pref, Quant-Check, Soup Cans 2026-04-20 21:37:05 +05:00
peft_builder.py feat(lora): v0.39.0 — LoRA Quality (PiSSA + ReLoRA + per-pattern rank + surgical patches + templates registry) 2026-05-01 16:18:07 +05:00
peft_patches.py feat(lora): v0.39.0 — LoRA Quality (PiSSA + ReLoRA + per-pattern rank + surgical patches + templates registry) 2026-05-01 16:18:07 +05:00
pipeline.py feat(v0.27.0): Multi-GPU Mastery — topology, ZeRO++, FSDP2+compile, MII, PP, recipes 2026-04-21 14:54:34 +05:00
preference_combine.py fix(v0.40.1): QA Hardening — UTF-8 bootstrap, schema strictness, multi-objective preference runtime, CLI UX 2026-05-08 12:03:16 +05:00
profiler.py fix: v0.24.1 — Windows Unicode fix, AWQ/GPTQ output path traversal 2026-04-03 23:41:44 +05:00
profiling.py feat(observability): v0.34.0 — Observability & Dev UX (7 Parts) 2026-04-28 13:14:49 +05:00
qat.py Add Quantization-Aware Training support (Phase 7) — v0.6.0 2026-03-23 20:35:35 +05:00
quality.py fix: rename APIs to match test plan, fix RoPE factor detection 2026-03-26 15:14:24 +05:00
quant_menu.py feat(quant): v0.38.0 — Quant Menu (8 Parts: A-H) 2026-05-01 13:31:49 +05:00
registry.py feat: v0.24.0 — Dataset Hub, Freeze Training, Loss Watchdog, Dataset Registry 2026-04-03 16:35:23 +05:00
relora.py feat(lora): v0.39.0 — LoRA Quality (PiSSA + ReLoRA + per-pattern rank + surgical patches + templates registry) 2026-05-01 16:18:07 +05:00
replay.py feat(observability): v0.34.0 — Observability & Dev UX (7 Parts) 2026-04-28 13:14:49 +05:00
ring_attention.py fix: rename APIs to match test plan, fix RoPE factor detection 2026-03-26 15:14:24 +05:00
run_cost.py feat(observability): v0.34.0 — Observability & Dev UX (7 Parts) 2026-04-28 13:14:49 +05:00
sglang.py fix: rename APIs to match test plan, fix RoPE factor detection 2026-03-26 15:14:24 +05:00
spec_pairing.py feat(inference): v0.30.0 — Inference Excellence 2026-04-24 23:39:04 +05:00
spike_recovery.py feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
structured_output.py feat(serve): structured-output + auto-quant live (v0.33.0 Part D) 2026-04-27 18:43:07 +05:00
topology.py feat(v0.27.0): Multi-GPU Mastery — topology, ZeRO++, FSDP2+compile, MII, PP, recipes 2026-04-21 14:54:34 +05:00
tracing.py feat(inference): v0.30.0 — Inference Excellence 2026-04-24 23:39:04 +05:00
trust_remote.py feat(correctness): v0.36.0 — Correctness First (4 Parts: A/B/C/D) 2026-04-30 11:52:51 +05:00
unsloth.py Add Unsloth backend for 2-5x faster training (Phase 5) — v0.4.3 2026-03-23 16:55:44 +05:00
v028_features.py feat(preference): v0.40.0 — Preference Variety (4 Parts: BCO + dispatcher + DPO variants + multi-objective) 2026-05-01 22:26:30 +05:00
vllm.py feat(trainers): v0.35.0 — Trainer Coverage (closes #60, #61, #45) 2026-04-28 15:01:42 +05:00
warmup.py feat(training): v0.32.0 — Training Stability & Auto-Tuning 2026-04-26 15:24:31 +05:00
why.py feat(observability): v0.34.0 — Observability & Dev UX (7 Parts) 2026-04-28 13:14:49 +05:00