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
test: run windows-latest train() tests on aten_half_matmuls instead of skipping (#1401)
Urooj Fatima Mukhtara7a26fc7af83
diff --git a/tests/_windows_ci.py b/tests/_windows_ci.pyindex 18f3c81a..83909d65 100644--- a/tests/_windows_ci.py+++ b/tests/_windows_ci.py@@ -1,9 +1,10 @@"""THE ``windows-latest`` illegal-instruction guard (#382). One definition.-Imported by every test file that reaches a real ``trainer.train()``. It lives-here rather than in one of those files because the guard has now been needed in-four of them, and this repo has been bitten three times by a predicate that was-copied instead of shared (#372, #392, #424). ``test_windows_ci_guard_is_not_+Imported by the test files whose real ``trainer.train()`` still crashes that+fleet: today only the two NF4 tests in ``test_v07202.py``. It lives here rather+than in that file because the guard has been needed in four files over time, and+this repo has been bitten three times by a predicate that was copied instead of+shared (#372, #392, #424). ``test_windows_ci_guard_is_not_duplicated`` fails if a second copy appears.Before reaching for the skip, look at the crash frame. When it is a CPU bf16 or@@ -25,11 +26,14 @@ import pytestdef _windows_ci() -> bool:"""True on a GitHub ``windows-latest`` runner, false on a Windows dev box.- #382 — part of GitHub's ``windows-latest`` fleet lacks an instruction the- bitsandbytes wheel emits, so the first test that reaches a real- ``trainer.train()`` dies with ``Windows fatal exception: code 0xc000001d``- (ILLEGAL_INSTRUCTION): a faulthandler dump, no Python exception, and a dead- interpreter. Occurrences so far span py3.10, py3.11 and py3.12, so it tracks+ #382 — part of GitHub's ``windows-latest`` fleet dies with ``Windows fatal+ exception: code 0xc000001d`` (ILLEGAL_INSTRUCTION) in some real training+ steps: a faulthandler dump, no Python exception, and a dead interpreter. Two+ causes are known. For the two NF4 tests in ``test_v07202.py`` it is an+ instruction the bitsandbytes wheel emits, and those tests still use this skip.+ For the others it was the first CPU bf16/fp16 matmul in oneDNN or MKL (#1314),+ which the ``aten_half_matmuls`` fixture avoids, so they request the fixture+ instead. Occurrences so far span py3.10, py3.11 and py3.12, so it tracksthe runner CPU rather than the interpreter; the control is that ``1715261``is the crashing tree ``7c9a931`` plus one line of markdown and came backgreen on the same pool.diff --git a/tests/test_issue382_windows_ci_guard_is_shared.py b/tests/test_issue382_windows_ci_guard_is_shared.pyindex 300aa6d7..f10ff616 100644--- a/tests/test_issue382_windows_ci_guard_is_shared.py+++ b/tests/test_issue382_windows_ci_guard_is_shared.py@@ -8,9 +8,12 @@ original guard did not cover. Copying the predicate would have been the thirdtime this repo shipped a duplicated source of truth (#372, #392, #424), so itmoved to ``tests/_windows_ci.py`` and both call sites import it.-These tests exist so a future copy fails loudly instead of drifting. Four files-carry the guard now, and each one's guarded tests are named in-:data:`GUARDED_TESTS` so a deleted decorator fails here too.+These tests exist so a future copy fails loudly instead of drifting. One file+carries the guard now: the two NF4 tests in ``test_v07202.py``, whose crash is+the bitsandbytes wheel. The others traced to CPU bf16/fp16 matmuls (#1314) and+request ``aten_half_matmuls`` instead (#1359). Both sets are named here, in+:data:`GUARDED_TESTS` and :data:`FIXTURE_TESTS`, so a deleted decorator or a+dropped fixture fails here too."""from __future__ import annotations@@ -27,15 +30,10 @@ from tests._windows_ci import _windows_ci, skip_on_windows_ci_TESTS_DIR = Path(__file__).resolve().parent_HOME = _TESTS_DIR / "_windows_ci.py"-#: The files that gate a real ``trainer.train()`` behind the shared guard. Four-#: now: #382 (v07202), the 2026-08-31 GRPO crash (v05311), and the two from-#: #1018's rewind batch (#1059 and #1062).-KNOWN_CALL_SITES = (- "test_v07202.py",- "test_v05311.py",- "test_rewind_hf.py",- "test_rewind_wiring.py",-)+#: The files that gate a real ``trainer.train()`` behind the shared guard. One+#: now: #382 (v07202). v05311, test_rewind_hf and test_rewind_wiring dropped it+#: in #1359, once #1314 traced their crash to CPU half-precision matmuls.+KNOWN_CALL_SITES = ("test_v07202.py",)class TestThereIsExactlyOneDefinition:@@ -116,11 +114,19 @@ class TestTheGuardStaysNarrow:#: is the same silent-drift failure the guard itself exists to prevent, one#: level up.GUARDED_TESTS: dict[str, tuple[str, ...]] = {- "test_v05311.py": ("test_real_trl_grpotrainer_end_to_end_step",),"test_v07202.py": ("test_one_nf4_training_step_actually_runs","test_the_saved_adapter_is_canonical",),+}++#: Every test that runs a real CPU bf16/fp16 step and requests+#: ``aten_half_matmuls`` instead of the skip (#1314, #1359). Dropping the fixture+#: from one of them sends its matmuls back to oneDNN / MKL, which is the path that+#: crashes part of the windows-latest fleet, so each must keep requesting it.+#: ``test_rewind_wiring.py`` is not here: its run trains fp32 and never needed it.+FIXTURE_TESTS: dict[str, tuple[str, ...]] = {+ "test_v05311.py": ("test_real_trl_grpotrainer_end_to_end_step",),"test_rewind_hf.py": ("test_recorded_rows_match_sampler_order","test_grad_accum_step_and_micro_sequence",@@ -131,7 +137,6 @@ GUARDED_TESTS: dict[str, tuple[str, ...]] = {"test_resumed_run_disables_the_recorder","test_packing_is_refused_and_unpacked_control_records",),- "test_rewind_wiring.py": ("test_hf_training_run_records_every_row_once",),}@@ -142,6 +147,21 @@ def _decorator_names(node: ast.AST) -> set:}+def _param_names(node: ast.FunctionDef) -> set:+ return {arg.arg for arg in node.args.args}+++def _find_test(filename: str, target: str) -> ast.FunctionDef:+ tree = ast.parse((_TESTS_DIR / filename).read_text(encoding="utf-8"))+ found = [+ node+ for node in ast.walk(tree)+ if isinstance(node, ast.FunctionDef) and node.name == target+ ]+ assert found, f"{filename}::{target} not found — did it move or get renamed?"+ return found[0]++class TestTheCrashingTestsAreActuallyGuarded:"""Each crash site must CARRY the marker, not merely import it."""@@ -150,14 +170,8 @@ class TestTheCrashingTestsAreActuallyGuarded:[(f, t) for f, targets in GUARDED_TESTS.items() for t in targets],)def test_the_guarded_test_carries_the_marker(self, filename, target):- tree = ast.parse((_TESTS_DIR / filename).read_text(encoding="utf-8"))- found = [- node- for node in ast.walk(tree)- if isinstance(node, ast.FunctionDef) and node.name == target- ]- assert found, f"{filename}::{target} not found — did it move or get renamed?"- assert "skip_on_windows_ci" in _decorator_names(found[0]), (+ node = _find_test(filename, target)+ assert "skip_on_windows_ci" in _decorator_names(node), (f"{filename}::{target} runs a real trainer.train() and must carry the "f"#382 guard")@@ -167,6 +181,24 @@ class TestTheCrashingTestsAreActuallyGuarded:assert set(GUARDED_TESTS) == set(KNOWN_CALL_SITES)+class TestTheHalfPrecisionTestsRequestTheFixture:+ """Each test that swapped the skip for ``aten_half_matmuls`` must keep it."""++ @pytest.mark.parametrize(+ "filename, target",+ [(f, t) for f, targets in FIXTURE_TESTS.items() for t in targets],+ )+ def test_the_test_requests_the_fixture(self, filename, target):+ node = _find_test(filename, target)+ assert "aten_half_matmuls" in _param_names(node), (+ f"{filename}::{target} runs a CPU bf16/fp16 step and must request "+ f"aten_half_matmuls (#1314)"+ )+ assert "skip_on_windows_ci" not in _decorator_names(node), (+ f"{filename}::{target} requests aten_half_matmuls and must not also skip; "+ f"if it needs the #382 skip back, move it to GUARDED_TESTS and link the log"+ )+@pytest.mark.skipif(os.environ.get("CI") == "true" and sys.platform == "win32",reason="the control below asserts the unskipped state",diff --git a/tests/test_rewind_hf.py b/tests/test_rewind_hf.pyindex c1f65626..5f31638b 100644--- a/tests/test_rewind_hf.py+++ b/tests/test_rewind_hf.py@@ -12,7 +12,6 @@ import pytestpytest.importorskip("trl")from soup_cli.trainer import rewind_hf # noqa: E402-from tests._windows_ci import skip_on_windows_ci # noqa: E402MODEL_ID = "hf-internal-testing/tiny-random-LlamaForCausalLM"@@ -185,8 +184,7 @@ def test_row_losses_mean_equals_trl_scalar(tmp_path):# ---------------------------------------------------------------------------@skip_on_windows_ci-def test_recorded_rows_match_sampler_order(tmp_path, monkeypatch):+def test_recorded_rows_match_sampler_order(tmp_path, monkeypatch, aten_half_matmuls):sink = FakeSink()trainer = _trainer(tmp_path)state = _attach_spy(monkeypatch, trainer, sink)@@ -207,8 +205,7 @@ def test_recorded_rows_match_sampler_order(tmp_path, monkeypatch):# ---------------------------------------------------------------------------@skip_on_windows_ci-def test_grad_accum_step_and_micro_sequence(tmp_path, monkeypatch):+def test_grad_accum_step_and_micro_sequence(tmp_path, monkeypatch, aten_half_matmuls):sink = FakeSink()trainer = _trainer(tmp_path,@@ -228,8 +225,7 @@ def test_grad_accum_step_and_micro_sequence(tmp_path, monkeypatch):# ---------------------------------------------------------------------------@skip_on_windows_ci-def test_eval_passes_record_nothing(tmp_path, monkeypatch):+def test_eval_passes_record_nothing(tmp_path, monkeypatch, aten_half_matmuls):sink = FakeSink()trainer = _trainer(tmp_path,@@ -261,8 +257,7 @@ def test_eval_passes_record_nothing(tmp_path, monkeypatch):# ---------------------------------------------------------------------------@skip_on_windows_ci-def test_rows_recorded_with_dataloader_workers(tmp_path, monkeypatch):+def test_rows_recorded_with_dataloader_workers(tmp_path, monkeypatch, aten_half_matmuls):sink = FakeSink()trainer = _trainer(tmp_path, dataloader_num_workers=2)state = _attach_spy(monkeypatch, trainer, sink)@@ -281,8 +276,9 @@ def test_rows_recorded_with_dataloader_workers(tmp_path, monkeypatch):# ---------------------------------------------------------------------------@skip_on_windows_ci-def test_factory_is_cached_and_unattached_trainer_records_nothing(tmp_path, monkeypatch):+def test_factory_is_cached_and_unattached_trainer_records_nothing(+ tmp_path, monkeypatch, aten_half_matmuls+ ):from trl import SFTTrainercls = rewind_hf.make_rewind_trainer_class(SFTTrainer)@@ -309,9 +305,8 @@ def test_factory_is_cached_and_unattached_trainer_records_nothing(tmp_path, monk# ---------------------------------------------------------------------------@skip_on_windows_cidef test_row_losses_failure_disables_recorder_without_stopping_training(- tmp_path, monkeypatch+ tmp_path, monkeypatch, aten_half_matmuls):recording_console = _recording_console(monkeypatch)@@ -368,8 +363,7 @@ def test_disable_reason_is_escaped_not_parsed_as_markup(monkeypatch, reason):assert reason in console.export_text()-@skip_on_windows_ci-def test_resumed_run_disables_the_recorder(tmp_path, monkeypatch):+def test_resumed_run_disables_the_recorder(tmp_path, monkeypatch, aten_half_matmuls):"""Accelerate's SkipBatchSampler enumerates the wrapped sampler on resume, soskipped rows would reach the FIFO while compute_loss never runs for them."""first = _trainer(tmp_path, wrap=False, save_strategy="steps", save_steps=1)@@ -389,8 +383,7 @@ def test_resumed_run_disables_the_recorder(tmp_path, monkeypatch):assert "resumed runs" in console.export_text()-@skip_on_windows_ci-def test_packing_is_refused_and_unpacked_control_records(tmp_path, monkeypatch):+def test_packing_is_refused_and_unpacked_control_records(tmp_path, monkeypatch, aten_half_matmuls):"""packing=True turns on TRL's padding_free: B=1 micro-batches, one id poppedeach, the rest leaking forever."""console = _recording_console(monkeypatch)diff --git a/tests/test_rewind_wiring.py b/tests/test_rewind_wiring.pyindex c52bb5ab..e6429374 100644--- a/tests/test_rewind_wiring.py+++ b/tests/test_rewind_wiring.py@@ -16,7 +16,6 @@ import pytestfrom soup_cli.config.schema import TrainingConfigfrom soup_cli.monitoring.rewind_log import RewindLog, dataset_fingerprint, read_rewind_log-from tests._windows_ci import skip_on_windows_cidef test_rewind_log_defaults_on_and_can_be_turned_off():@@ -54,13 +53,6 @@ def test_hf_rewind_log_false_builds_the_plain_trainer_and_no_file(tmp_path, monkassert not (tmp_path / "out" / RewindLog.FILENAME).exists()-# #382 via #1062: a real `trainer.train()` over a real tiny Llama, WITH the-# rewind recorder attached -- the same shape as the crash site in-# test_rewind_hf.py. Not every real train dies on those runners: on both-# 0xc000001d cells (runs 35228388681 and 35254266989) the full fine-tune tests in-# test_issue341_seed_and_fullft.py passed at 12%, long before the crash at 41%.-# So the marker follows the recorder, not `.train()` in general.-@skip_on_windows_cidef test_hf_training_run_records_every_row_once(tmp_path, monkeypatch):wrapper, dataset = _hf_wrapper(tmp_path, monkeypatch)wrapper.setup(dataset)diff --git a/tests/test_v05311.py b/tests/test_v05311.pyindex bd4b1f3e..d0b0ae89 100644--- a/tests/test_v05311.py+++ b/tests/test_v05311.py@@ -10,8 +10,6 @@ import mathimport pytest-from tests._windows_ci import skip_on_windows_ci-# Skip the whole module when torch is unavailable — the math kernels are# torch-based by design.torch = pytest.importorskip("torch")@@ -755,8 +753,7 @@ class TestGRPOVariantRuntimeContract:# rft computes NLL on positive advantages whereas gspo uses centered ratioassert losses["rft"] != losses["gspo"]- @skip_on_windows_ci- def test_real_trl_grpotrainer_end_to_end_step(self, tmp_path):+ def test_real_trl_grpotrainer_end_to_end_step(self, tmp_path, aten_half_matmuls):"""End-to-end single step with real trl.GRPOTrainer and tiny model."""from datasets import Datasetfrom transformers import AutoTokenizer, GPT2Config, GPT2LMHeadModel