Skip to content

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.

tests: skip two version_compat suites where the daily sweep has no torch (#12274)

Wayne Sletcher735b9e4051a3
diff --git a/tests/studio/test_version_compat_bundle.py b/tests/studio/test_version_compat_bundle.py
index 854ed0e3fa0..fdd2632d692 100644
--- a/tests/studio/test_version_compat_bundle.py
+++ b/tests/studio/test_version_compat_bundle.py
@@ -26,7 +26,10 @@ wired up fails here too, which is the same bug arriving from the other direction
from __future__ import annotations
+import os
import re
+import subprocess
+import sys
from pathlib import Path
import yaml
@@ -40,6 +43,11 @@ SUITE_DIRS = ("tests/version_compat", "tests/vllm_compat")
# whole file quietly asserting nothing.
BUNDLE_JOB = "pinned-symbol-matrix"
+# Cron-only; sweeps tests/version_compat/ with only pytest installed.
+SWEEP_JOB = "daily-fresh-fetch"
+# A None entry in sys.modules makes `import` raise and find_spec return None, as in that job.
+NOT_IN_THE_SWEEP = ("torch", "numpy", "transformers", "trl", "peft", "accelerate", "unsloth_zoo")
+
# Suites with no pull_request home today.
# This is a RECORDED GAP, not an approval, and both entries pre-date the bundling change that added this file.
# Neither can join the bundle, because the bundle installs nothing but pytest: test_import_leaves_torch_globals_alone.py
@@ -141,6 +149,33 @@ def test_the_bundle_does_not_duplicate_the_install_bearing_jobs() -> None:
)
+def test_the_daily_sweep_skips_what_it_cannot_import() -> None:
+ """A suite that needs torch must skip in the sweep, not fail (#12069 broke it daily on `import unsloth`).
+
+ Bundle suites are left out: they install nothing, already run per pull request, and fetch from the network.
+ """
+ sweep = _named_paths(_jobs()[SWEEP_JOB])
+ bundle = _named_paths(_jobs()[BUNDLE_JOB])
+ suites = sorted(s for s in _all_suites() if _covers(sweep, s) and s not in bundle)
+ assert suites, f"{SWEEP_JOB} sweeps none of {SUITE_DIRS}; retarget this test"
+
+ hide = f"import sys\nfor m in {NOT_IN_THE_SWEEP!r}: sys.modules[m] = None\nimport pytest\nsys.exit(pytest.main())"
+ proc = subprocess.run(
+ [sys.executable, "-c", hide, "-q", "-p", "no:cacheprovider", *suites],
+ cwd = REPO,
+ env = {**os.environ, "PYTHONPATH": str(REPO)},
+ capture_output = True,
+ text = True,
+ timeout = 600,
+ )
+ failed = [line for line in proc.stdout.splitlines() if line.startswith(("FAILED", "ERROR"))]
+ assert proc.returncode == 0 and not failed, (
+ f"{SWEEP_JOB} would go red: these fail without {NOT_IN_THE_SWEEP[0]} rather than skip. Guard them the way "
+ f"their neighbours do, `if importlib.util.find_spec('torch') is None: pytest.skip(...)`.\n"
+ + ("\n".join(failed[:20]) or proc.stdout[-3000:] + proc.stderr[-3000:])
+ )
+
+
def test_the_bundle_stays_parallel_and_file_scoped() -> None:
"""Without -n the bundle is six jobs' work run end to end on one runner.
diff --git a/tests/version_compat/test_pref_max_length_clamp.py b/tests/version_compat/test_pref_max_length_clamp.py
index 65d34828a9b..d86013c5e19 100644
--- a/tests/version_compat/test_pref_max_length_clamp.py
+++ b/tests/version_compat/test_pref_max_length_clamp.py
@@ -77,6 +77,9 @@ def test_model_without_a_limit_is_untouched():
@pytest.mark.parametrize("trainer", ["DPOTrainer", "KTOTrainer"])
def test_patched_trainer_carries_the_clamp(trainer):
+ # daily-fresh-fetch has only pytest; the tests above read rl.py as text and still run there.
+ if importlib.util.find_spec("torch") is None:
+ pytest.skip("torch not installed")
import unsloth # noqa: F401
import trl
diff --git a/tests/version_compat/test_trl_config_defaults_contract.py b/tests/version_compat/test_trl_config_defaults_contract.py
index 9d657b14ce7..be5c1359470 100644
--- a/tests/version_compat/test_trl_config_defaults_contract.py
+++ b/tests/version_compat/test_trl_config_defaults_contract.py
@@ -9,11 +9,16 @@ from __future__ import annotations
import dataclasses
import importlib
+import importlib.util
import math
import pytest
+# daily-fresh-fetch collects this directory with only pytest installed.
+if importlib.util.find_spec("torch") is None:
+ pytest.skip("torch not installed", allow_module_level = True)
+
# Fields Unsloth changes on purpose (rl.py replacements, extra_args, or TRL deriving them from those).
INTENDED = {
"auto_find_batch_size",