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
fix(config): lr_groups, early_stop_patience and citation_recall_threshold warn, then refuse (#761) (#1337)
Srinivasan R17ada469aa9e
diff --git a/changelog.d/0.75.1/1337.changed.md b/changelog.d/0.75.1/1337.changed.mdnew file mode 100644index 00000000..8535c082--- /dev/null+++ b/changelog.d/0.75.1/1337.changed.md@@ -0,0 +1,2 @@+- **`training.lr_groups`, `training.early_stop_patience` and `training.citation_recall_threshold` now warn at load, and v0.77 refuses them (#761 by @Srinivasan8888 in #1337).**+ All three were documented and validated but read by nothing: `lr_groups` never set a per-module learning rate, `citation_recall_threshold` never gated a save, and `early_stop_patience` never stopped a run. Setting one away from its default now prints "accepted but read by nothing; v0.77 will refuse it", as the #808 fields do. `early_stop_patience` moves from `soup train`'s "set but not enforced" note to that warning, so it is reported once, with the date. The docs no longer show `lr_groups` or `citation_recall_threshold` doing what they never did.diff --git a/docs/peft-and-efficiency.md b/docs/peft-and-efficiency.mdindex 41c1515b..153f0358 100644--- a/docs/peft-and-efficiency.md+++ b/docs/peft-and-efficiency.md@@ -188,7 +188,7 @@ training:## Optimizer & PEFT Zoo-Pick from a wider catalogue of optimizers, target individual modules with their own LR, and use quantization-aware LoRA initialisation:+Pick from a wider catalogue of optimizers and use quantization-aware LoRA initialisation:```yamltraining:@@ -196,12 +196,6 @@ training:# grokadamw, schedule_free, muon, dion, came_pytorch, ao_adamw_{fp8,4bit,8bit}optimizer: badam- # Per-module LR override (first match wins; remaining params use base lr)- lr_groups:- q_proj: 1e-4- v_proj: 5e-5- mlp: 1e-5-# Friendly aliases for users coming from LlamaFactory / Axolotl# load_in_8bit: true # equivalent to quantization: 8bit# load_in_16bit: true # equivalent to quantization: none@@ -218,7 +212,9 @@ training:freeze_trainable_layers: 4```-Catch-all friendly errors: typos in `optimizer:` are rejected at config-load with the v0.41.0 additions listed in the message; `lr_groups` patterns are validated as compilable regexes (length-capped + benign-string ReDoS probe); `load_in_8bit` mixed with `load_in_16bit` raises rather than picking one silently.+Catch-all friendly errors: typos in `optimizer:` are rejected at config-load with the v0.41.0 additions listed in the message; `load_in_8bit` mixed with `load_in_16bit` raises rather than picking one silently.++**`lr_groups` is not applied.** The per-module learning rate it describes is parsed and validated (patterns must be compilable regexes) but no optimizer reads it, so every parameter trains at `lr`. Setting it warns in v0.76 and is refused as of v0.77 (#761).PiSSA, OLoRA, LoftQ, and VeRA are applied through the shared PEFT constructor onthe Transformers backend. Soup refuses these variants on MLX and Unsloth rather@@ -699,7 +695,9 @@ reserved for planned in-training callbacks. They are accepted by the schema butare not enforced during training in this build. `soup train` prints an advisory notewhen one is set away from its default, directing users to `--gate <suite.yaml>`.(Other unconsumed configuration fields staged for features that have not landed emit-a load-time warning in v0.76 and are refused as of v0.77 per #808).+a load-time warning in v0.76 and are refused as of v0.77 per #808. That includes+`early_stop_patience`, which moved from the advisory note to the load-time warning+in #761, so it is reported once, with the refusal date.)Use the live eval gate for regression detection and automatic stopping today:diff --git a/docs/training.md b/docs/training.mdindex 0d977bf6..9d3391ff 100644--- a/docs/training.md+++ b/docs/training.md@@ -1591,9 +1591,10 @@ data:training:citation_faithful: true # enable citation precision/recall scoringcitation_style: bracket # cite as [doc-1] inline- citation_recall_threshold: 0.8 # gate final save on recall >= 80%```+`training.citation_recall_threshold` is validated but nothing gates a save or a run on it. Setting it warns in v0.76 and is refused as of v0.77 (#761).+```jsonl# RAFT JSONL row shape{"query": "When was Python released?", "golden_doc": "Python was released in 1991 by Guido van Rossum.", "distractor_docs": ["Ruby was released in 1995.", "Java was released in 1995."], "answer": "1991 [doc-1]"}diff --git a/src/soup_cli/commands/train.py b/src/soup_cli/commands/train.pyindex 269dd063..595213e7 100644--- a/src/soup_cli/commands/train.py+++ b/src/soup_cli/commands/train.py@@ -43,7 +43,8 @@ _UNWIRED_TRAINING_TUNABLES = ("checkpoint_eval_metric","checkpoint_eval_tasks","checkpoint_keep_top",- "early_stop_patience",+ # early_stop_patience moved to config/staged_fields.py (#761): the loader+ # warns about it with the refusal date, so it is not listed here as well."convergence_window","convergence_rel_tol",)diff --git a/src/soup_cli/config/schema.py b/src/soup_cli/config/schema.pyindex 27b5a34c..aac4a3bc 100644--- a/src/soup_cli/config/schema.py+++ b/src/soup_cli/config/schema.py@@ -1257,9 +1257,9 @@ class TrainingConfig(BaseModel):lr_groups: Optional[List[Dict[str, Union[str, float]]]] = Field(default=None,description=(- "Per-module LR override. List of {pattern, lr} entries (or a "- "{pattern: lr} dict). First match wins; remaining params fall "- "through to the base lr. Capped at 32 entries. (v0.41.0)"+ "Staged, not applied: a per-module LR override (list of {pattern, lr} "+ "entries or a {pattern: lr} dict, capped at 32) that no optimizer reads; "+ "setting it warns at load, then is refused (#761). (v0.41.0)"),)# v0.41.0 Part C — LLaMA Pro block expansion.@@ -4235,9 +4235,9 @@ class TrainingConfig(BaseModel):citation_recall_threshold: Optional[float] = Field(default=None,description=(- "Reject final-save when measured citation recall < this "- "threshold. Bounded [0.0, 1.0]. Composes with v0.56.0 "- "diagnose-gate. (v0.62.0 Part D)"+ "Staged, not applied: a citation-recall threshold in [0.0, 1.0] that "+ "nothing gates a save or a run on; setting it warns at load, then is "+ "refused (#761). (v0.62.0 Part D)"),)diff --git a/src/soup_cli/config/staged_fields.py b/src/soup_cli/config/staged_fields.pyindex c6720fef..f9052e5f 100644--- a/src/soup_cli/config/staged_fields.py+++ b/src/soup_cli/config/staged_fields.py@@ -41,9 +41,10 @@ class StagedField:#: DIFFERS from its schema default.#:#: Note: Training intelligence tunables already reported by ``soup train``-#: (e.g. ``forgetting_*``, ``checkpoint_*``, ``early_stop_patience``,-#: ``convergence_*``) are excluded here to avoid conflicting diagnostics-#: and adhere to their respective issue ownership (#808).+#: (e.g. ``forgetting_*``, ``checkpoint_*``, ``convergence_*``) are excluded here+#: to avoid conflicting diagnostics and adhere to their respective issue ownership+#: (#808). ``early_stop_patience`` moved here from that report (#761), so it is+#: reported once, with the refusal date.STAGED_FIELDS: dict[tuple[str, str], Any] = {("training", "long_context_grpo"): False,("training", "vision_grpo"): False,@@ -51,6 +52,10 @@ STAGED_FIELDS: dict[tuple[str, str], Any] = {("training", "grace_codebook"): False,("training", "grace_codebook_size"): None,("training", "grace_codebook_dim"): None,+ # #761: documented, validated, and read by nothing.+ ("training", "lr_groups"): None,+ ("training", "early_stop_patience"): 2,+ ("training", "citation_recall_threshold"): None,("data", "video_dir"): None,("data", "video_fps"): None,("data", "video_maxlen"): None,diff --git a/src/soup_cli/utils/diagnose/citation.py b/src/soup_cli/utils/diagnose/citation.pyindex b2d0268f..13bc0762 100644--- a/src/soup_cli/utils/diagnose/citation.py+++ b/src/soup_cli/utils/diagnose/citation.py@@ -7,7 +7,7 @@ document ids, and measures recall against the ground-truth golden-doc id.The ``FailureScore`` follows the same OK/MINOR/MAJOR taxonomy as every otherdiagnose mode (``classify_score`` on the mean recall). The training-config-``citation_recall_threshold`` is a separate eval-gate knob — the diagnose+``citation_recall_threshold`` is not read here, or anywhere (#761): the diagnosebadge uses the shared 0.85/0.60 bands so it reads consistently next to theother six probes.diff --git a/tests/test_issue748_config_fields_reach_a_consumer.py b/tests/test_issue748_config_fields_reach_a_consumer.pyindex 74113b98..5a5074ad 100644--- a/tests/test_issue748_config_fields_reach_a_consumer.py+++ b/tests/test_issue748_config_fields_reach_a_consumer.py@@ -326,15 +326,15 @@ def _consumed_in_src() -> set:# --------------------------------------------------------------------------KNOWN_UNCONSUMED = {# -- documented with a worked example, applied nowhere. Verified by hand.- "training.lr_groups": "no issue yet -- utils/lr_groups.py exports parse_lr_groups() and "- "nothing outside schema.py imports it; documented at "- "docs/peft-and-efficiency.md:190",+ "training.lr_groups": "#761 -- warns at load from v0.76, refused as of v0.77; "+ "utils/lr_groups.py exports parse_lr_groups() and nothing "+ "outside schema.py imports it",# data.mask_history was here until #761 wired it into data/loss_mask.py.- "training.early_stop_patience": "#761 -- schema promises 'consecutive regressions "- "before early stopping'; documented at "- "docs/peft-and-efficiency.md:622",- "training.citation_recall_threshold": "no issue yet -- validated by utils/citation_faithful.py "- "and named in its error strings; never applied",+ "training.early_stop_patience": "#761 -- warns at load from v0.76, refused as of "+ "v0.77; no early-stop callback reads it",+ "training.citation_recall_threshold": "#761 -- warns at load from v0.76, refused as "+ "of v0.77; validated by utils/citation_faithful.py, "+ "never applied",# -- found by the read/write fix, and the reason that fix exists. A user# setting that is OVERRIDDEN rather than merely unread, so the strongest# kind of member this list has.diff --git a/tests/test_issue755_backend_support_registry.py b/tests/test_issue755_backend_support_registry.pyindex cd555069..d08ef924 100644--- a/tests/test_issue755_backend_support_registry.py+++ b/tests/test_issue755_backend_support_registry.py@@ -487,7 +487,9 @@ def _fields_read_outside(repo_root: pathlib.Path, modules) -> set[str]:declared = {(repo_root / "src" / m).resolve() for m in modules}names: set[str] = set()for path in src.rglob("*.py"):- if path.resolve() in declared or path.name == "schema.py":+ # schema.py declares every field, and config/staged_fields.py lists the+ # ones nothing reads (#808): naming a field there is not reading it.+ if path.resolve() in declared or path.name in ("schema.py", "staged_fields.py"):continuenames |= _fields_read_by(path)return namesdiff --git a/tests/test_issue761_staged_three_fields.py b/tests/test_issue761_staged_three_fields.pynew file mode 100644index 00000000..46e9ce6d--- /dev/null+++ b/tests/test_issue761_staged_three_fields.py@@ -0,0 +1,86 @@+"""#761 — three documented training settings that nothing reads get the #808 rule.++``training.lr_groups`` and ``training.citation_recall_threshold`` were validated+and read by nothing, and setting them printed nothing. ``early_stop_patience``+got ``soup train``'s "set but not enforced" note, with no refusal date. Ruled on+#761 (2026-09-24): warn in v0.76, refuse in v0.77, with the deadline in #1106's+``STAGED_FIELD_REJECTION_VERSION``.+"""++from __future__ import annotations++import re++import pytest++from soup_cli.config import loader+from soup_cli.config.staged_fields import STAGED_FIELD_REJECTION_VERSION++_BASE = "base: org/m\ntask: sft\ndata:\n train: ./x.jsonl\n"+# Each field, set as a user would write it, in a config that otherwise loads.+_SET = {+ "training.lr_groups": _BASE + "training:\n lr_groups:\n - {pattern: lm_head, lr: 1.0e-5}\n",+ "training.early_stop_patience": _BASE + "training:\n early_stop_patience: 5\n",+ "training.citation_recall_threshold": (+ "base: org/m\ntask: sft\ndata:\n train: ./x.jsonl\n format: raft\n"+ "training:\n citation_faithful: true\n citation_recall_threshold: 0.8\n"+ ),+}+_ANSI = re.compile(r"\x1b\[[0-9;]*m")+++def _plain(text: str) -> str:+ return " ".join(_ANSI.sub("", text).split())+++class TestEachFieldWarnsThenRefuses:+ @pytest.mark.parametrize("path", sorted(_SET))+ def test_it_warns_and_names_the_version(self, path, capsys, monkeypatch):+ monkeypatch.setattr(loader, "STAGED_FIELD_SEVERITY", "warn")++ loader.load_config_from_string(_SET[path])++ out = _plain(capsys.readouterr().out)+ assert f"{path} is accepted but read by nothing" in out, out+ assert f"v{STAGED_FIELD_REJECTION_VERSION} will refuse it" in out++ @pytest.mark.parametrize("path", sorted(_SET))+ def test_it_is_refused_once_the_switch_flips(self, path, monkeypatch):+ monkeypatch.setattr(loader, "STAGED_FIELD_SEVERITY", "error")++ with pytest.raises(ValueError, match=re.escape(f"{path} is accepted but read by nothing")):+ loader.load_config_from_string(_SET[path])+++class TestTheDefaultsStaySilent:+ @pytest.mark.parametrize("severity", ["warn", "error"])+ @pytest.mark.parametrize(+ "training",+ [+ " early_stop_patience: 2\n", # the schema default, written out+ " lr_groups: []\n", # parses to None: no groups+ " lr_groups: {}\n", # the dict spelling, also None+ " citation_recall_threshold: null\n", # the default, written out+ " lr: 2.0e-5\n", # none of the three set+ ],+ )+ def test_a_default_prints_nothing(self, training, severity, capsys, monkeypatch):+ monkeypatch.setattr(loader, "STAGED_FIELD_SEVERITY", severity)++ loader.load_config_from_string(_BASE + "training:\n" + training)++ assert "read by nothing" not in _plain(capsys.readouterr().out)+++class TestOneDiagnosticForEarlyStopPatience:+ """#808 left it out of STAGED_FIELDS to avoid two diagnostics for one field:+ ``soup train`` already listed it as not enforced. It moves, it is not copied."""++ def test_soup_train_no_longer_lists_it(self):+ from soup_cli.commands.train import _nondefault_unwired_training_settings++ cfg = loader.load_config_from_string(+ _BASE + "training:\n early_stop_on_regression: true\n early_stop_patience: 5\n"+ )++ assert _nondefault_unwired_training_settings(cfg.training) == ["early_stop_on_regression"]diff --git a/tests/test_issue808_staged_config_fields.py b/tests/test_issue808_staged_config_fields.pyindex 538ed829..e543f068 100644--- a/tests/test_issue808_staged_config_fields.py+++ b/tests/test_issue808_staged_config_fields.py@@ -125,11 +125,13 @@ class TestTheDeadline:class TestStagedFieldsInventory:- """Validate inventory size and default handling across all 17 staged fields."""+ """Validate inventory size and default handling across all 20 staged fields."""- def test_exactly_17_staged_fields_registered(self) -> None:- assert len(STAGED_FIELDS) == 17, (- f"Expected exactly 17 staged fields, got {len(STAGED_FIELDS)}"+ def test_exactly_20_staged_fields_registered(self) -> None:+ # 17 from #808, plus lr_groups / early_stop_patience /+ # citation_recall_threshold from #761.+ assert len(STAGED_FIELDS) == 20, (+ f"Expected exactly 20 staged fields, got {len(STAGED_FIELDS)}")@pytest.mark.parametrize(@@ -141,6 +143,9 @@ class TestStagedFieldsInventory:("training", "grace_codebook", True),("training", "grace_codebook_size", 1024),("training", "grace_codebook_dim", 64),+ ("training", "lr_groups", [{"pattern": "lm_head", "lr": 1e-5}]),+ ("training", "early_stop_patience", 5),+ ("training", "citation_recall_threshold", 0.8),("data", "video_dir", "./videos"),("data", "video_fps", 2.0),("data", "video_maxlen", 64),