Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
docs(contributors): #1575, #1586, #1605, #1607, #1608, #1621 [skip ci]
Alpamysdbbe39090d39
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.mdindex 0228c1dc..627aa701 100644--- a/CONTRIBUTORS.md+++ b/CONTRIBUTORS.md@@ -344,6 +344,7 @@ Listed by first contribution. PR numbers link the work.- Resolved #1145's four recipes that could not load, following the three rulings on the issue: removed `mistral-large-3-sft`/`-dpo` (the repo has no `config.json`) and `minimax-m3-dpo` (DPO cannot build the `minimax_m3_vl` wrapper), and moved `minimax-m3-sft` onto the vision path. **The finding worth copying is the consequence nobody asked about**: the vision path loads `AutoProcessor`, MiniMax-M3's processor is custom code, so the recipe now needs `--trust-remote-code`, and they wrote that into the description and pinned it in a test, then checked a second review comment (the vision collator supervises every token) by running `soup doctor --config` both ways. The rebase chased moving targets (#1297, then #1388 and #1113), each time from `main`'s side with both fixtures regenerated by their scripts; the last round closed the attach-ratchet coupling and pinned the docs paragraph whose mutation had survived. 2446 tests over 20 files on the merged tree, 9 of 9 mutations caught, live attach ratchet exit 0 ([#1145](https://github.com/MakazhanAlpamys/Soup/issues/1145), [#1398](https://github.com/MakazhanAlpamys/Soup/pull/1398))- Closed the top-level half of `soup expect`'s silent-drop family: `parse_suite_spec` read only `expectations`, so `fail_fast: true` (or a `name:` label, or a typo like `expectation:`) beside it ran and exited 0. They filed it from the #1461 review, waited for #1461 to merge as agreed, and opened the PR rebased on it: six lines in `src/`, the key text echoed through #1461's `repr()` helper, `soup expect` exiting 3 before the data file is opened. They found that one existing test fixture (`name: test_all_formats_suite`) was itself an instance of the bug and removed that single line, leaving the test's rows and exit-2 assertion untouched. When review found one docs sentence missing and one surviving mutation (an allowlist widened to `name`), they closed both in one push with `src/` byte-identical and a 4-case test that kills it, and said plainly that bounding the key list would be a separate follow-up rather than folding it in. Verified on the merged tree: 270 passed; the check removed, the `repr()` removed, naming only the first key, and four allowlist widenings are each caught (8 / 2 / 1 / 1 / 1 / 1 / 1 failures). ([#1483](https://github.com/MakazhanAlpamys/Soup/issues/1483), [#1499](https://github.com/MakazhanAlpamys/Soup/pull/1499))- Finished the LLaMA-Factory and Unsloth halves of `soup migrate`'s preference mapping. `pref_loss: ipo` had become plain DPO, `hinge` / `kto_pair` loaded as DPO, and four TRL trainer classes migrated as SFT, all without a warning. Each value now maps to its Soup task or stops by name, `OnlineDPOTrainer` gets a placeholder judge that loads, and `SFTConfig` hyperparameters are read. **The fourth round is the one worth copying.** Adding `SFTConfig` exposed that the notebook walk was breadth-first, so an inline SFT warm-up beat a later GRPO config, and four public Unsloth GRPO notebooks turned into SFT recipes with a 40x learning rate. They switched to a source-order walk. Unasked, they also made the config resolver handle the positional `CPOTrainer(model, args)` form and refuse a rebound config name instead of reading a stale one. 278 tests pass on the merged tree, the new tests fail 42 of 67 on `main`, and all 9 mutations run on the last two rounds' code are caught ([#1214](https://github.com/MakazhanAlpamys/Soup/issues/1214), [#1560](https://github.com/MakazhanAlpamys/Soup/pull/1560))+ - Removed the Web UI plugin registry that nothing rendered: `soup_cli.ui.plugins` had been importable since v0.44.0, but `create_app` never read it and a registered tab never appeared. The module, its docs section and its 11 dead tests went, exactly as the ruling listed, with `soup plugins` and `ui_env` untouched. They added a guard that keeps it gone; in review they reproduced the stale ignored `__pycache__` failure themselves before applying the suggested replacement, and they extended the route pin to every decorated Web UI path plus the static mount. 709 passed / 2 skipped across 19 files; 9 of 9 mutations caught ([#1465](https://github.com/MakazhanAlpamys/Soup/issues/1465), [#1608](https://github.com/MakazhanAlpamys/Soup/pull/1608))- **Sohaib Kamash** ([@Nick-800](https://github.com/Nick-800))- Added seven validated Qwen2.5-Coder, Qwen2.5-Math, and DeepSeek-R1-Distill-Qwen SFT recipes; synchronized all catalog-count sites and repaired the Mistral Small model identifier. Literal repository IDs and per-recipe learning rates are now load-bearing assertions ([#536](https://github.com/MakazhanAlpamys/Soup/pull/536)).@@ -456,6 +457,7 @@ Listed by first contribution. PR numbers link the work.- `soup data clean` silently deleted valid tool-calling training rows: with no flags, the `--min-tokens` check in the `chatml` branch of `clean_row` dropped a trajectory whose call-only assistant turn had `"content": ""` (the shape Soup's own tool-calling format writes) while the same turn with `null` was kept and the loader accepted both. They found it while working on #1338, reported it with a runnable snippet and the CLI output, and fixed it by exempting only a turn with a non-empty `tool_calls` list, leaving `[]`, `null`, a missing key and non-lists on the old rule. 18 tests (6 fail on `main`) cover `""`, whitespace and `null` in both branches; their mutation table (6 / 10 / 2 / 3 / 18 / 1) reproduced exactly and five further mutations were all caught ([#1477](https://github.com/MakazhanAlpamys/Soup/issues/1477), [#1493](https://github.com/MakazhanAlpamys/Soup/pull/1493))- `soup ab` estimated the variance from the rows it tested, so its two-sided mSPRT needed a 30-40 row burn-in, was calibrated only to 1000 rows and `--alpha 0.01`, and still sat at 0.011 there. They replaced it with the normal-inverse-gamma mixture Bayes factor, which depends on the rows only through the t statistic, so the false-positive bound holds at any number of looks: worst simulated 0.033 at `--alpha 0.05` and 0.0066 at 0.01, from 7 rows per arm. **The part worth copying is that the cost is published next to the gain**: `accept_h0` is slower when there is no difference (281 pairs against 43 at 0.5 sd), and that table sits in the docs, the record and the changelog. Across four review rounds every edge review found became a refusal or a guard with a test a mutation kills: a near-constant held-out column, an overflowing prior at a small row count, a variance that underflows to 0, and a saturated start that had ended 99% of simulated runs in a wrong `accept_h0`, now held at `continue` while the tested rows spread more than 3 times the held-out ones (0 such runs in 2000, 15 of 6000 Gaussian first verdicts changed, no rejection). 208 passed across the `soup ab` suite; 16 of 17 mutations of the final changes killed ([#1265](https://github.com/MakazhanAlpamys/Soup/issues/1265), [#1419](https://github.com/MakazhanAlpamys/Soup/pull/1419))- `training.freeze_layers` and `training.freeze_ratio` loaded on all 23 tasks but are read in exactly one place, `SFTTrainerWrapper._setup_transformers`. On the other 21 tasks a `freeze_layers: 2` run trained every layer and said nothing. They refused the fields at load on those tasks and kept `tts` on the applying side, because its wrapper inherits the SFT setup. They tied the refused list to the trainers with an AST scan of `trainer/dispatch.py` instead of a hand-kept table, pinned the refusal on every backend, and filed the remaining within-`sft` gap as #1581. 106 tests; every reachable mutation killed ([#1497](https://github.com/MakazhanAlpamys/Soup/issues/1497), [#1532](https://github.com/MakazhanAlpamys/Soup/pull/1532))+ - `soup ab` reached `accept_h0` slowly when there was no difference: under their own #1265 statistic the Bayes factor had to fall to `log(beta / (1 - alpha))`, which took 621 pairs per arm on average at 0.3 standard deviations. They read the same mixture the other way, as an always-valid confidence sequence for the difference, and accept once it lies inside +-effect_size: 307 pairs at 0.3 sd and 117 at 0.5, with the reject rule unchanged byte for byte. **The part worth copying is how the decision was made**: both readings of `--beta` were measured on the same replayed runs and put in the PR with their costs (level beta was faster, 220 pairs against 307 at 0.3 sd, but took power at effect_size from 0.997 to 0.964). The maintainer chose level alpha, and the record keeps the option not taken. `--beta` is retired through the existing one-release deprecation staging: it warns once and changes no verdict. 466 passed across the `soup ab`, deprecation, fragment, startup and ANSI-guard tests; 27 of 30 mutations killed, the survivors an exact float tie and an unpinned `--beta 0` warning ([#1418](https://github.com/MakazhanAlpamys/Soup/issues/1418), [#1575](https://github.com/MakazhanAlpamys/Soup/pull/1575))- **GitFromRatatouille** ([@swalla02](https://github.com/swalla02))- First contribution, and it is the third instance of this repo's most persistent bug class found by someone else ([#363](https://github.com/MakazhanAlpamys/Soup/issues/363), [#423](https://github.com/MakazhanAlpamys/Soup/issues/423), [#659](https://github.com/MakazhanAlpamys/Soup/issues/659)): `soup migrate` refused **any** input named `*.jsonl`, a valid LLaMA-Factory YAML config included, because the guard branched on the filename while the content sniff written to gate it had **zero call sites in `src/`**. The diagnosis is worth more than the one-line fix — the test was named after the command and its body called the helper, so it passed on a codebase where `migrate` never imported it. **Then review found a regression their own fix introduced, and the way they closed it is the part to copy**: the sniff read `utf-8`, so a UTF-8 BOM survived as U+FEFF, which `str.strip()` does not remove, and a real BOM'd JSONL silently lost the friendly error it used to get — on a project with three Windows CI cells where PowerShell's `Out-File` writes that BOM by default. Their BOM test **guards its own fixture** (asserting the file really contains a BOM before asserting behaviour) and their bounded-read test measures the property with `tracemalloc` rather than pinning the spelling of the loop. Six mutations, six killed; zero assertions removed. They also **declined to widen the fix** to files whose name gives no hint, correctly citing the `.ipynb` case the original comment warns about, and left that as an open question rather than guessing ([#672](https://github.com/MakazhanAlpamys/Soup/issues/672), [#675](https://github.com/MakazhanAlpamys/Soup/pull/675))@@ -490,6 +492,7 @@ Listed by first contribution. PR numbers link the work.- Symlink tests were skipped by PLATFORM, so a Windows box that CAN create symlinks - any account with Developer Mode on - silently lost the coverage. They replaced `skipif(os.name == "nt")` with a capability probe and a `requires_symlink` marker across 91 test files, and the numbers say it removes skips rather than coverage: `skipif` across `tests/` drops 152 -> 60 while the assert count goes UP. **The part that earned the merge is the ratchet** that fails the suite when a new test hand-rolls its own probe - it counts 291 offenders on `main` today, so the convention is enforced rather than announced. Verified here in both directions: with the privilege, 812 passed / 1 skipped, and the 154 tests of #820/#1024 that used to be nt-skipped now actually execute; with the privilege simulated away, 768 passed / 45 skipped, and 812 - 768 = 44 is exactly the gated set with nothing failing. Forcing the probe True on an unprivileged account fails 45; forcing it False on a capable one fails exactly the test that compares it against a live `os.symlink`. The 91-file merge resolution was audited by re-running git's own automerge and by an AST decorator diff: zero test objects lost, zero non-symlink decorators lost, 147 gained the marker ([#832](https://github.com/MakazhanAlpamys/Soup/issues/832), [#1039](https://github.com/MakazhanAlpamys/Soup/pull/1039))- Twice a streamed LoRA run saved an adapter that reloads as nothing — v0.72.0's `.inner.` keys, then #1005's 0-tensor file under peft 0.21.0 — and training reported success both times. Every streamed save, each `checkpoint-*` and the final one, now reads the written file's keys back and raises, naming the file and both counts, on a missing file, a LoRA tensor count other than the model trained, or an `.inner.` key. **The reference is the design decision**: no streamed save is legitimately empty, so the check compares against the trainable count rather than a bare `> 0` and catches a partial adapter too, and the final save is checked on its own because `save_model` dispatches no `on_save`. Their #1005 mutation test makes the guard fire on peft 0.21.0 and skips, saying so, on a peft where the mutation is inert instead of passing vacuously. All seven mutations fail tests, including the `should_save` gate that keeps a distributed streamed run alive at its final save ([#1011](https://github.com/MakazhanAlpamys/Soup/issues/1011), [#1031](https://github.com/MakazhanAlpamys/Soup/pull/1031))- With `stream_layers: true` on an untied checkpoint, the Llama-3-8B-class shape, `dpo` and `kto` crashed inside `trainer.train()`: `embed_tokens` and `lm_head` share one device slot, the head handed autograd a view of it, and the reference forward refilled those bytes before the policy backward. The head now takes a private copy of its weight only when the slot is shared and the loss runs a reference forward before its backward, and the VRAM pre-flight charges that copy for exactly those runs, so its never-under-predicts contract holds. **Where the decision lives is the part worth copying**: a trainer flag, because the trainer is the one thing that knows whether a second forward runs before the backward, so `sft`, `orpo`, `simpo` and the embedding keep the view and pay nothing (the SFT half was @VanshSharmaPES's catch in #1174). Without the fix `dpo` and `kto` fail with the issue's error verbatim; 18 of 19 mutations killed, the survivor equivalent ([#1049](https://github.com/MakazhanAlpamys/Soup/issues/1049), [#1061](https://github.com/MakazhanAlpamys/Soup/pull/1061))+ - With `expand_layers` set, `freeze_trainable_layers` was read only for its sign: under full fine-tuning `1`, `2` and `4` trained the same appended blocks and `0` or a negative value silently trained the whole expanded model, while the released field description promised top-N / bottom-N. Following the route-1 ruling, any value other than `expand_layers` is now refused at load, naming both fields and the value to set, and the description, the `block_expansion.py` docstrings and both docs pages now say the value must equal `expand_layers`. **The test worth copying is the one through the real `SFTTrainerWrapper.setup()`**: it compares the `requires_grad` set from `named_parameters()` with the appended blocks, so it fails when the freeze is skipped, leaves one new block frozen or leaves the embeddings trainable, not only when a helper returns a different number. 17 of 18 mutations killed, including all five the ruling listed ([#1409](https://github.com/MakazhanAlpamys/Soup/issues/1409), [#1586](https://github.com/MakazhanAlpamys/Soup/pull/1586))- **Thanniru Sai Teja** ([@iam-saiteja](https://github.com/iam-saiteja))- Made `soup data validate` single-pass with type-tagged row signatures — and the reason this is worth reading is the recovery, not the speedup. The first revision was written against a pre-#712 copy of `validator.py`, so it silently reverted that fix and `soup data validate` went back to reporting `3/3 rows valid` on a file the loader drops two thirds of; twenty existing tests said so. **They then did more than was asked on the second finding**: told that a test pinning both copies of the join-separator arithmetic would be sufficient, they removed the duplication instead, so one helper now serves both functions and mutating it fails two tests where the second copy had survived +0 failures across 1432. The `_to_hashable` collision class ({"messages": []} and {"messages": {}} both canonicalising to `()` and reporting as duplicates on real chat data) is closed and verified over a 184-case differential harness across all eighteen formats. **And they corrected their own number rather than defending it** — the benchmark now interleaves the two implementations instead of timing them sequentially, reporting 1.34x-1.57x, where the version first shipped printed a *slowdown* for a change that was faster. Unrequested scope, said so at the time ([#771](https://github.com/MakazhanAlpamys/Soup/pull/771))@@ -770,6 +773,11 @@ Listed by first contribution. PR numbers link the work.- First contribution: a judge that was down still cost 3 s of backoff for every row, because each row retried on its own: 1,000 rows slept 3,000 s against a host that never answered, and `soup data from-traces --judge` then wrote an empty file with exit 0. They added a per-evaluator count of requests whose retries were spent, a `JudgeDownError` at the third, and a stop in each caller that names the judge URL and how much was left; a 4xx or an unusable reply counts as an answer and resets it. **The part worth copying is how they handled what they could not prove**: they measured that `ship` and `best-of-n` already stopped on `main` and said a counter mutation cannot fail those tests, flagged their own 60-second cooldown as the reviewer's to overrule, and when review showed it turning a 9-second outage into 48 unranked pairs in a row, removed it and rewrote the tests the way the real callers behave. 19 tests (8 fail with the counter reverted), 2,584 passing across 40 judge-related files, 27 of 29 mutations killed ([#1522](https://github.com/MakazhanAlpamys/Soup/issues/1522), [#1563](https://github.com/MakazhanAlpamys/Soup/pull/1563))- First contribution: a hand-written `use_dora: true` on a GPTQ, AWQ, AQLM or EETQ base loaded and then failed inside peft when the adapter was attached, after the checkpoint download and the model load. They claimed the item on the issue first, then added a `SoupConfig` validator that refuses the pairing at config load with a message naming both settings and the fix, and moved the four formats into one set that Autopilot's `decide_peft` now reads too, so the schema and Autopilot cannot drift apart. **The part worth copying is the controls**: every test uses the same GPTQ-named base and flips only `quantization`, so a refusal keyed on the model name would have failed their own tests. 17 tests (5 fail on `main`), 11 of 12 mutations killed, and across 14,904 config loads nothing is newly accepted and the 404 new refusals are all `use_dora: true` with one of the four formats ([#1466](https://github.com/MakazhanAlpamys/Soup/issues/1466), [#1555](https://github.com/MakazhanAlpamys/Soup/pull/1555))- `training.quantization: mxfp4` passed config validation and then failed at the model load, because Soup built a bitsandbytes config for a format that belongs to transformers' own `Mxfp4Config`; the MXFP4 base Autopilot passes through failed the same way. They reproduced both on `main` and posted what transformers' quantizer says before writing code, then mapped `mxfp4` to `Mxfp4Config(dequantize=True)`, took it out of the k-bit prep path of all 15 trainer sites (it would cast the dequantized model to fp32), refused a local base that is not MXFP4 and the bitsandbytes-only `bnb_4bit_quant_storage`, and priced the base as the bf16 model it loads. **The part worth copying is the "not run" list**: no CUDA, no real MXFP4 weights, no training run, each with what it leaves unproven. 13 new tests (all fail on `main`, 26 across their test files), 26 of 26 mutations killed ([#1466](https://github.com/MakazhanAlpamys/Soup/issues/1466), [#1558](https://github.com/MakazhanAlpamys/Soup/pull/1558))+ - First contribution: disk-tier layer streaming turned direct I/O off for the whole store when torch's caching host allocator handed back a pinned staging arena off a 4096-byte boundary, and said so only in a log line. They aligned the placements inside the arena or took the next power of two, measured the shift again on the replacement, made `pinned_bytes` count the arenas actually held, and put the remaining page-cache fallback on the console. 12 CPU tests with a forced 512-byte offset (4 fail and 5 error on main), 12 of 12 mutations killed ([#1531](https://github.com/MakazhanAlpamys/Soup/issues/1531), [#1621](https://github.com/MakazhanAlpamys/Soup/pull/1621))++- **Nariman Abdikarim** ([@Nari-Ab](https://github.com/Nari-Ab))+ - First contribution: `soup data generate --template preference` appended every preference row before the dedup check, so rows repeating a `--dedup-with` file and repeats within the same run were all written. They claimed that one item of the #1448 audit, routed preference rows through the shared dedup check, and built an order-independent key from the DPO and KTO fields. **Review found that nothing pinned which fields make up the key: a prompt-only key passed every test and would have dropped every later row for the same prompt. They added the proposed test and the exact duplicate count within minutes.** The new file is 4 failed on `main`, 11 of 11 mutations are caught, and 507 related tests pass ([#1448](https://github.com/MakazhanAlpamys/Soup/issues/1448), [#1605](https://github.com/MakazhanAlpamys/Soup/pull/1605))+ - First contribution, one slice of the #1448 audit: `soup serve` dropped `--structured-output` / `--json-schema` / `--regex-pattern` and `--reasoning-parser` on streaming chat completions, so `stream: true` returned unconstrained text with the `<think>` block still in it while the same request without streaming was constrained and stripped. They claimed that one item, wired the processors, the n-gram config and the reasoning parser into the streaming path exactly as the non-streaming handler does, and stripped the text before both the SSE chunks and the trace log. **Review found that the first constraint test mocked the builder, so building for `None` (the reported bug) still passed; they added the parity test the review supplied, which drives the same app with and without `stream` and compares what the client sees and what generation receives.** 5 tests fail on `main`, 11 of 11 mutations of the constraint, n-gram and parser hand-offs are caught, and 1231 serve-related tests pass with `main` merged ([#1448](https://github.com/MakazhanAlpamys/Soup/issues/1448), [#1607](https://github.com/MakazhanAlpamys/Soup/pull/1607))---