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: mark sweep setup failures as failed (#1464) (#1640)
Jay Song49c6c2ffdca1
diff --git a/changelog.d/0.75.1/1640.fixed.md b/changelog.d/0.75.1/1640.fixed.mdnew file mode 100644index 00000000..5d846f30--- /dev/null+++ b/changelog.d/0.75.1/1640.fixed.md@@ -0,0 +1,2 @@+- `soup sweep` now marks an arm as failed when trainer construction or setup raises,+ preventing stuck `running` rows in the experiment tracker (#1464 by @deximple in #1640)diff --git a/src/soup_cli/commands/sweep.py b/src/soup_cli/commands/sweep.pyindex 13b71f29..bdb8f5c6 100644--- a/src/soup_cli/commands/sweep.py+++ b/src/soup_cli/commands/sweep.py@@ -512,16 +512,16 @@ def _run_single(base_cfg, params: dict, run_name: str, config_path: Path) -> dicexperiment_name=run_name,)- # Build trainer — the same dispatch `soup train` uses (#1213). This used to- # be a second, shorter chain that never grew past v0.40.0, so ten task- # values and every `backend: mlx` config were trained as plain SFT here- # while the tracker recorded the configured task.- trainer_wrapper = build_trainer(cfg, device=device)- trainer_wrapper.setup(dataset)-- # Train- display = TrainingDisplay(cfg, device_name=device_name)try:+ # Build trainer — the same dispatch `soup train` uses (#1213). This used to+ # be a second, shorter chain that never grew past v0.40.0, so ten task+ # values and every `backend: mlx` config were trained as plain SFT here+ # while the tracker recorded the configured task.+ trainer_wrapper = build_trainer(cfg, device=device)+ trainer_wrapper.setup(dataset)++ # Train+ display = TrainingDisplay(cfg, device_name=device_name)result = trainer_wrapper.train(display=display, tracker=tracker, run_id=run_id)tracker.finish_run(run_id=run_id,@@ -533,8 +533,10 @@ def _run_single(base_cfg, params: dict, run_name: str, config_path: Path) -> dic)result["run_id"] = run_idreturn result- except Exception:- tracker.fail_run(run_id)+ except Exception as exc:+ from soup_cli.commands.train import _describe_exception_for_tracker++ tracker.fail_run(run_id, error=_describe_exception_for_tracker(exc))raisediff --git a/tests/test_sweep.py b/tests/test_sweep.pyindex 0f226410..41f62cbb 100644--- a/tests/test_sweep.py+++ b/tests/test_sweep.py@@ -347,3 +347,38 @@ def test_a_failed_arm_prints_its_error_verbatim(plain = " ".join(re.sub(r"\x1b\[[0-9;]*m", "", result.output).split())assert 'pip install "soup-cli[mlx]"' in plain, plain++[email protected]("failure_stage", ["construction", "setup"])+def test_sweep_setup_failure_marks_run_failed(tmp_path, monkeypatch, failure_stage):+ """An arm that fails before training must not remain running (#1464)."""+ from unittest.mock import Mock++ from soup_cli.commands.sweep import _run_single+ from soup_cli.config.schema import SoupConfig+ from soup_cli.experiment.tracker import ExperimentTracker++ cfg = SoupConfig(base="test/model", data={"train": "data.jsonl"})+ failure = OSError("repo not found")+ trainer = Mock()+ factory = Mock(return_value=trainer)+ if failure_stage == "construction":+ factory.side_effect = failure+ else:+ trainer.setup.side_effect = failure++ monkeypatch.setattr("soup_cli.trainer.dispatch.build_trainer", factory)+ monkeypatch.setattr("soup_cli.data.loader.load_dataset", lambda *a, **kw: {"train": [{}]})+ monkeypatch.setattr("soup_cli.utils.gpu.detect_device", lambda: ("cpu", "CPU"))+ monkeypatch.setattr("soup_cli.utils.gpu.get_gpu_info", lambda: {})++ with pytest.raises(OSError) as excinfo:+ _run_single(cfg, {}, "sweep_1", tmp_path / "soup.yaml")++ assert excinfo.value is failure+ trainer.train.assert_not_called()+ runs = ExperimentTracker().list_runs()+ assert len(runs) == 1+ assert runs[0]["experiment_name"] == "sweep_1"+ assert runs[0]["status"] == "failed", runs[0]+ assert runs[0]["error_message"] == "OSError: repo not found", runs[0]