Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Block compile: test that checkpoint early-stop does not demote the layer (#14065)
Indrajit swaind477ae88e89d
diff --git a/tests/test_block_compile.py b/tests/test_block_compile.pyindex fd82936b22f..7148f7d589a 100644--- a/tests/test_block_compile.py+++ b/tests/test_block_compile.py@@ -131,6 +131,28 @@ def test_compile_failure_falls_back(monkeypatch, fails_in):assert calls == []+def test_stop_recomputation_does_not_demote(monkeypatch):+ """#14063: checkpoint early-stop is control flow; demoting on it raised CheckpointError."""+ from torch.utils.checkpoint import _StopRecomputationError++ M = _load()++ def fake_compile(fn, **kwargs):+ def compiled(*args, **kw):+ raise _StopRecomputationError()++ return compiled++ monkeypatch.setattr(torch, "compile", fake_compile)+ cls = _toy_class()+ M._wrap(cls, {})+ layer = cls()+ with pytest.raises(_StopRecomputationError):+ layer(torch.randn(2, 4, 8, requires_grad = True))+ assert layer._unsloth_block_mode == M._FIRST_MODE+ assert layer.__dict__.get("_unsloth_block_checked", 0) == 0++def test_cache_calls_keep_the_stock_forward(monkeypatch):from transformers.cache_utils import DynamicCachediff --git a/tests/test_ddp_comm_defaults.py b/tests/test_ddp_comm_defaults.pyindex 6e75f226318..17481048cd1 100644--- a/tests/test_ddp_comm_defaults.py+++ b/tests/test_ddp_comm_defaults.py@@ -19,13 +19,26 @@ import _ddp_comm_defaults_worker as worker # noqa: E402pytestmark = pytest.mark.skipif(sys.platform == "win32", reason = "two gloo ranks over TCP localhost")++def _bf16_hook_supported():+ # Mirrors DistributedDataParallel._check_comm_hook: a torch build check, not a GPU or+ # backend check. CPU wheels refuse bf16_compress_hook with TypeError even on gloo (#14065 CI).+ try:+ import torch.distributed as dist+ built = torch.version.cuda is not None or torch.version.hip is not None+ return built and dist.is_nccl_available() and torch.cuda.nccl.version() >= (2, 10)+ except Exception:+ return False++CASES = [("full", "full", {}, {}),("full_off", "full", {"UNSLOTH_DDP_GRADIENT_AS_BUCKET_VIEW": "0"}, {}),("peft", "peft", {}, {}),- ("bf16_hook", "full", {"UNSLOTH_DDP_COMM_HOOK": "bf16"}, {}),("fp16_hook", "peft", {"UNSLOTH_DDP_COMM_HOOK": "fp16"}, {}),]+if _bf16_hook_supported():+ CASES.append(("bf16_hook", "full", {"UNSLOTH_DDP_COMM_HOOK": "bf16"}, {}))_UTILS = pathlib.Path(__file__).resolve().parents[1] / "unsloth" / "models" / "_utils.py"@@ -112,7 +125,8 @@ def test_lora_keeps_gradients_unaliased(ranks):def test_comm_hook_opt_in(ranks):- for name, kind in (("bf16_hook", "full"), ("fp16_hook", "peft")):+ hook_cases = [(name, kind) for name, kind, *_ in CASES if name.endswith("_hook")]+ for name, kind in hook_cases:case = ranks[0][name]assert case["hooks"] >= 1, name_assert_parity(case, kind, exact = False)