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): #1337, #1317, #1333, #1323, #1321, #1298, #1300, #1301
Alpamysd7a4f7a77f25
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.mdindex 94d6667f..df41b874 100644--- a/CONTRIBUTORS.md+++ b/CONTRIBUTORS.md@@ -185,6 +185,9 @@ Listed by first contribution. PR numbers link the work.- `soup doctor --config` gave vision and audio configs an all-clear while `train_on_responses_only` and `mask_history` were unread there; the backend-support registry is now keyed by modality and reports both, with text output unchanged ([#1156](https://github.com/MakazhanAlpamys/Soup/issues/1156), [#1169](https://github.com/MakazhanAlpamys/Soup/pull/1169))- `soup mcp serve` wrote a child's output through whatever `.soup/mcp-runs` resolved to. So a directory symlink or junction at `.soup` or `.soup/mcp-runs`, or a hard link planted at the log path, sent training output wherever it pointed. Execution now refuses all three before spawn, with a message that names the reason and no path, and nothing is created at the link target. **Three rounds, and each one closed what the last one found.** A hard-link refusal first placed in the shared `open_no_follow` silently cost the audit log and the draft registry their records, so they scoped it to the run log. A directory check copied inline left the shared helper out of reach of every test, so they made it one helper in `utils/paths.py`. The pre-`mkdir` check let a refused execution hold the one-execution slot until restart, so they moved the call inside the slot-freeing `try` and kept the regression test. On Windows and Linux every refused layout frees the slot and a fresh plan runs, and 19 of 20 mutations fail tests ([#1158](https://github.com/MakazhanAlpamys/Soup/issues/1158), [#1171](https://github.com/MakazhanAlpamys/Soup/pull/1171))- `training.packing: true` silently trained SFT on the prompt: TRL packs only `input_ids`, so the `labels` mask was discarded and system and user tokens became targets (234 supervised positions where the unpacked run had 81). They carried the mask through `assistant_masks`, the column TRL's packing keeps and its collator always applies, derived once for train and eval, text and pre-tokenised data. The review round added the missing validation-split test and removed a second derivation that had left half of the fix untestable. New tests 6 passed and 5 fail on main; 5 of 6 mutations caught ([#1236](https://github.com/MakazhanAlpamys/Soup/issues/1236), [#1304](https://github.com/MakazhanAlpamys/Soup/pull/1304))+ - `task: distill` trained on rows whose assistant turn was truncated away at `data.max_length`: cross-entropy over zero targets was NaN, which the Trainer logged as 0.0 or a doubled loss, and a validation row made `eval_loss` NaN. Setup now refuses such a row by split and row number with SFT's own check and wording, on train and val and in every distill variant including sequence mode, and `compute_loss` returns a finite zero for a microbatch with no target. 15 new tests (14 fail on `main`); removing the guard fails 13 of them, removing the loss fallback fails 1, and skipping the guard for sequence, ULD or MiniLLM configs fails exactly those four cases ([#1242](https://github.com/MakazhanAlpamys/Soup/issues/1242), [#1298](https://github.com/MakazhanAlpamys/Soup/pull/1298))+ - `soup expect` passed datasets with PII or refusals in any field it did not know by name: ShareGPT conversations, DPO `chosen`/`rejected`, KTO `completion`, embedding pairs, multimodal parts and tool calls. They made extraction format-aware and scanned each field separately, so PII after a long field is no longer cut off by the 50 KB cap. **Three rounds, and the second turned the extraction table from documentation into a test**: the first version declared fields in a table that nothing read, so the table could be emptied with the suite green, and now every declared field of every format must catch a PII sample. New tests 102 passed and 62 fail on main; 17 of 17 targeted mutations caught ([#1231](https://github.com/MakazhanAlpamys/Soup/issues/1231), [#1300](https://github.com/MakazhanAlpamys/Soup/pull/1300))+ - `soup diagnose` tokenized with an ASCII-only regex, so an adapter answering in Greek, Cyrillic, Hindi, CJK or Thai read as MAJOR mode collapse, and one that had forgotten everything still read OK on the forgetting probe. They rebuilt the tokenizer on Unicode categories, with NFC, bigrams for unspaced scripts and digits, and kept English `token_f1` scores identical to main. **Three rounds, and the second was about cost**: NFC on untrusted text was quadratic in a run of combining marks (15 s for 100k characters), so they added a stream-safe cap and pinned it with a Tibetan case that only a category-based filter survives. New tests 54 passed and 32 fail on main; 11 of 11 targeted mutations caught ([#1233](https://github.com/MakazhanAlpamys/Soup/issues/1233), [#1301](https://github.com/MakazhanAlpamys/Soup/pull/1301))- **AmixDigital** ([@Amix29](https://github.com/Amix29))- Gave `soup monitor` a real Apple Silicon path, where it had reported nothing but an NVIDIA-shaped blank since v0.44.1. The security work is the part worth naming: fixed absolute executable paths so `PATH` cannot influence what runs, `sudo -n` that never prompts and never reads a password, stderr pattern-matched for permission markers but never printed, and a parser that returns `[]` against a billion-laughs entity bomb, an XXE `file:///` reference, 5,000-deep nesting and embedded NUL bytes. **Three guards had no test holding them up and they closed all three in twenty minutes** — most importantly the call site that decides which implementation every Linux and Windows user gets, where `if True or detect_apple_silicon()` had left 126 tests passing. Their oversize-payload test had also been asserting on `b"x" * (CAP + 1)`, which is not a valid plist and returns `[]` whether the cap exists or not; they rebuilt it around a valid oversized document. The test file shrank by 18 lines and **every deletion was an upgrade** — membership assertions became adjacency assertions. Asked to confirm the live plist schema, they said plainly that the Mac is not theirs and they cannot authenticate `sudo`, rather than guessing — while confirming the two things they could check against the real binary ([#481](https://github.com/MakazhanAlpamys/Soup/pull/481))@@ -308,6 +311,9 @@ Listed by first contribution. PR numbers link the work.- `training.moe_lora` was accepted and read by nothing on eight tasks; it is now wired into distill, unlearn and the classifier family, and refused at config load wherever no adapter is built (asr, moe_lora_routing, prm, backend: unsloth, SFT vision/audio), with all 19 mutation cases killed ([#1151](https://github.com/MakazhanAlpamys/Soup/issues/1151), [#1179](https://github.com/MakazhanAlpamys/Soup/pull/1179))- A missing torchao now stops an explicitly requested FP8 run (card checked first) instead of falling back silently, and `soup train` refuses before the model loads; running the real CLI also turned up Rich eating the `[qat]` extra from the install hint, fixed in the same PR ([#835](https://github.com/MakazhanAlpamys/Soup/issues/835), [#1154](https://github.com/MakazhanAlpamys/Soup/pull/1154))- Added `soup recipes verify`, the check #1116 argued nothing ran: does a shipped config actually reach an adapter? It fetches only `config.json`, builds the architecture on the meta device with the class that config's trainer loads, and runs Soup's own target resolution, the `moe_lora` rescue and the real peft attach with the config's own LoRA settings. So the verdict is the trainer's, not a re-implementation of it. A gated or remote-code repo is reported as unverified rather than broken, and exit codes follow the gate/verdict contract. The design choice worth copying is attaching instead of grepping: before any code, their live run found three MoE-by-architecture recipes (`gpt-oss-20b-sft`, `gpt-oss-120b-sft`, `minimax-m2-sft`) that #1102's flag-based sweep could not see. Six review rounds, each point closed with a measurement: a skeleton that keeps one layer of every kind (26 catalogue rows gained adapted modules, 0 verdicts changed), a broken library that exits 1 instead of turning into a verdict, and a `--json` stdout that stays a document even when the config loader warns. On the final head merged with `main`, 124 tests pass and 7 of 7 source mutations fail a test ([#1116](https://github.com/MakazhanAlpamys/Soup/issues/1116), [#1117](https://github.com/MakazhanAlpamys/Soup/pull/1117))+ - `training.lr_groups`, `training.early_stop_patience` and `training.citation_recall_threshold` were documented, validated and read by nothing. They now get #808's warn-then-refuse through #1106's `STAGED_FIELDS` and its single deadline constant, and the docs and schema descriptions no longer promise a per-module learning rate or a recall gate that never existed. **The move is the part worth copying**: `early_stop_patience` left `soup train`'s undated note instead of being listed twice, which is the double diagnostic #1106's review had to untangle, and a test pins both that it left and that its sibling flag stayed. When review showed that staging the fields blinded the #755 drift guard, they fixed the guard and put its original stand-in back instead of keeping the substitute that had hidden the gap. 10 of 10 mutations fail a test, and 1,103 tests pass across 23 related files ([#761](https://github.com/MakazhanAlpamys/Soup/issues/761), [#1337](https://github.com/MakazhanAlpamys/Soup/pull/1337))+ - An explicitly requested FP8 that failed during conversion trained on anyway. `apply_fp8_training` returned `False` and discarded torchao's error, so `quantization_aware: fp8` printed a yellow line and trained in bf16. The `fp8_attention` refusals ("PARTIALLY converted", "refusing the silent no-op") were caught and printed as yellow lines while training went on over a half-converted model or a no-op. All three now stop the run at setup and quote the cause. The uncalled `validate_fp8_config` is deleted, with a table mapping every behaviour its tests pinned to a live-path test that still holds it. **The discipline worth copying is what they left out**: NVFP4's identical degrade, and the OOM matcher that swallows the wrapped message, were both flagged as out of scope rather than folded in. Review ran the real torchao 0.18 and found its own conversion raising `AssertionError` and `TypeError`, which escaped the first catch unwrapped. They widened it to every exception and added the ready test in one push, replying twenty-five minutes after the review with three numbers that match my own re-measurement exactly. On the final head merged with `main`: 458 tests pass in the FP8 core set and 1,923 in the 28-file FP8 radius, 11 of the PR's tests fail on `main`, and 14 of 14 source mutations fail a test ([#1152](https://github.com/MakazhanAlpamys/Soup/issues/1152), [#1333](https://github.com/MakazhanAlpamys/Soup/pull/1333))+ - The `moe_lora` + `backend: unsloth` refusal gave one reason on every task, and it was false on the ten tasks with no unsloth setup; it also fired before the refusals that hold on every backend, so `asr`, `prm`, `moe_lora_routing` and SFT vision/audio were sent to `transformers` only to be refused again. They measured the task list from the wrapper classes rather than trusting the issue's seven, split the reason by a ratchet-checked `UNSLOTH_SETUP_TASKS`, and reordered the checks so each of those configs gets one refusal on every backend. A 936-config grid shows nothing newly refused (305 load on both sides); 135 tests pass on the merged head, 35 of the 72 new ones fail on `main`, and 12 of 12 source mutations are killed ([#1264](https://github.com/MakazhanAlpamys/Soup/issues/1264), [#1323](https://github.com/MakazhanAlpamys/Soup/pull/1323))- **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)).@@ -397,6 +403,8 @@ Listed by first contribution. PR numbers link the work.- `soup data preprocess` tokenised the rendered chat template directly, with no `add_eos` step, while the live SFT path reproduces TRL 0.29.1's rule in `data/loss_mask.py` — so on a template that renders no EOS and a tokenizer whose post-processor appends none (the Qwen shape), the live path trained on one stop token and the cache on **zero**, teaching run-on generation. It was silent in both directions a user can look: the loss curve is normal, and `soup data doctor --show-mask` renders the live path rather than the cache. **The part worth copying is what they did when the first baseline was challenged.** Their original test compared the cache against a faithful reproduction of TRL's `add_eos`, with a fair justification — the real `SFTTrainer._prepare_dataset` hangs on Windows through `PartialState` — but a reproduction of a rule is evidence about one's reading of the rule, not about the rule. They drove TRL's genuine `_prepare_dataset` instead, unbound with a minimal `self`, and made four things agree at one EOS per row: real TRL, their reproduction, the live `build_full_sequence_labels` path, and the cache. The second thing to copy is the truncation control: the obvious fix appends unconditionally, theirs appends only while the row is under the length budget, because the live path appends *then* truncates and keeps no trailing EOS there either — a constraint that comes from following the live path to its end rather than from the bug report, and their `append unconditionally` mutation proves the control is load-bearing. The cache key bumps `v2 -> v3` so a dataset cached under the old encoding is re-tokenised rather than silently reused, and the changelog fragment names the remedy for anyone already affected ([#791](https://github.com/MakazhanAlpamys/Soup/issues/791), [#938](https://github.com/MakazhanAlpamys/Soup/pull/938))- `soup serve --backend sglang` rendered the prompt through the chat template — which already emits the model's BOS — and then handed that string to the engine with special tokens added **again**. Every request began with two BOS tokens: a prompt the model was never trained on, with no error and no warning, so the degradation reads as the model simply being a bit worse and nobody files a bug for it. **The shape of the fix is the point** — it follows #781 in encoding the prompt the way training encoded it, rather than detecting a doubled BOS and stripping it afterwards. A stripper has to know which token to remove and when, and is wrong the moment a tokenizer behaves slightly differently; not adding special tokens to an already-rendered template has no such failure mode. They also diagnosed their own red Windows cell correctly as #382's illegal-instruction crash in a file they do not touch ([#890](https://github.com/MakazhanAlpamys/Soup/issues/890), [#995](https://github.com/MakazhanAlpamys/Soup/pull/995))- `training.loraplus_lr_ratio`, which their own #738 made work on sft, pretrain and embedding, was accepted and silently ignored by the thirteen other trainers that build a LoRA adapter: B trained at the base rate and the loss curve looked normal. Twelve now attach the LoRA+ optimizer after construction, online_dpo included, which hands TRL a `peft_config=` instead of calling `get_peft_model`. **PPO is the part worth reading.** trl's PPO trainer builds its optimizer and scheduler inside `__init__`, so a late attach would leave the scheduler on a discarded optimizer; they build the optimizer first, add the value model's groups (without them the critic belonged to no optimizer and never trained), prune empty groups under DeepSpeed, and pass it to the constructor, detecting that trainer shape rather than the trl version. Tasks with no trainable LoRA B, VeRA included, refuse the ratio at parse. **The part worth copying is how the tests grew**: across four review rounds, each surviving mutation became a test of what the trainer actually receives (group sizes as the constructor sees them, `base_lrs` on the real trl trainer), and a source scan fails when any LoRA-building trainer ships without LoRA+ or an earned exemption. On the final head: 195 tests plus 2 real-trainer smoke tests, 8 of 9 mutations killed (the survivor is error-message wording), and 3653 passed across 49 files on the merged tree ([#745](https://github.com/MakazhanAlpamys/Soup/issues/745), [#1080](https://github.com/MakazhanAlpamys/Soup/pull/1080))+ - `soup data canary insert` appended chat-format canaries to every dataset, so on any other format the loader dropped all of them before training and `canary check` could only answer OK. The issue's alpaca repro kept 3 of 7 rows on `main` and all 7 here. The canaries are now written in the file's own format, and every format whose canaries would be dropped, or that `check` cannot score, is refused before the manifest or the data exists. That includes plaintext, a file whose format cannot be detected, a first row that is not an object, and an explicit `--format` that is not the file's own. The manifest records the format, and legacy manifests read as chatml. **The part worth copying is the sweep:** every format `detect_format` can return must either load every canary or be refused with nothing written, and a guard test fails when a new format arrives without a fixture. It caught #1306's `cross_encoder` before either PR merged. Second round: the one surviving mutation became a test. 20 of 20 mutations killed; 350 passed, 1 skipped with the canary suite ([#1216](https://github.com/MakazhanAlpamys/Soup/issues/1216), [#1317](https://github.com/MakazhanAlpamys/Soup/pull/1317))+ - `format: tool-calling` read only top-level `tools` and `tool_calls`. It dropped every row `soup agent synth` writes, and every OpenAI-shape trajectory, and `soup train --dry-run` still said `Ready to train!` on zero rows. The converter now reads calls where they live, in source order, and keeps the old top-level form as a fallback. `format: auto` recognises `{messages, tools}`, synthesised rows carry their tool's schema, and `tools` may be a JSON-encoded string. **The part worth copying is the stop, and what it found.** `soup train` now exits 1 before the model loads when a load yields no training rows, and names the format and the first dropped row's reason. On its first run it caught two fixtures in the existing suite whose only row had gone to validation, runs that had trained on nothing; they fixed the fixtures rather than loosening the check. They also caught that Arrow gives every message every key, so a plain user turn reached Llama-style templates as a call, and they pinned that with a render through a real tokenizer. Second round: a string `tools` regression, null content, a mutable load record and one unpinned line, all closed with tests. 25 of 25 mutations killed; 4066 passed across a 74-file batch ([#1217](https://github.com/MakazhanAlpamys/Soup/issues/1217), [#1321](https://github.com/MakazhanAlpamys/Soup/pull/1321))- **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))