Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

fix(doctor): report config gaps only when set to active values (#1336)

yi1119890509684bd
diff --git a/changelog.d/0.75.1/1336.fixed.md b/changelog.d/0.75.1/1336.fixed.md
new file mode 100644
index 00000000..cddd3b48
--- /dev/null
+++ b/changelog.d/0.75.1/1336.fixed.md
@@ -0,0 +1 @@
+- **`soup doctor --config` no longer reports a setting written in its off position (#1330 by @Yi-111-a in #1336).** A config that wrote `loss_watchdog: false` or `use_liger: false` on `backend: mlx` was listed as ignored or rejected, so a config written out in full by `soup autopilot` got 15 rows where the same values written minimally got none. A setting is now reported only when its value is switched on; `seed: 0` still counts as set.
diff --git a/docs/commands.md b/docs/commands.md
index 5e1aa09c..c728515a 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -259,7 +259,7 @@ soup bench train --config soup.yaml --steps 20 --warmup 3 -o bench-train.json T
soup bench <model> --backend auto Auto-detect transformers/mlx backend (v0.53.9)
soup serve --reasoning-parser deepseek-r1 Strip <think> blocks from responses (v0.53.9)
soup doctor [--nccl] [--disk] [--config F] Check environment (optionally check NCCL bandwidth, media type; --disk ~9s cold / ~2.4s warm).
- --config also reports which settings that config writes are not read on its task/backend (#755); exits 2 if it cannot be read, and exits 1 when a required core dependency is missing, or when any installed package is beyond its declared ceiling — core or [train] (#828, #874).
+ --config also reports which settings that config switches on (a `false` or unset value is not reported; `seed: 0` is) that its task/backend does not read (#755, #1330); exits 2 if it cannot be read, and exits 1 when a required core dependency is missing, or when any installed package is beyond its declared ceiling — core or [train] (#828, #874).
soup monitor NVIDIA / Apple Silicon GPU monitor: util / temp / VRAM / power
soup quickstart [--dry-run] Full demo
soup plugins list|install|enable|disable Manage Soup plugins
diff --git a/src/soup_cli/commands/doctor.py b/src/soup_cli/commands/doctor.py
index 36bfd64e..6216040d 100644
--- a/src/soup_cli/commands/doctor.py
+++ b/src/soup_cli/commands/doctor.py
@@ -360,9 +360,10 @@ def _installed_version_str(import_name: str, pkg_name: str) -> str | None:
def _check_config_support(config_path: str) -> None:
"""#755 — report the settings this config sets that its backend never reads.
- Only fields the user actually wrote are listed. A wall of 275 rows is not a
- pre-flight check, and the fields sitting at their schema default are not
- what anyone came here to ask about.
+ Only fields the user wrote and switched on are listed (a ``false`` or unset
+ value is not; ``seed: 0`` is). A wall of 275 rows is not a pre-flight check,
+ and the fields sitting at their schema default or written in their off
+ position are not what anyone came here to ask about.
"""
from soup_cli.config.backend_support import (
DEFAULT_BACKEND,
@@ -407,7 +408,7 @@ def _check_config_support(config_path: str) -> None:
modality_msg = f" modality={modality}" if modality != DEFAULT_MODALITY else ""
console.print(
f" [green]None of the {len(known)} setting(s) known to be unread "
- f"on task={cfg.task} backend={backend}{modality_msg} is set in this config.[/]"
+ f"on task={cfg.task} backend={backend}{modality_msg} is switched on in this config.[/]"
)
return
@@ -424,7 +425,7 @@ def _check_config_support(config_path: str) -> None:
console.print(table)
modality_summary = f" (modality={modality})" if modality != DEFAULT_MODALITY else ""
console.print(
- f" [yellow]{len(gaps)} setting(s) written here are not read on "
+ f" [yellow]{len(gaps)} setting(s) switched on here are not read on "
f"backend={backend}{modality_summary}.[/]"
)
diff --git a/src/soup_cli/config/backend_support.py b/src/soup_cli/config/backend_support.py
index 192268c2..70a8f401 100644
--- a/src/soup_cli/config/backend_support.py
+++ b/src/soup_cli/config/backend_support.py
@@ -27,8 +27,9 @@ reviewed for them.
from __future__ import annotations
-from dataclasses import dataclass
-from typing import TYPE_CHECKING
+from collections.abc import Callable
+from dataclasses import dataclass, field
+from typing import TYPE_CHECKING, Any
from soup_cli.utils.advanced_precision import (
UNSLOTH_PRECISION_INCOMPATIBLE_REASON,
@@ -55,6 +56,16 @@ DEFAULT_BACKEND = "transformers"
DEFAULT_MODALITY = "text"
+def _default_active(value: Any) -> bool:
+ """A setting is active when it is switched on (truthy)."""
+ return bool(value)
+
+
+def _seed_active(value: Any) -> bool:
+ """0 is a valid random seed, so any non-None value is active."""
+ return value is not None
+
+
@dataclass(frozen=True)
class SupportEntry:
"""One declared gap: a field, what happens to it, and why."""
@@ -69,6 +80,7 @@ class SupportEntry:
#: (this is what happens to ``max_grad_norm`` when #750 lands), and a
#: ``True`` entry the trainer stops reading means the warning was deleted.
trainer_reads: bool = False
+ active: Callable[[Any], bool] = field(default=_default_active, compare=False, repr=False)
def describe(self) -> str:
suffix = f" (#{self.issue})" if self.issue else ""
@@ -86,12 +98,14 @@ _MLX_SFT: tuple[SupportEntry, ...] = (
IGNORED,
"MLX seeds through mx.random, not this field",
trainer_reads=True,
+ active=_seed_active,
),
SupportEntry(
"training.data_seed",
IGNORED,
"MLX seeds through mx.random, not this field",
trainer_reads=True,
+ active=_seed_active,
),
SupportEntry(
"training.use_galore",
@@ -320,9 +334,11 @@ 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 are reported. Pydantic's ``model_fields_set``
- distinguishes those from the ones sitting at their schema default, which is
- the difference between a useful pre-flight check and a wall of 275 rows.
+ Only fields the user wrote and switched on are reported. Pydantic's
+ ``model_fields_set`` distinguishes the written fields from the ones sitting
+ at their schema default, which is the difference between a useful pre-flight
+ check 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.
"""
backend = getattr(cfg, "backend", DEFAULT_BACKEND)
modality = getattr(cfg, "modality", DEFAULT_MODALITY)
@@ -330,12 +346,14 @@ def check_config(cfg: "SoupConfig") -> list[SupportEntry]:
if not entries:
return []
- written: set[str] = set()
+ written: dict[str, Any] = {}
for namespace in ("training", "data"):
section = getattr(cfg, namespace, None)
if section is None:
continue
for name in getattr(section, "model_fields_set", ()):
- written.add(f"{namespace}.{name}")
+ written[f"{namespace}.{name}"] = getattr(section, name)
- return [entry for entry in entries if entry.field in written]
+ return [
+ entry for entry in entries if entry.field in written and entry.active(written[entry.field])
+ ]
diff --git a/tests/test_issue1156_multimodal_mask_history_doctor.py b/tests/test_issue1156_multimodal_mask_history_doctor.py
index f79bd455..7cdb2c5a 100644
--- a/tests/test_issue1156_multimodal_mask_history_doctor.py
+++ b/tests/test_issue1156_multimodal_mask_history_doctor.py
@@ -173,7 +173,7 @@ def test_doctor_config_prints_gaps_for_vision_with_mask_history(
assert "data.train_on_responses_only" in out
assert "multimodal vision collator" in out
assert (
- "2 setting(s) written here are not read on backend=transformers (modality=vision)"
+ "2 setting(s) switched on here are not read on backend=transformers (modality=vision)"
in out
)
@@ -201,7 +201,7 @@ def test_doctor_config_prints_all_clear_when_no_unread_flags_set(
n = len(unsupported_for("sft", "transformers", "vision"))
expected_msg = (
f"None of the {n} setting(s) known to be unread on task=sft "
- f"backend=transformers modality=vision is set"
+ f"backend=transformers modality=vision is switched on"
)
assert expected_msg in out
@@ -232,6 +232,6 @@ def test_mlx_reports_unread_flags_regardless_of_modality(
assert "Config check - task=sft backend=mlx modality=vision" in out
assert "training.seed" in out
assert (
- "1 setting(s) written here are not read on backend=mlx (modality=vision)"
+ "1 setting(s) switched on here are not read on backend=mlx (modality=vision)"
in out
)
diff --git a/tests/test_issue1330_backend_support_active_values.py b/tests/test_issue1330_backend_support_active_values.py
new file mode 100644
index 00000000..af337818
--- /dev/null
+++ b/tests/test_issue1330_backend_support_active_values.py
@@ -0,0 +1,172 @@
+"""Tests for Issue #1330: soup doctor --config reports settings by spelling, not value.
+
+Ensures that settings written in their inactive state (e.g. false) do not produce
+false positive 'ignored' or 'rejected' rows, and that active values like seed: 0
+are properly detected.
+"""
+
+from __future__ import annotations
+
+import re
+import textwrap
+
+import pytest
+import yaml
+
+from soup_cli.autopilot.generate_config import write_yaml
+from soup_cli.config.backend_support import (
+ REGISTRY,
+ REJECTED,
+ check_config,
+ unsupported_for,
+)
+from soup_cli.config.loader import load_config, load_config_from_string
+from tests.conftest import strip_ansi
+
+_FORMAT = {"text": "alpaca", "vision": "llava", "audio": "chatml"}
+
+
+def _config(task: str, backend: str, modality: str) -> dict:
+ """The smallest config that loads for a registered (task, backend, modality)."""
+ cfg = {
+ "base": "test/model",
+ "task": task,
+ "backend": backend,
+ "data": {"train": "./data/train.jsonl", "format": _FORMAT[modality]},
+ "output": "./output",
+ }
+ if modality != "text":
+ cfg["modality"] = modality
+ return cfg
+
+
+def _load(cfg: dict):
+ return load_config_from_string(yaml.safe_dump(cfg, sort_keys=False))
+
+
+def test_mlx_config_with_false_settings_reports_zero_gaps(tmp_path, capsys, monkeypatch):
+ """AC1: An MLX config with inactive/false settings gets the all-clear (0 rows)."""
+ from rich.console import Console
+
+ import soup_cli.commands.doctor as doctor_module
+ from soup_cli.commands.doctor import doctor
+
+ monkeypatch.setattr(doctor_module, "console", Console(width=200))
+ config_text = textwrap.dedent(
+ """\
+ base: mlx-community/Qwen2.5-0.5B-Instruct-4bit
+ task: sft
+ backend: mlx
+ data:
+ train: ./data/train.jsonl
+ format: alpaca
+ training:
+ epochs: 1
+ loss_watchdog: false
+ loss_spike_recovery: false
+ grad_accum_auto_tune: false
+ quantization_aware: false
+ use_liger: false
+ lora:
+ r: 8
+ alpha: 16
+ output: ./output
+ """
+ )
+ cfg_file = tmp_path / "c7_mlx_false.yaml"
+ cfg_file.write_text(config_text, encoding="utf-8")
+
+ cfg = load_config(str(cfg_file))
+ assert check_config(cfg) == []
+
+ doctor(nccl=False, disk=False, config=str(cfg_file))
+ out = strip_ansi(capsys.readouterr().out)
+ n = len(unsupported_for("sft", "mlx", "text"))
+ assert (
+ f"None of the {n} setting(s) known to be unread on task=sft backend=mlx "
+ "is switched on in this config." in out
+ )
+
+
+# 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),
+)
+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"
+ src.write_text(yaml.safe_dump(_config(*key), sort_keys=False), encoding="utf-8")
+ minimal = load_config(str(src))
+ dump = tmp_path / "dump.yaml"
+ write_yaml(minimal, dump)
+ full = load_config(str(dump))
+ assert [e.field for e in check_config(full)] == [e.field for e in check_config(minimal)]
+
+
+def test_seed_zero_on_mlx_is_still_reported():
+ """AC3: training.seed: 0 and data_seed: 0 on MLX are still reported (0 is an active seed)."""
+ yaml_text = textwrap.dedent(
+ """\
+ base: mlx-community/Qwen2.5-0.5B-Instruct-4bit
+ task: sft
+ backend: mlx
+ data:
+ train: ./data/train.jsonl
+ format: alpaca
+ training:
+ epochs: 1
+ seed: 0
+ data_seed: 0
+ output: ./output
+ """
+ )
+ cfg = load_config_from_string(yaml_text)
+ reported_fields = {g.field for g in check_config(cfg)}
+ assert "training.seed" in reported_fields
+ 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
+]
+
+
[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
+
+ 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)) == []