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
Stop the CUDA spoof from deciding whether a GPU test skips (#10864)
Daniel Han9effb893b9f7
diff --git a/tests/_shared/real_accelerator.py b/tests/_shared/real_accelerator.pynew file mode 100644index 00000000000..3a055575155--- /dev/null+++ b/tests/_shared/real_accelerator.py@@ -0,0 +1,73 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.++"""Does this machine have an accelerator, asked so that the CUDA spoof cannot answer.++`torch.cuda.is_available()` is not a safe thing for a test to gate hardware on in+this repo, because two harnesses deliberately make it lie:++- ``tests/conftest.py`` patches it to True for the window in which it pre-loads+ ``unsloth_zoo.device_type``, so ``get_device_type()``'s ``@cache`` captures+ "cuda" on a GPU-less runner. That window is closed in a ``finally``.+- ``tests/_zoo_aggressive_cuda_spoof.py`` patches it to True and leaves it that+ way. It is applied at module import by every file under ``tests/version_compat``+ and ``tests/vllm_compat``, and it is not undoable by design: the whole point is+ that unsloth's import chain sees a card for the rest of the process.++The second one crosses module boundaries. pytest imports every selected test+module before running anything, and a ``@pytest.mark.skipif`` is evaluated at+import, so one spoofing module in the session flips the guard for every other+module collected after it. On a CPU-only box the guarded tests then un-skip and+die inside torch with++ RuntimeError: Cannot access accelerator device when none is available.++which reads like a torch or a driver problem and is neither. Observed on+``pytest tests/utils/test_packing.py tests/version_compat/...`` in one session:+2 failed, and the same two pass when either file is run alone.++CI does not hit this today only because the three jobs that touch these+directories each ``--ignore`` the others. That is an accident of the current+ignore lists, not a property anything checks.++So record the answer once, before anything has had the chance to spoof, and hand+that out afterwards. ``tests/conftest.py`` primes the cache at its own import,+which is ahead of every test module in the session.+"""++from __future__ import annotations++_REAL_ACCELERATOR: bool | None = None+++def _probe() -> bool:+ try:+ import torch+ except Exception:+ return False+ for probe in (+ lambda: hasattr(torch, "cuda") and torch.cuda.is_available(),+ lambda: hasattr(torch, "xpu") and torch.xpu.is_available(),+ lambda: hasattr(torch, "accelerator") and torch.accelerator.is_available(),+ ):+ try:+ if probe():+ return True+ except Exception:+ # A probe that raises is not an accelerator. torch.xpu on a build without+ # XPU support, and torch.accelerator on torch < 2.6, both do this.+ pass+ return False+++def has_real_accelerator() -> bool:+ """True if this machine really has a CUDA / XPU / torch.accelerator device.++ Cached on the first call. ``tests/conftest.py`` makes that first call before+ any spoof runs, so every later caller gets the pre-spoof answer no matter what+ has patched ``torch.cuda`` since.+ """+ global _REAL_ACCELERATOR+ if _REAL_ACCELERATOR is None:+ _REAL_ACCELERATOR = _probe()+ return _REAL_ACCELERATORdiff --git a/tests/conftest.py b/tests/conftest.pyindex 9e082c432d2..acbb4224aae 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -62,21 +62,17 @@ def _contain_installer_venv_root(tmp_path_factory, monkeypatch):def _has_real_accelerator() -> bool:- try:- import torch- except Exception:- return False- for probe in (- lambda: hasattr(torch, "cuda") and torch.cuda.is_available(),- lambda: hasattr(torch, "xpu") and torch.xpu.is_available(),- lambda: hasattr(torch, "accelerator") and torch.accelerator.is_available(),- ):- try:- if probe():- return True- except Exception:- pass- return False+ """Mechanism: tests/_shared/real_accelerator.py.++ The probe moved there so test modules can ask the same question, and so the+ answer is recorded once. Calling it here, before the pre-load window below and+ long before any test module imports the aggressive spoof, is what makes the+ recorded answer the pre-spoof one for everybody. Kept as a function of this+ name because tests/python/test_conftest_bitsandbytes_preimport.py reads the+ `if not _has_real_accelerator():` block out of this file's AST.+ """+ from real_accelerator import has_real_accelerator+ return has_real_accelerator()def _preload_device_type(package: str, prereqs: tuple[str, ...] = ()) -> bool:diff --git a/tests/fast_inference/test_fast_inference.py b/tests/fast_inference/test_fast_inference.pyindex 0eea3361ce7..b0a9585f248 100644--- a/tests/fast_inference/test_fast_inference.py+++ b/tests/fast_inference/test_fast_inference.py@@ -26,6 +26,9 @@ REPO_ROOT = Path(__file__).parents[2]sys.path.insert(0, str(REPO_ROOT))import pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torchfrom tests.utils import header_footer_context@@ -83,7 +86,7 @@ def _metric(metrics, *names):return None[email protected](not torch.cuda.is_available(), reason = "fast_inference needs a CUDA GPU + vLLM")[email protected](not has_real_accelerator(), reason = "fast_inference needs a CUDA GPU + vLLM")def test_fast_inference():# Import here, not at module load: importing unsloth probes for an accelerator and errors on CPU-only machines, so# deferring keeps pytest collection and the skip path import-free. Unsloth must precede TRL.diff --git a/tests/python/test_accelerator_skip_guards.py b/tests/python/test_accelerator_skip_guards.pynew file mode 100644index 00000000000..eb254424070--- /dev/null+++ b/tests/python/test_accelerator_skip_guards.py@@ -0,0 +1,157 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team.+"""No test may gate hardware on a call this repo's own harnesses spoof.++`tests/_zoo_aggressive_cuda_spoof.py` sets `torch.cuda.is_available` to return+True and leaves it there. It is applied at module import by everything under+`tests/version_compat` and `tests/vllm_compat`. pytest imports every selected+module before running anything and evaluates `@pytest.mark.skipif` at import, so+one spoofing module in a session decides the guard for every module collected+after it, whatever directory it lives in.++A guard written as `skipif(not torch.cuda.is_available())` therefore un-skips on+a CPU-only box as soon as it shares a session with one of those files, and the+test dies inside torch with `RuntimeError: Cannot access accelerator device when+none is available` -- a message about torch, from a cause that is neither torch+nor the test.++CI is only clear of this because the three jobs covering those directories each+`--ignore` the others. Nothing enforced that, and dropping one `--ignore` would+have reopened it silently, so enforce the guard side instead:+`tests/_shared/real_accelerator.py` records the answer before any spoof runs.++Scanned with ast rather than grep so a reformatted decorator, a multi-line+`skipif(...)` or a `# noqa` cannot walk past it.+"""++from __future__ import annotations++import ast+from pathlib import Path++import pytest+++_TESTS_ROOT = Path(__file__).resolve().parents[1]++# The spoof itself, the recorded-answer helper and conftest are what implement the+# real probe. They are the only places allowed to call the raw torch API for it.+_ALLOWED = {+ _TESTS_ROOT / "_zoo_aggressive_cuda_spoof.py",+ _TESTS_ROOT / "_shared" / "real_accelerator.py",+ _TESTS_ROOT / "conftest.py",+}++_SPOOFED_CALLS = {+ ("torch", "cuda", "is_available"),+ ("torch", "xpu", "is_available"),+ ("torch", "accelerator", "is_available"),+}+++def _dotted(node: ast.AST) -> tuple[str, ...]:+ parts: list[str] = []+ while isinstance(node, ast.Attribute):+ parts.append(node.attr)+ node = node.value+ if isinstance(node, ast.Name):+ parts.append(node.id)+ return tuple(reversed(parts))+ return ()+++def _skipif_calls(tree: ast.AST):+ """Every `pytest.mark.skipif(...)` decorator call in the module."""+ for node in ast.walk(tree):+ if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):+ continue+ for decorator in node.decorator_list:+ if not isinstance(decorator, ast.Call):+ continue+ if _dotted(decorator.func)[-1:] == ("skipif",):+ yield decorator+++def _python_test_files():+ for path in sorted(_TESTS_ROOT.rglob("*.py")):+ if path in _ALLOWED:+ continue+ if "__pycache__" in path.parts:+ continue+ yield path+++def test_no_skip_guard_reads_a_spoofable_accelerator_probe():+ offenders = []+ for path in _python_test_files():+ try:+ tree = ast.parse(path.read_text(encoding = "utf-8"))+ except SyntaxError:+ # tests/python/ holds fixtures that are deliberately unparseable on this+ # interpreter (the 3.9 floor checks). Not our business.+ continue+ for decorator in _skipif_calls(tree):+ for call in ast.walk(decorator):+ if isinstance(call, ast.Call) and _dotted(call.func) in _SPOOFED_CALLS:+ offenders.append(+ f"{path.relative_to(_TESTS_ROOT)}:{call.lineno}: "+ f"{'.'.join(_dotted(call.func))}()"+ )+ assert not offenders, (+ "these skip guards read a probe tests/_zoo_aggressive_cuda_spoof.py patches to "+ "True process-wide, so they un-skip on a CPU-only box whenever they share a "+ "pytest session with tests/version_compat or tests/vllm_compat. Use "+ "`from real_accelerator import has_real_accelerator` instead:\n " + "\n ".join(offenders)+ )+++def test_the_recorded_answer_survives_the_spoof():+ """The property the helper exists for, asserted rather than assumed.++ Primed by conftest before collection, so by the time this runs the aggressive+ spoof may or may not have been applied depending on what else is in the+ session. Apply it here and check the recorded answer does not move.+ """+ import sys++ sys.path.insert(0, str(_TESTS_ROOT))+ from real_accelerator import has_real_accelerator++ before = has_real_accelerator()++ import _zoo_aggressive_cuda_spoof as spoof++ spoof.apply()++ import torch++ assert torch.cuda.is_available() is True, (+ "the spoof no longer patches torch.cuda.is_available, so this test is not "+ "checking anything; re-point it at whatever it patches now"+ )+ assert has_real_accelerator() is before, (+ "has_real_accelerator() moved after the spoof was applied, which is the whole "+ "thing it is supposed to be immune to"+ )+++ "probe", ["torch.cuda.is_available", "torch.xpu.is_available", "torch.accelerator.is_available"]+)+def test_the_scanner_would_catch_a_regression(probe, tmp_path):+ """The scan is not vacuous: hand it the shape it forbids and it must object."""+ offending = tmp_path / "test_offending.py"+ offending.write_text(+ "import pytest\nimport torch\n\n\n"+ f"@pytest.mark.skipif(not {probe}(), reason = 'needs a GPU')\n"+ "def test_x():\n pass\n",+ encoding = "utf-8",+ )+ tree = ast.parse(offending.read_text(encoding = "utf-8"))+ found = [+ call+ for decorator in _skipif_calls(tree)+ for call in ast.walk(decorator)+ if isinstance(call, ast.Call) and _dotted(call.func) in _SPOOFED_CALLS+ ]+ assert len(found) == 1diff --git a/tests/studio/test_gpu_inference_smoke.py b/tests/studio/test_gpu_inference_smoke.pyindex ccc55b8cc3e..92c540ba468 100644--- a/tests/studio/test_gpu_inference_smoke.py+++ b/tests/studio/test_gpu_inference_smoke.py@@ -15,6 +15,9 @@ check, not a benchmark. Select/deselect it by name, e.g. `-k gpu_generation`.from __future__ import annotationsimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pytorch = pytest.importorskip("torch")@@ -27,7 +30,7 @@ MIN_NEW_TOKENS = 4MAX_NEW_TOKENS = 16[email protected](not torch.cuda.is_available(), reason = "requires a CUDA GPU")[email protected](not has_real_accelerator(), reason = "requires a CUDA GPU")def test_gpu_generation_smoke():try:from transformers import AutoModelForCausalLM, AutoTokenizerdiff --git a/tests/test_cross_entropy_softcap_padding.py b/tests/test_cross_entropy_softcap_padding.pyindex bdbd5ce8a3f..fc670e5fa03 100644--- a/tests/test_cross_entropy_softcap_padding.py+++ b/tests/test_cross_entropy_softcap_padding.py@@ -2,13 +2,16 @@# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.import pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torchimport torch.nn.functional as Fpytestmark = pytest.mark.gpu[email protected](not torch.cuda.is_available(), reason = "CUDA Triton kernels required")[email protected](not has_real_accelerator(), reason = "CUDA Triton kernels required")@pytest.mark.parametrize("dtype", [torch.float32, torch.float16, torch.bfloat16])@pytest.mark.parametrize("vocab_size,softcap,offset",@@ -43,7 +46,7 @@ def test_cross_entropy_softcap_padding(dtype, vocab_size, softcap, offset):torch.testing.assert_close(logits.grad, reference_logits.grad, rtol = 1e-2, atol = 1e-7)[email protected](not torch.cuda.is_available(), reason = "CUDA Triton kernels required")[email protected](not has_real_accelerator(), reason = "CUDA Triton kernels required")@pytest.mark.parametrize("vocab_size", [32000, 65537, 256000])@pytest.mark.parametrize("logit_scaling", [0.0625, 0.5, 2.0])def test_cross_entropy_softcap_padding_with_logit_scaling(vocab_size, logit_scaling):@@ -73,7 +76,7 @@ def test_cross_entropy_softcap_padding_with_logit_scaling(vocab_size, logit_scaltorch.testing.assert_close(logits.grad, reference_logits.grad, rtol = 1e-2, atol = 1e-7)[email protected](not torch.cuda.is_available(), reason = "CUDA Triton kernels required")[email protected](not has_real_accelerator(), reason = "CUDA Triton kernels required")@pytest.mark.parametrize("vocab_size", [32000, 65537])@pytest.mark.parametrize("softcap", [0.0, 30.0])def test_negative_logit_scaling_does_not_nan(vocab_size, softcap):@@ -101,7 +104,7 @@ def test_negative_logit_scaling_does_not_nan(vocab_size, softcap):torch.testing.assert_close(actual, expected, rtol = 1e-5, atol = 1e-5)[email protected](not torch.cuda.is_available(), reason = "CUDA Triton kernels required")[email protected](not has_real_accelerator(), reason = "CUDA Triton kernels required")@pytest.mark.parametrize("vocab_size", [32000, 65537, 256000, 262208])def test_softcapped_probabilities_sum_to_one(vocab_size):"""Guards the denominator without leaning on a loss tolerance."""diff --git a/tests/test_dispatch_hook_repair.py b/tests/test_dispatch_hook_repair.pyindex 45fa6c44ba4..67566a4b871 100644--- a/tests/test_dispatch_hook_repair.py+++ b/tests/test_dispatch_hook_repair.py@@ -17,6 +17,9 @@ import sysimport typesimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pytorch = pytest.importorskip("torch")pytest.importorskip("accelerate")@@ -490,7 +493,7 @@ def test_the_repair_stands_aside_for_an_offloaded_embedding():@pytest.mark.skipif(- not torch.cuda.is_available(),+ not has_real_accelerator(),reason = "needs two real devices; `cpu` plus one card is enough, a CPU-only runner is not",)def test_the_whole_sequence_against_real_accelerate():diff --git a/tests/test_float32_generate_autocast.py b/tests/test_float32_generate_autocast.pyindex a746a0bd2f2..b9f6c84d007 100644--- a/tests/test_float32_generate_autocast.py+++ b/tests/test_float32_generate_autocast.py@@ -41,6 +41,9 @@ import sysfrom pathlib import Pathimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torchREPO_ROOT = Path(__file__).resolve().parents[1]@@ -100,7 +103,7 @@ def test_the_gate_by_execution(dtype, expected):assert (dtype in (torch.float16, torch.bfloat16)) is expected[email protected](not torch.cuda.is_available(), reason = "needs a CUDA device")[email protected](not has_real_accelerator(), reason = "needs a CUDA device")def test_cuda_really_does_accept_float32_as_an_autocast_dtype():"""The premise. If torch ever starts rejecting or ignoring this, the fixabove is no longer load-bearing and this test says so rather than letting@@ -110,7 +113,7 @@ def test_cuda_really_does_accept_float32_as_an_autocast_dtype():assert torch.get_autocast_dtype("cuda") == torch.float32[email protected](not torch.cuda.is_available(), reason = "needs a CUDA device")[email protected](not has_real_accelerator(), reason = "needs a CUDA device")def test_the_gate_turns_that_into_a_no_op():dtype = torch.float32with torch.autocast(diff --git a/tests/test_offload_frozen_module_device.py b/tests/test_offload_frozen_module_device.pyindex ded9b7c68dd..0a78cc32a6d 100644--- a/tests/test_offload_frozen_module_device.py+++ b/tests/test_offload_frozen_module_device.py@@ -28,6 +28,9 @@ card is testable on any box, including CI runners with no GPU.import typesimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torch@@ -180,7 +183,7 @@ def test_a_module_without_modules_to_save_is_untouched():assert plain.to_calls == [][email protected](not torch.cuda.is_available(), reason = "needs a CUDA device")[email protected](not has_real_accelerator(), reason = "needs a CUDA device")def test_on_real_hardware_a_module_on_the_current_card_is_unchanged():class _Real:def __init__(self):diff --git a/tests/test_rmsnorm_gradient_layout.py b/tests/test_rmsnorm_gradient_layout.pyindex e687c140782..1cc74dd5323 100644--- a/tests/test_rmsnorm_gradient_layout.py+++ b/tests/test_rmsnorm_gradient_layout.py@@ -2,12 +2,15 @@# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.import pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torchpytestmark = pytest.mark.gpu[email protected](not torch.cuda.is_available(), reason = "CUDA Triton kernels required")[email protected](not has_real_accelerator(), reason = "CUDA Triton kernels required")@pytest.mark.parametrize("gemma", [False, True])@pytest.mark.parametrize("layout", ["contiguous", "columns", "rows", "expanded"])@pytest.mark.parametrize("dtype", [torch.float32, torch.float16, torch.bfloat16])@@ -44,7 +47,7 @@ def test_rmsnorm_backward_gradient_layout(gemma, layout, dtype):torch.testing.assert_close(actual_inputs.grad, reference_inputs.grad, rtol = 2e-2, atol = 1e-2)[email protected](not torch.cuda.is_available(), reason = "CUDA Triton kernels required")[email protected](not has_real_accelerator(), reason = "CUDA Triton kernels required")@pytest.mark.parametrize("gemma", [False, True])@pytest.mark.parametrize("dtype", [torch.float32, torch.float16, torch.bfloat16])def test_rmsnorm_forward_column_strided_input(gemma, dtype):@@ -74,7 +77,7 @@ def test_rmsnorm_forward_column_strided_input(gemma, dtype):torch.testing.assert_close(source.grad, reference_source.grad, rtol = 2e-2, atol = 1e-2)[email protected](not torch.cuda.is_available(), reason = "CUDA Triton kernels required")[email protected](not has_real_accelerator(), reason = "CUDA Triton kernels required")@pytest.mark.parametrize("gemma", [False, True])@pytest.mark.parametrize("layout", ["contiguous", "columns", "expanded"])@pytest.mark.parametrize("dtype", [torch.float32, torch.float16, torch.bfloat16])diff --git a/tests/test_uma_safetensors_load.py b/tests/test_uma_safetensors_load.pyindex 6507e529fe2..0d72647345d 100644--- a/tests/test_uma_safetensors_load.py+++ b/tests/test_uma_safetensors_load.py@@ -17,6 +17,9 @@ import typesfrom pathlib import Pathimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pytorch = pytest.importorskip("torch")safetensors_torch = pytest.importorskip("safetensors.torch")@@ -170,7 +173,7 @@ def test_cpu_target_is_passthrough(uma, force_uma, monkeypatch, tiny_safetensors@pytest.mark.skipif(- not (hasattr(torch, "cuda") and torch.cuda.is_available()),+ not has_real_accelerator(),reason = "needs a GPU for the host->device clone-and-move path",)def test_cuda_target_clones_and_moves(uma, force_uma, monkeypatch, tiny_safetensors):@@ -190,7 +193,7 @@ def test_cuda_target_clones_and_moves(uma, force_uma, monkeypatch, tiny_safetens@pytest.mark.skipif(- not (hasattr(torch, "cuda") and torch.cuda.is_available()),+ not has_real_accelerator(),reason = "needs a GPU for the low-memory fallback path",)def test_low_memory_falls_back_to_direct_move(uma, force_uma, monkeypatch, tiny_safetensors):diff --git a/tests/utils/test_attn_mask_compat.py b/tests/utils/test_attn_mask_compat.pyindex 8d98774c76e..d2b799feb9c 100644--- a/tests/utils/test_attn_mask_compat.py+++ b/tests/utils/test_attn_mask_compat.py@@ -12,6 +12,9 @@ from pathlib import Pathfrom unittest import mockimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torch_REPO_ROOT = Path(__file__).resolve().parents[2]@@ -131,7 +134,7 @@ def test_prepare_4d_causal_attention_mask_for_sdpa_matches_transformers(assert torch.equal(actual, expected)[email protected](not torch.cuda.is_available(), reason = "needs CUDA")[email protected](not has_real_accelerator(), reason = "needs CUDA")@pytest.mark.parametrize("attention_mask,past_length",[diff --git a/tests/utils/test_packing.py b/tests/utils/test_packing.pyindex cc66fcdc01f..7065e0fafd8 100644--- a/tests/utils/test_packing.py+++ b/tests/utils/test_packing.py@@ -34,6 +34,9 @@ from types import SimpleNamespacefrom unittest.mock import patchimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torchfrom datasets import Dataset, IterableDatasetfrom trl import SFTConfig, SFTTrainer@@ -1050,9 +1053,7 @@ def test_enable_sample_packing_only_requires_torch_call():assert torch.equal(batch["packed_seq_lengths"], torch.tensor([2, 1, 3], dtype = torch.int32))- not torch.cuda.is_available(), reason = "builds a real 4bit model on an accelerator"-)[email protected](not has_real_accelerator(), reason = "builds a real 4bit model on an accelerator")def test_enable_sample_packing_trl_collator(tmp_path):if torch.cuda.is_available():device = torch.device("cuda")@@ -1114,9 +1115,7 @@ def test_enable_padding_free_metadata():assert trainer.args.remove_unused_columns is False- not torch.cuda.is_available(), reason = "builds a real 4bit model on an accelerator"-)[email protected](not has_real_accelerator(), reason = "builds a real 4bit model on an accelerator")def test_packing_sdpa(tmp_path):if torch.cuda.is_available():device = torch.device("cuda")diff --git a/tests/utils/test_xformers_capability_gate.py b/tests/utils/test_xformers_capability_gate.pyindex 0560b4e80fb..18a82ef7504 100644--- a/tests/utils/test_xformers_capability_gate.py+++ b/tests/utils/test_xformers_capability_gate.py@@ -4,6 +4,9 @@ SDPA packed-mask fallback). The gate now probes the real op instead of guessingcompute-capability major version."""import pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.pyimport torchimport unsloth # noqa: F401@@ -33,11 +36,11 @@ def test_capability_gate(capability, probe_result, expect_disabled):@pytest.mark.skipif(- not (torch.cuda.is_available() and ad.HAS_XFORMERS),+ not (has_real_accelerator() and ad.HAS_XFORMERS),reason = "needs a CUDA GPU with a working xformers build",)@pytest.mark.skipif(- torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 12,+ has_real_accelerator() and torch.cuda.get_device_capability()[0] >= 12,reason = "on real sm_120+ the probe legitimately returns False when the build ships no ""sm_120 kernel, so asserting True there would be a false failure",)