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(doctor): omit explicit defaults and unreachable support rows (#1791)
Aditya Pratap Singh819af883039a
diff --git a/changelog.d/0.76.0/1791.fixed.md b/changelog.d/0.76.0/1791.fixed.mdnew file mode 100644index 00000000..afe1ede2--- /dev/null+++ b/changelog.d/0.76.0/1791.fixed.md@@ -0,0 +1 @@+- **`soup doctor --config` ignores explicitly written schema defaults (#1330).** Minimal configs and full YAML dumps now produce the same support report, including vision/audio defaults; `seed: 0` remains active. Removed unreachable MLX/Unsloth rejection rows and multimodal response-mask rows, retaining documentation of their limitations and load-time refusals. Round-trip regressions now pass without xfails. Follow-up to #1336 by @Yi-111-a. (#1330 by @akkupratap323 in #1791)diff --git a/docs/backends-and-ops.md b/docs/backends-and-ops.mdindex 659b8c91..2ce7f3ca 100644--- a/docs/backends-and-ops.md+++ b/docs/backends-and-ops.md@@ -556,6 +556,14 @@ soup doctor [--nccl]Shows: Python version, GPU availability, system resources (RAM/Disk), all dependency versions, and fix suggestions. Use `--nccl` to measure and check multi-GPU communication bandwidth against expected hardware ceilings.+With `soup doctor --config soup.yaml`, the declared support report lists only+explicitly written, active settings that differ from their schema defaults.+Writing a default counts as leaving it unwritten, so a full YAML dump and its+minimal source have the same report; `seed: 0` still counts because the seed+default is unset. Settings refused at config load are not listed as doctor rows:+their active values fail before the report can run. This report describes the+reviewed gaps, not a guarantee that every unlisted setting is supported.+### GPU diagnosticsWhen an NVIDIA GPU is available, `soup doctor` reports its compute capabilitydiff --git a/docs/data.md b/docs/data.mdindex 6264fe1c..cb98ce57 100644--- a/docs/data.md+++ b/docs/data.md@@ -940,10 +940,11 @@ turn on MLX. `soup train` says so on its "MLX backend ignores:" line, andevery text token is supervised. Soup's vision collator masks only padding and imagetokens, and the audio path only padding. Assistant-only masking would have to locate theassistant spans after the processor expands the image or audio tokens, which neither path-does yet. Soup declares this gap rather-than attempting unverified label restructuring, so both `mask_history` and `train_on_responses_only`-are unread on vision and audio modalities, every text token trains, and `soup doctor --config`-reports them as ignored.+does yet. Both `mask_history` and `train_on_responses_only` are unread on these+modalities, so every text token trains. `soup doctor --config` reports an explicit+`mask_history: true` as ignored. It does not list `train_on_responses_only`: its+schema default is `true`, and writing a default counts as leaving it unwritten.+The absence of a doctor row does not imply assistant-only multimodal masking.**AOT preprocessing:**diff --git a/docs/performance-and-quantization.md b/docs/performance-and-quantization.mdindex cc184790..f62b1b45 100644--- a/docs/performance-and-quantization.md+++ b/docs/performance-and-quantization.md@@ -1354,6 +1354,11 @@ torchao converters as of v0.71.21 (hardware-gated):Cross-validator ordering picks the most actionable error: `quantization_aware='fp8'` prerequisite fires before the MLX rejection on `fp8_attention`, and task compatibility checks fire at config load before runtime trainer construction.+On `backend: unsloth`, active `quantization_aware`, `fp8_attention` and `nvfp4`+settings are refused at config load. They do not appear as `rejected` rows in+`soup doctor --config`: a loadable config cannot reach such a row. Select a+supported transformers path for these precision features.+## LF / Axolotl Quant Parity (v0.53.0)diff --git a/src/soup_cli/config/backend_support.py b/src/soup_cli/config/backend_support.pyindex 70a8f401..842cc94a 100644--- a/src/soup_cli/config/backend_support.py+++ b/src/soup_cli/config/backend_support.py@@ -31,10 +31,6 @@ from collections.abc import Callablefrom dataclasses import dataclass, fieldfrom typing import TYPE_CHECKING, Any-from soup_cli.utils.advanced_precision import (- UNSLOTH_PRECISION_INCOMPATIBLE_REASON,-)-if TYPE_CHECKING: # pragma: no cover - typing onlyfrom soup_cli.config.schema import SoupConfig@@ -46,8 +42,8 @@ if TYPE_CHECKING: # pragma: no cover - typing only#: * ``honoured`` would mean enumerating 275 declared fields against every#: reviewed pair -- a table nobody can review honestly, and the opposite of#: this module's premise that a gap list is short enough to be checked;-#: * ``rejected`` covers settings rejected at the schema boundary for a-#: backend (e.g. callback monitoring flags on backend=mlx, #1069).+#: * ``rejected`` is retained for compatibility, but has no registry rows:+#: settings refused at config load cannot reach the doctor (#1330).IGNORED = "ignored"REJECTED = "rejected"STATUSES = frozenset({IGNORED, REJECTED})@@ -190,24 +186,6 @@ _MLX_SFT: tuple[SupportEntry, ...] = ("before resolve_trainer)",trainer_reads=True,),- SupportEntry(- "training.loss_watchdog",- REJECTED,- "Soup does not implement the watchdog on the MLX callback, which has no stop control",- trainer_reads=True,- ),- SupportEntry(- "training.loss_spike_recovery",- REJECTED,- "spike recovery is driven by the watchdog and the watchdog cannot fire on MLX",- trainer_reads=True,- ),- SupportEntry(- "training.grad_accum_auto_tune",- REJECTED,- "there is no VRAM total to measure pressure against on unified memory",- trainer_reads=True,- ),)@@ -215,14 +193,6 @@ _MLX_SFT: tuple[SupportEntry, ...] = (# reads data.train_on_responses_only and data.mask_history in# data/sft_format.py and data/loss_mask.py, outside the declared trainer modules._TRANSFORMERS_VISION_SFT: tuple[SupportEntry, ...] = (- SupportEntry(- "data.train_on_responses_only",- IGNORED,- "multimodal vision collator supervises all tokens; assistant-only masking "- "is not implemented for vision datasets",- issue=1156,- trainer_reads=False,- ),SupportEntry("data.mask_history",IGNORED,@@ -234,14 +204,6 @@ _TRANSFORMERS_VISION_SFT: tuple[SupportEntry, ...] = ()_TRANSFORMERS_AUDIO_SFT: tuple[SupportEntry, ...] = (- SupportEntry(- "data.train_on_responses_only",- IGNORED,- "audio training supervises all tokens; assistant-only masking "- "is not implemented for audio datasets",- issue=1156,- trainer_reads=False,- ),SupportEntry("data.mask_history",IGNORED,@@ -253,28 +215,8 @@ _TRANSFORMERS_AUDIO_SFT: tuple[SupportEntry, ...] = ()-_UNSLOTH_SFT: tuple[SupportEntry, ...] = (- SupportEntry(- "training.quantization_aware",- REJECTED,- f"QAT and FP8 training are not compatible with the unsloth backend "- f"({UNSLOTH_PRECISION_INCOMPATIBLE_REASON})",- issue=1124,- ),- SupportEntry(- "training.fp8_attention",- REJECTED,- f"fp8_attention is not supported on backend=unsloth "- f"({UNSLOTH_PRECISION_INCOMPATIBLE_REASON})",- issue=1124,- ),- SupportEntry(- "training.nvfp4",- REJECTED,- f"nvfp4 is not supported on backend=unsloth ({UNSLOTH_PRECISION_INCOMPATIBLE_REASON})",- issue=1124,- ),-)+# Unsloth precision settings are refused at config load, not reported by doctor.+_UNSLOTH_SFT: tuple[SupportEntry, ...] = ()#: ``(task, backend, modality)`` -> the settings that combination does not honour.@@ -334,11 +276,12 @@ def unsupported_for(def check_config(cfg: "SoupConfig") -> list[SupportEntry]:"""The declared gaps that apply to the fields this config actually sets.- Only fields the user wrote and switched on are reported. Pydantic's+ Only non-default fields the user wrote and switched on are reported. Pydantic's``model_fields_set`` distinguishes the written fields from the ones sittingat their schema default, which is the difference between a useful pre-flightcheck and a wall of 275 rows. ``entry.active`` then drops a field written in- its off position (e.g. ``false``); ``seed: 0`` still counts as set.+ its off position (e.g. ``false``). A written schema default counts as+ unwritten, including a default of ``true``; ``seed: 0`` still counts as set."""backend = getattr(cfg, "backend", DEFAULT_BACKEND)modality = getattr(cfg, "modality", DEFAULT_MODALITY)@@ -352,7 +295,10 @@ def check_config(cfg: "SoupConfig") -> list[SupportEntry]:if section is None:continuefor name in getattr(section, "model_fields_set", ()):- written[f"{namespace}.{name}"] = getattr(section, name)+ value = getattr(section, name)+ schema_field = type(section).model_fields[name]+ if value != schema_field.get_default(call_default_factory=True):+ written[f"{namespace}.{name}"] = valuereturn [entry for entry in entries if entry.field in written and entry.active(written[entry.field])diff --git a/tests/test_issue1069_mlx_callback_monitoring_compat.py b/tests/test_issue1069_mlx_callback_monitoring_compat.pyindex 4e47c751..1e8c1362 100644--- a/tests/test_issue1069_mlx_callback_monitoring_compat.py+++ b/tests/test_issue1069_mlx_callback_monitoring_compat.py@@ -1,5 +1,5 @@"""Tests for Issue #1069: loss_watchdog, loss_spike_recovery and grad_accum_auto_tune-are rejected and reported as unread on backend: mlx.+are refused at config load on backend: mlx; no unreachable doctor row remains."""from __future__ import annotations@@ -9,7 +9,7 @@ from types import SimpleNamespaceimport pytest-from soup_cli.config.backend_support import REJECTED, check_config, unsupported_for+from soup_cli.config.backend_support import check_config, unsupported_forfrom soup_cli.config.schema import SoupConfig, TrainingConfigfrom tests.conftest import strip_ansi@@ -75,40 +75,24 @@ class TestSchemaRejectionOnMlxBackend:class TestBackendSupportRegistryAndDoctor:- """Verify backend_support registry and check_config declare and report- all three unread monitoring fields for (sft, mlx) as REJECTED.- """-- def test_registry_contains_all_three_monitoring_fields_as_rejected(self) -> None:- entries = {e.field: e for e in unsupported_for("sft", "mlx")}- assert entries["training.loss_watchdog"].status == REJECTED- assert "watchdog on the MLX callback" in entries["training.loss_watchdog"].reason- assert entries["training.loss_watchdog"].trainer_reads is True-- assert entries["training.loss_spike_recovery"].status == REJECTED- assert "driven by the watchdog" in entries["training.loss_spike_recovery"].reason- assert entries["training.loss_spike_recovery"].trainer_reads is True+ """Schema-refused monitoring settings have no unreachable doctor rows."""- assert entries["training.grad_accum_auto_tune"].status == REJECTED- assert "VRAM total to measure pressure" in entries["training.grad_accum_auto_tune"].reason- assert entries["training.grad_accum_auto_tune"].trainer_reads is True+ def test_registry_omits_schema_refused_monitoring_fields(self) -> None:+ fields = {entry.field for entry in unsupported_for("sft", "mlx")}+ assert fields.isdisjoint({+ "training.loss_watchdog",+ "training.loss_spike_recovery",+ "training.grad_accum_auto_tune",+ })- def test_check_config_reports_declared_gaps(self) -> None:- cfg = SoupConfig.model_construct(- base="sshleifer/tiny-gpt2",- task="sft",- backend="mlx",- data=SimpleNamespace(model_fields_set=set()),- training=TrainingConfig(- loss_watchdog=True,- loss_spike_recovery=True,- grad_accum_auto_tune=True,- ),+ def test_loadable_monitoring_defaults_report_no_gaps(self) -> None:+ cfg = SoupConfig(+ base="test/model", task="sft", backend="mlx",+ data={"train": "data.jsonl"},+ training={"loss_watchdog": False, "loss_spike_recovery": False,+ "grad_accum_auto_tune": False},)- reported = {e.field for e in check_config(cfg)}- assert "training.loss_watchdog" in reported- assert "training.loss_spike_recovery" in reported- assert "training.grad_accum_auto_tune" in reported+ assert check_config(cfg) == []class TestMlxTrainerCheckUnsupported:@@ -184,9 +168,8 @@ class TestReasonStringsByteIdenticalAcrossSurfaces:assert prefix in msgschema_reason = msg.split(prefix)[1].strip()- # 2. Registry reason extracted from backend_support.py- registry_entries = {e.field: e.reason for e in unsupported_for("sft", "mlx")}- registry_reason = registry_entries[f"training.{field}"]+ # Refused values cannot reach doctor, so there is no registry reason.+ assert f"training.{field}" not in {e.field for e in unsupported_for("sft", "mlx")}# 3. Trainer warning reason extracted from MLXSFTTrainerWrapper._check_unsupportedwrapper = object.__new__(MLXSFTTrainerWrapper)@@ -209,6 +192,5 @@ class TestReasonStringsByteIdenticalAcrossSurfaces:assert match is not Nonetrainer_reason = match.group(1)- # Assert byte-identical equality across all 3 surfaces- assert schema_reason == registry_reason- assert registry_reason == trainer_reason+ # Keep the load-time refusal and internal trainer guard consistent.+ assert schema_reason == trainer_reasondiff --git a/tests/test_issue1124_sft_audio_stream_unsloth_fp8.py b/tests/test_issue1124_sft_audio_stream_unsloth_fp8.pyindex a5a50b56..dd8f371d 100644--- a/tests/test_issue1124_sft_audio_stream_unsloth_fp8.py+++ b/tests/test_issue1124_sft_audio_stream_unsloth_fp8.py@@ -8,7 +8,7 @@ Validates that:3. backend: unsloth rejects quantization_aware: fp8, fp8_attention, and nvfp4at schema validation time with actionable diagnostics.4. validate_fp8_attention_compat and validate_nvfp4_compat reject unsloth.-5. backend_support declares ("sft", "unsloth", "text") with REJECTED status for precision knobs.+5. Schema-refused precision knobs have no unreachable doctor rows (#1330)."""from __future__ import annotations@@ -369,21 +369,12 @@ class TestUnslothPrecisionRejections:class TestBackendSupportRegistryUnsloth:- """Test that backend_support registers unsloth SFT rejected entries."""+ """Test that schema-refused unsloth precision settings are omitted from doctor."""def test_unsloth_sft_registered(self) -> None:assert ("sft", "unsloth", "text") in REGISTRY- entries = unsupported_for("sft", "unsloth")- fields = {e.field: e.status for e in entries}- assert fields.get("training.quantization_aware") == "rejected"- assert fields.get("training.fp8_attention") == "rejected"- assert fields.get("training.nvfp4") == "rejected"- assert all(e.issue == 1124 for e in entries)-- entries_vision = unsupported_for("sft", "unsloth", "vision")- assert len(entries_vision) == len(entries)- fields_vision = {e.field: e.status for e in entries_vision}- assert fields_vision.get("training.quantization_aware") == "rejected"+ assert unsupported_for("sft", "unsloth") == ()+ assert unsupported_for("sft", "unsloth", "vision") == ()def test_unsloth_sft_in_trainer_modules(self) -> None:assert ("sft", "unsloth", "text") in TRAINER_MODULES@@ -402,8 +393,7 @@ class TestBackendSupportRegistryUnsloth:def test_no_loadable_unsloth_config_sets_quantization_aware(self, value, reason, modality) -> None:- """Every value of the field is refused at load on unsloth, so the REJECTED- row documents the gap rather than reporting it (as the MLX row for #961)."""+ """Every active value is refused at load on unsloth, so doctor has no row."""data = {"train": "tests/fixtures/sample_train.jsonl"}if modality == "vision":data["format"] = "multimodal"@@ -427,12 +417,12 @@ class TestBackendSupportRegistryUnsloth:cfg = SoupConfig(base="test/model", task="sft", backend="unsloth", modality=modality, data=data)- assert unsupported_for("sft", "unsloth", modality), "fallback must cover the modality"+ assert unsupported_for("sft", "unsloth", modality) == ()assert check_config(cfg) == []def test_setup_unsloth_does_not_wire_fp8_silently(self) -> None:"""AST guard: SFTTrainerWrapper._setup_unsloth must not wire precision knobs- while ("sft", "unsloth", "text") declares them REJECTED in backend_support.+ while config validation refuses them for backend=unsloth."""sft_path = Path(__file__).resolve().parents[1] / "src/soup_cli/trainer/sft.py"tree = ast.parse(sft_path.read_text(encoding="utf-8"))diff --git a/tests/test_issue1156_multimodal_mask_history_doctor.py b/tests/test_issue1156_multimodal_mask_history_doctor.pyindex 7cdb2c5a..a7bed053 100644--- a/tests/test_issue1156_multimodal_mask_history_doctor.py+++ b/tests/test_issue1156_multimodal_mask_history_doctor.py@@ -6,8 +6,8 @@ silently ignored because multimodal collators do not implement assistant-turnmasking.backend_support.REGISTRY carries the modality axis (task, backend, modality),-and soup doctor --config reports them as ignored rather than printing an-affirmative all-clear.+and soup doctor --config reports non-default mask_history as ignored.+train_on_responses_only has a true schema default and is not listed (#1330)."""from __future__ import annotations@@ -56,7 +56,7 @@ def test_vision_sft_reports_mask_history_as_ignored():assert entry.issue == 1156-def test_vision_sft_reports_train_on_responses_only_as_ignored():+def test_vision_sft_does_not_report_default_train_on_responses_only():yaml_text = """\base: Qwen/Qwen2-VL-7B-Instructtask: sft@@ -68,11 +68,8 @@ def test_vision_sft_reports_train_on_responses_only_as_ignored():"""cfg = load_config_from_string(textwrap.dedent(yaml_text))gaps = {e.field: e for e in check_config(cfg)}- assert "data.train_on_responses_only" in gaps- entry = gaps["data.train_on_responses_only"]- assert entry.status == IGNORED- assert "multimodal vision collator" in entry.reason- assert entry.issue == 1156+ assert "data.train_on_responses_only" not in gaps+ assert gaps == {}def test_audio_sft_reports_mask_history_as_ignored():@@ -95,7 +92,7 @@ def test_audio_sft_reports_mask_history_as_ignored():assert entry.issue == 1156-def test_audio_sft_reports_train_on_responses_only_as_ignored():+def test_audio_sft_does_not_report_default_train_on_responses_only():yaml_text = """\base: Qwen/Qwen2-Audio-7B-Instructtask: sft@@ -107,11 +104,8 @@ def test_audio_sft_reports_train_on_responses_only_as_ignored():"""cfg = load_config_from_string(textwrap.dedent(yaml_text))gaps = {e.field: e for e in check_config(cfg)}- assert "data.train_on_responses_only" in gaps- entry = gaps["data.train_on_responses_only"]- assert entry.status == IGNORED- assert "audio training" in entry.reason- assert entry.issue == 1156+ assert "data.train_on_responses_only" not in gaps+ assert gaps == {}def test_multimodal_clean_config_reports_no_gaps():@@ -170,10 +164,10 @@ def test_doctor_config_prints_gaps_for_vision_with_mask_history(out = strip_ansi(capsys.readouterr().out)assert "Config check - task=sft backend=transformers modality=vision" in outassert "data.mask_history" in out- assert "data.train_on_responses_only" in out+ assert "data.train_on_responses_only" not in outassert "multimodal vision collator" in outassert (- "2 setting(s) switched on here are not read on backend=transformers (modality=vision)"+ "1 setting(s) switched on here are not read on backend=transformers (modality=vision)"in out)diff --git a/tests/test_issue1330_backend_support_active_values.py b/tests/test_issue1330_backend_support_active_values.pyindex af337818..fcd29f86 100644--- a/tests/test_issue1330_backend_support_active_values.py+++ b/tests/test_issue1330_backend_support_active_values.py@@ -7,7 +7,6 @@ are properly detected.from __future__ import annotations-import reimport textwrapimport pytest@@ -15,8 +14,10 @@ import yamlfrom soup_cli.autopilot.generate_config import write_yamlfrom soup_cli.config.backend_support import (+ IGNORED,REGISTRY,REJECTED,+ SupportEntry,check_config,unsupported_for,)@@ -88,31 +89,7 @@ def test_mlx_config_with_false_settings_reports_zero_gaps(tmp_path, capsys, monk)-# data.train_on_responses_only defaults to true, so write_yaml writes `true` and-# the reloaded vision/audio config reports it. Whether the dump or #1156's-# explicit-true test gives way is still open on #1330; flip these once it is ruled.-_ROUND_TRIP_PENDING_1330 = {- ("sft", "transformers", "vision"),- ("sft", "transformers", "audio"),-}--- "key",- [- pytest.param(- key,- marks=pytest.mark.xfail(- strict=True,- reason="data.train_on_responses_only defaults to true; pending #1330",- ),- )- if key in _ROUND_TRIP_PENDING_1330- else key- for key in REGISTRY- ],- ids=lambda k: "-".join(k),-)[email protected]("key", list(REGISTRY), ids=lambda key: "-".join(key))def test_a_full_dump_reports_what_the_minimal_config_reports(key, tmp_path):"""AC2: A config reloaded after write_yaml gets the same doctor report as the minimal config."""src = tmp_path / "min.yaml"@@ -147,26 +124,28 @@ def test_seed_zero_on_mlx_is_still_reported():assert "training.data_seed" in reported_fields-_REJECTED = [- pytest.param(key, entry, id=f"{'-'.join(key)}-{entry.field}")- for key, entries in REGISTRY.items()- for entry in entries- if entry.status == REJECTED-]+def test_schema_refused_settings_have_no_doctor_rows():+ assert all(entry.status != REJECTED for entries in REGISTRY.values() for entry in entries)[email protected](("key", "entry"), _REJECTED)-def test_a_rejected_rows_active_value_is_refused_at_load(key, entry):- """AC4: Each REJECTED field's active value is refused at load on its own, and its- off value reports nothing, so the row cannot fire on a loadable config."""- section, name = entry.field.split(".", 1)- _load(_config(*key)) # control: the base config itself loads[email protected]("modality", ["vision", "audio"])[email protected]("value", [True, False])+def test_multimodal_response_mask_has_no_unreachable_doctor_row(modality, value):+ config = _config("sft", "transformers", modality)+ config["data"]["train_on_responses_only"] = value+ assert check_config(_load(config)) == []+ assert "data.train_on_responses_only" not in {+ entry.field for entry in unsupported_for("sft", "transformers", modality)+ }- active = _config(*key)- active.setdefault(section, {})[name] = True- with pytest.raises(ValueError, match=re.escape(name)):- _load(active)- off = _config(*key)- off.setdefault(section, {})[name] = False- assert check_config(_load(off)) == []+def test_written_true_schema_default_counts_as_unwritten(monkeypatch):+ """A future true-default registry entry cannot revive spelling-dependent reports."""+ key = ("sft", "transformers", "vision")+ entry = SupportEntry("data.train_on_responses_only", IGNORED, "test gap")+ monkeypatch.setitem(REGISTRY, key, (entry,))+ minimal = _config(*key)+ explicit = _config(*key)+ explicit["data"]["train_on_responses_only"] = True+ assert check_config(_load(minimal)) == []+ assert check_config(_load(explicit)) == []diff --git a/tests/test_issue755_backend_support_registry.py b/tests/test_issue755_backend_support_registry.pyindex 27665574..d01bf777 100644--- a/tests/test_issue755_backend_support_registry.py+++ b/tests/test_issue755_backend_support_registry.py@@ -179,7 +179,13 @@ def test_registry_covers_every_field_the_mlx_trainer_warns_about():unknown = sorted(warned - known)assert unknown == [], f"warning list names fields that do not exist: {unknown}"registered = {e.field for e in unsupported_for("sft", "mlx")}- missing = sorted(warned - registered)+ # These warnings are internal guards for schema-refused monitoring values.+ # Their load-time refusal is pinned by test_issue1069; doctor cannot list them.+ schema_refused = {+ "training.loss_watchdog", "training.loss_spike_recovery",+ "training.grad_accum_auto_tune",+ }+ missing = sorted(warned - registered - schema_refused)assert missing == [], (f"mlx_sft.py warns about {missing} but the registry does not list them")