soup/soup_cli/utils
Alpamys 7da82d355a feat(adapters): v0.57.0 — git for LoRA (diff, merge, blame, branch)
Ships "soup adapters {diff,merge,blame,branch,checkout,branches}" — git-shaped
UX for LoRA adapter management. Pure-numpy math (no torch); TOCTOU defence on
every path; atomic writes throughout.

Part A — adapters diff (utils/adapter_diff.py, ~270 LOC):
  Per-layer ΔW Frobenius norm + relative drift; effective-rank delta via
  SVD entropy; top-K changed projections; JSON/Markdown/table output.

Part B — adapters merge (utils/adapter_merge.py, ~280 LOC):
  Four strategies — linear (weighted avg), ties (Yadav et al. — trim/
  elect-sign/disjoint), dare (Yu et al. — drop+rescale, deterministic),
  svd (low-rank reconstruction). MergeReport.verdict='UNKNOWN' is a stub;
  live canary verdict via v0.55 eval gate ships in v0.57.1.

Part C — adapters blame (utils/blame.py, ~190 LOC):
  Leave-one-out plan emitter + budget tracker (parse_budget mirrors v0.48.0
  data_mix idiom). Per-shard work table + feasibility check. Live ablation
  runner raises NotImplementedError v0.57.1 (mirrors v0.27.0 / v0.50.0 /
  v0.56.0 stub-then-live pattern).

Part D — adapters branch / checkout / branches (utils/adapter_branch.py,
~230 LOC):
  SHA-256 snapshot pointers under ~/.soup/branches/ (SOUP_BRANCHES_DIR
  override, $HOME/$CWD/$TMPDIR-bounded). Drift detection on checkout —
  refuses restore when source SHA != snapshot SHA. CRLF/null-byte
  rejection on env override (mirrors v0.51.0 hub-endpoint policy).

5-agent review-fix wave (1 CRITICAL + 9 HIGH + 11 MEDIUM + 4 LOW):
  - TIES tied-sign defaults to +1 (np.sign(0)==0 would silently zero all
    tied parameters)
  - load_branch / delete_branch reject symlinks via os.lstat + S_ISLNK
    before read/unlink
  - merge output safetensors + adapter_config.json atomic writes with
    symlink target rejection at output path; source config size-capped
    at 256 KB
  - compute_adapter_diff weights-file path symlink-rejected via lstat
    BEFORE is_file() (defends against .safetensors -> /etc/passwd escape)
  - _count_dataset_rows opens via realpath captured at containment check
    (closes TOCTOU window)
  - diff --output write is atomic (tempfile + os.replace)
  - SOUP_BRANCHES_DIR rejects every C0 control char, not just null
  - SUPPORTED_STRATEGIES is now frozenset (matches v0.41.0+ allowlist
    policy); STRATEGY_ORDER tuple preserved for canonical iteration
  - 5× pytest.raises(Exception) tightened to FrozenInstanceError
  - 2 zero-assertion Part D tests converted to real assertions
  - Added: bool base_model rejection, top_k boundary 1/201, density=1.0
    inclusive bound, inf weight rejection, tied-sign positive default,
    bool False for num_shards/budget_seconds, POSIX symlink rejections
    for diff weights / merge output / load_branch / delete_branch,
    no-top-level-torch source-grep guards, traversal delete_branch.

Plus v0.56.0 follow-up: test_v0560.py version-floor tests widened from
exact-match to floor-check (matches v0.51.0 / v0.54.0 idiom — every
subsequent release would otherwise edit this one line).

Test count: 8849 → 8998 (+149 net in 4 new files; 4 POSIX-only symlink
tests skipped on Windows). Full suite green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 18:37:14 +05:00
..
diagnose feat(diagnose): soup diagnose — post-training model report card (v0.56.0) 2026-05-15 15:03:00 +05:00
__init__.py Initial project setup: CLI skeleton + config + trainer + data pipeline 2026-02-20 16:14:56 +05:00
_eval_text.py feat(eval): soup eval design — derive evals from data (v0.55.0) 2026-05-15 12:44:14 +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
adapter_branch.py feat(adapters): v0.57.0 — git for LoRA (diff, merge, blame, branch) 2026-05-15 18:37:14 +05:00
adapter_diff.py feat(adapters): v0.57.0 — git for LoRA (diff, merge, blame, branch) 2026-05-15 18:37:14 +05:00
adapter_merge.py feat(adapters): v0.57.0 — git for LoRA (diff, merge, blame, branch) 2026-05-15 18:37:14 +05:00
advanced_precision.py feat(v0.53.0): Quant Menu II — UD GGUFs + KV cache + NVFP4 + LF parity + save formats 2026-05-12 14:31:26 +05:00
advise.py feat(advise): soup advise — pre-flight decision (v0.54.0) 2026-05-14 21:48:19 +05:00
advise_history.py feat(advise): soup advise — pre-flight decision (v0.54.0) 2026-05-14 21:48:19 +05:00
agent_forge.py feat(agent): Agent Forge — OpenAPI/MCP/GraphQL spec → tool-calling SFT dataset (v0.46.0 Part B) 2026-05-11 17:12:13 +05:00
agent_rollout.py feat(grpo): v0.50.0 — GRPO Plus (unsloth + axolotl RL parity) 2026-05-12 00:30:43 +05:00
anthropic_messages.py feat(v0.45.0): Plugin System & Ecosystem Wins — 5 Parts, +169 tests 2026-05-10 21:21:04 +05:00
auto_quant.py feat(trainers): v0.35.0 — Trainer Coverage (closes #60, #61, #45) 2026-04-28 15:01:42 +05:00
backend_detect.py feat(v0.53.9): Live Dashboard + UX + Bench + Standalone CLIs 2026-05-14 04:28:19 +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
bitnet.py feat(v0.52.0): Modality II — TTS + Distillation + BitNet + EBFT-GDPO + MoE quant + reasoning_effort 2026-05-12 13:38:01 +05:00
blame.py feat(adapters): v0.57.0 — git for LoRA (diff, merge, blame, branch) 2026-05-15 18:37:14 +05:00
block_expansion.py feat(longctx): v0.53.4 — Long Context + Architecture 2026-05-13 14:52:10 +05:00
canary_discovery.py feat(eval): soup eval design — derive evals from data (v0.55.0) 2026-05-15 12:44:14 +05:00
checkpoint_trigger.py fix(v0.44.0): write_trigger lstat unresolved path so symlink at trigger is detected 2026-05-10 19:28:02 +05:00
classifier.py feat(modality): v0.53.2 — lift Modality II stubs (distill + classifier + EBFT/GDPO + reasoning_effort) 2026-05-13 12:56:50 +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
curriculum_dynamic.py feat(adaptive): v0.53.5 — Adaptive Training (BETA → stable) 2026-05-13 15:55:28 +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
data_forge.py feat(v0.53.7): Data Forge + Pipeline live (wave 1) — 11 items 2026-05-13 19:28:11 +05:00
data_mix.py feat(v0.53.10): Quick wins + packaging + UX wiring 2026-05-14 13:58:20 +05:00
data_pipeline.py fix(test): v0.53.7 CI hardening — importorskip(fastapi) + Arrow target setup 2026-05-13 19:45:21 +05:00
data_score.py feat(v0.53.10): Quick wins + packaging + UX wiring 2026-05-14 13:58:20 +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
delinearize_llama4.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
demo_bundles.py feat(v0.53.8): Remote data + Hubs + Trackers (wave 2) — 6 features 2026-05-13 23:55:23 +05:00
deploy_autopilot.py feat(deploy): On-Device Deploy Autopilot — 10-profile catalog + recipe/script writer (v0.46.0 Part A) 2026-05-11 17:11:36 +05:00
deploy_measure.py feat(v0.53.1): Quant Menu II + Export pipeline live 2026-05-13 00:16:03 +05:00
distill.py feat(modality): v0.53.2 — lift Modality II stubs (distill + classifier + EBFT/GDPO + reasoning_effort) 2026-05-13 12:56:50 +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
ebft_gdpo.py feat(modality): v0.53.2 — lift Modality II stubs (distill + classifier + EBFT/GDPO + reasoning_effort) 2026-05-13 12:56:50 +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 feat(longctx): v0.53.4 — Long Context + Architecture 2026-05-13 14:52:10 +05:00
eval_design.py feat(eval): soup eval design — derive evals from data (v0.55.0) 2026-05-15 12:44:14 +05:00
eval_gate_hook.py feat(eval): soup eval design — derive evals from data (v0.55.0) 2026-05-15 12:44:14 +05:00
eval_lock_coverage.py feat(eval): soup eval design — derive evals from data (v0.55.0) 2026-05-15 12:44:14 +05:00
fetch_examples.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
flash_attn.py feat(longctx): v0.53.4 — Long Context + Architecture 2026-05-13 14:52:10 +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
fsdp_consolidate.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
galore.py v0.12.0: ORPO/SimPO/IPO trainers + DoRA/LoRA+/GaLore 2026-03-25 18:12:36 +05:00
gguf_quant.py feat(v0.53.1): Quant Menu II + Export pipeline live 2026-05-13 00:16:03 +05:00
gpu.py v0.10.1: Fix 6 bugs from manual testing report 2026-03-24 12:31:37 +05:00
gpu_monitor.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
graceful_save.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +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
grpo_long_context.py feat(grpo): v0.50.0 — GRPO Plus (unsloth + axolotl RL parity) 2026-05-12 00:30:43 +05:00
grpo_variants.py feat(v0.53.11): GRPO Plus finish + preference live 2026-05-14 15:40:34 +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.53.8): Remote data + Hubs + Trackers (wave 2) — 6 features 2026-05-13 23:55:23 +05:00
hubs.py feat(v0.53.10): Quick wins + packaging + UX wiring 2026-05-14 13:58:20 +05:00
integrations.py feat(v0.45.0): Plugin System & Ecosystem Wins — 5 Parts, +169 tests 2026-05-10 21:21:04 +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
kv_cache.py feat(v0.53.0): Quant Menu II — UD GGUFs + KV cache + NVFP4 + LF parity + save formats 2026-05-12 14:31:26 +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
llama_proxy.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
llama_server_timings.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
loftq_init.py feat(trainer): Optimizer & PEFT Zoo (v0.41.0) 2026-05-10 15:35:35 +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 feat(longctx): v0.53.4 — Long Context + Architecture 2026-05-13 14:52:10 +05:00
longlora.py feat(v0.53.11): GRPO Plus finish + preference live 2026-05-14 15:40:34 +05:00
lr_finder.py fix(v0.33.0): review-wave findings (CRITICAL + HIGH + MEDIUM + LOW) 2026-04-27 19:57:57 +05:00
lr_groups.py feat(trainer): Optimizer & PEFT Zoo (v0.41.0) 2026-05-10 15:35:35 +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
mix_proxy.py feat(adaptive): v0.53.5 — Adaptive Training (BETA → stable) 2026-05-13 15:55:28 +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
moe_quant.py feat(v0.52.0): Modality II — TTS + Distillation + BitNet + EBFT-GDPO + MoE quant + reasoning_effort 2026-05-12 13:38: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(catalog): v0.51.0 — Model Catalog Expansion + Alternative Hubs 2026-05-12 12:05:04 +05:00
multipack_trainer.py feat(trainer): multipack live HF Trainer DataLoader override (v0.40.4 Part B) 2026-05-09 13:20:47 +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
ngram_spec.py feat(v0.45.0): Plugin System & Ecosystem Wins — 5 Parts, +169 tests 2026-05-10 21:21:04 +05:00
nlg_metrics.py feat(eval): Tracker & Eval Pro — 18 features (v0.43.0) 2026-05-10 18:04:40 +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
onboarding.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
optimizer_zoo.py feat(trainer): Optimizer & PEFT Zoo (v0.41.0) 2026-05-10 15:35:35 +05:00
paths.py feat(v0.53.1): Quant Menu II + Export pipeline live 2026-05-13 00:16:03 +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
peft_wiring.py feat(v0.53.11): GRPO Plus finish + preference live 2026-05-14 15:40:34 +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 feat(v0.53.11): GRPO Plus finish + preference live 2026-05-14 15:40:34 +05:00
prm.py feat(v0.53.11): GRPO Plus finish + preference live 2026-05-14 15:40:34 +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
profiling_v0_43.py feat(eval): Tracker & Eval Pro — 18 features (v0.43.0) 2026-05-10 18:04:40 +05:00
qat.py Add Quantization-Aware Training support (Phase 7) — v0.6.0 2026-03-23 20:35:35 +05:00
qr_url.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +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
reasoning_effort.py feat(modality): v0.53.2 — lift Modality II stubs (distill + classifier + EBFT/GDPO + reasoning_effort) 2026-05-13 12:56:50 +05:00
reasoning_parser.py feat(v0.53.9): Live Dashboard + UX + Bench + Standalone CLIs 2026-05-14 04:28:19 +05:00
recipe_dag.py feat(v0.45.0): Plugin System & Ecosystem Wins — 5 Parts, +169 tests 2026-05-10 21:21:04 +05:00
recipe_run.py fix(test): v0.53.7 CI hardening — importorskip(fastapi) + Arrow target setup 2026-05-13 19:45:21 +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
save_formats.py feat(v0.53.1): Quant Menu II + Export pipeline live 2026-05-13 00:16:03 +05:00
server_tools.py feat(v0.45.0): Plugin System & Ecosystem Wins — 5 Parts, +169 tests 2026-05-10 21:21:04 +05:00
sglang.py fix: rename APIs to match test plan, fix RoPE factor detection 2026-03-26 15:14:24 +05:00
shortcuts.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +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
sse_train_stream.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +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
sweep_config.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
tail_latency.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +05:00
tool_outputs.py feat(v0.53.9): Live Dashboard + UX + Bench + Standalone CLIs 2026-05-14 04:28:19 +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
trackers.py feat(v0.53.10): Quick wins + packaging + UX wiring 2026-05-14 13:58:20 +05:00
train_event_buffer.py feat(v0.53.9): Live Dashboard + UX + Bench + Standalone CLIs 2026-05-14 04:28:19 +05:00
trainer_plugins.py feat(v0.53.7): Data Forge + Pipeline live (wave 1) — 11 items 2026-05-13 19:28:11 +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
tts.py feat(v0.52.0): Modality II — TTS + Distillation + BitNet + EBFT-GDPO + MoE quant + reasoning_effort 2026-05-12 13:38:01 +05:00
ui_env.py feat(v0.44.0): Live Dashboard & UX - 21 features, +192 tests 2026-05-10 19:20:18 +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(v0.53.7): Data Forge + Pipeline live (wave 1) — 11 items 2026-05-13 19:28:11 +05:00
vscode_setup.py feat(eval): Tracker & Eval Pro — 18 features (v0.43.0) 2026-05-10 18:04:40 +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