Repository navigation
Stop the CUDA spoof from deciding whether a GPU test skips - #10864
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7dae996e6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 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(), |
There was a problem hiding this comment.
Preserve CUDA-specific availability in CUDA guards
On an XPU-only host this probe returns True, even though most converted tests still require CUDA explicitly. In particular, tests/utils/test_xformers_capability_gate.py:43 consequently evaluates torch.cuda.get_device_capability() during collection and raises instead of skipping, while several other converted tests allocate tensors with device = "cuda". Cache backend-specific availability results and retain a CUDA-only guard for tests that cannot run on XPU.
Useful? React with 👍 / 👎.
| import _zoo_aggressive_cuda_spoof as spoof | ||
|
|
||
| spoof.apply() |
There was a problem hiding this comment.
Restore torch after exercising the aggressive spoof
On a CPU runner, any pytest invocation that executes this test before another runtime-gated test leaves torch.cuda.is_available() returning True and also retains all the allocator, stream, RNG, and pin-memory patches installed by spoof.apply(). For example, a later tests/test_offload_embedding_hooks.py::test_cuda_input_roundtrip passes its runtime availability check and attempts a real CUDA allocation. Run this assertion in a subprocess or restore every mutated torch attribute afterward so this regression test does not introduce the same cross-test contamination it is meant to guard against.
Useful? React with 👍 / 👎.
| for node in ast.walk(tree): | ||
| if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)): | ||
| continue | ||
| for decorator in node.decorator_list: |
There was a problem hiding this comment.
Scan module-level pytest marks too
This walker only examines function and class decorator lists, so module-level guards such as pytestmark = pytest.mark.skipif(...) are invisible. tests/python/test_embed_lm_head_target_modules_redirect.py:27-30 still contains exactly the spoofable CUDA guard this test intends to forbid, meaning a CPU session that collects it after a compatibility shim can still run its GPU integration tests while this policy test remains green. Include assignment-based module marks in the scan.
Useful? React with 👍 / 👎.
| from real_accelerator import ( | ||
| has_real_accelerator, | ||
| ) # tests/_shared, on sys.path via tests/conftest.py |
There was a problem hiding this comment.
Add the shared helpers to the standalone runner's path
When the documented python tests/fast_inference/test_fast_inference.py invocation is used, pytest never loads tests/conftest.py, and the script only adds the repository root to sys.path; tests/_shared is therefore absent. This new import raises ModuleNotFoundError: No module named 'real_accelerator' before the __main__ CUDA check can run. Add the shared directory explicitly for standalone execution or import the helper through a package-visible path.
Useful? React with 👍 / 👎.
tests/_zoo_aggressive_cuda_spoof.py sets torch.cuda.is_available to return True
and leaves it that way. That is deliberate: unsloth's import chain has to see a
card for the rest of the process. Every module under tests/version_compat and
tests/vllm_compat applies it at import.
pytest imports every selected module before running anything, and a
@pytest.mark.skipif is evaluated at import. So one spoofing module in a session
decides the guard for every module collected after it, in any directory. A test
guarded on `skipif(not torch.cuda.is_available())` then un-skips on a CPU-only
box and dies inside torch with
RuntimeError: Cannot access accelerator device when none is available
which is a message about torch, from a cause that is neither torch nor the test.
Run the same file alone and it skips correctly.
Found while sweeping unsloth's TRL source-transform patches across the supported
range. tests/utils/test_packing.py::test_packing_sdpa and
::test_enable_sample_packing_trl_collator failed on all eight pins from TRL
0.22.2 through 1.13.0, identically, which is what ruled out version drift: the
common factor was tests/version_compat sharing the session.
CI does not hit this today only because the three jobs that touch those
directories each --ignore the others. That is an accident of the current ignore
lists, not a property anything checks, and dropping one --ignore would have
reopened it silently.
tests/_shared/real_accelerator.py records the answer once. tests/conftest.py
primes it at its own import, which is ahead of every test module in the session,
so every later caller gets the pre-spoof answer. conftest keeps
_has_real_accelerator() under that name and keeps its
`if not _has_real_accelerator():` block, because
tests/python/test_conftest_bitsandbytes_preimport.py reads that shape out of
this file's AST.
20 guards across 11 files move over. A grep found 15 of them; the other 5 are
multi-line spellings, including two that wrap the probe in a hasattr() and one
that reads torch.cuda.get_device_capability() in a second decorator. That is why
tests/python/test_accelerator_skip_guards.py walks the ast rather than the text:
a reformatted decorator or a # noqa cannot get past it. It also asserts the
recorded answer survives the spoof, and feeds itself the forbidden shape to prove
the scan is not vacuous.
Checked in both directions, which matters because a broken helper here would
silently skip every GPU test forever rather than fail:
- Polluted session, CPU-only, TRL 0.22.2, before: 2 failed, 192 passed, 37
skipped. After: 0 failed, 192 passed, 39 skipped. The same 192 still pass and
exactly the two failures became skips.
- On a real B200, has_real_accelerator() returns True and both tests still RUN
rather than skipping, so the guards did not simply go dead.
- Whole-suite control: this branch and unmodified origin/main were run through
tests/python/ plus all 11 touched files in the same venv. Both report the same
7 pre-existing failures, byte-identical lists, so this change moves nothing
else.
7dae996 to
c09de55
Compare
…10866) #10864 added tests/python/test_accelerator_skip_guards.py to stop tests gating hardware on a probe the aggressive CUDA spoof patches process-wide. One of its own tests then did exactly the thing the file exists to prevent. test_the_recorded_answer_survives_the_spoof called spoof.apply() in-process. That sets torch.cuda.is_available to return True and never restores it, so the rest of the xdist worker runs believing there is a CUDA card. peft's infer_device() opens with `if torch.cuda.is_available(): return "cuda"`, so tests/test_save_lora_without_vllm.py::test_the_saved_adapter_still_loads_back, scheduled onto the same worker, asked safetensors to load an adapter onto CUDA and died with NotImplementedError: Could not run 'aten::empty_strided' with arguments from the 'CUDA' backend Nothing about that names the cause, and the guard test itself passed. Which victim gets hit depends on how xdist distributes work, so it looked like a flake in an unrelated file for two rounds of investigation. Reproduces deterministically in two files, in this order: pytest tests/python/test_accelerator_skip_guards.py \ tests/test_save_lora_without_vllm.py before: 1 failed, 18 passed after: 20 passed The question now goes to a subprocess, the same pattern tests/vllm_compat/test_unsloth_zoo_imports.py uses since #10855, and for the same reason: a question about global state has to be asked somewhere the answer cannot leak back. Coverage is unchanged, it still asserts the spoof really does patch is_available and that the recorded answer does not move. Also adds test_this_file_never_applies_the_spoof_in_process, an ast check that this file never regains an in-process spoof.apply(). Worth pinning structurally because the damage is invisible at its own site and lands on whichever test the scheduler happens to run next. Full Repo tests (CPU) on this branch: 1 failed, 18523 passed, 497 skipped. The one failure is test_lint_exec_literals::test_the_baseline_matches_the_tree_it_ was_recorded_against, which fails identically on clean d7e5c6b and is a separate matter.
…adratic (#10868) test_deepseek_r1_huge_fenceless_body_is_linear failed on #10864 at 6.56 against a bar of 6.0, on a branch that touches no parser code. It failed the same way on #10825. The parser is fine: measured locally across all four shapes the median 4x ratio is ~4.0, which is what linear looks like. The measurement is what is wrong. _growth computed min(big over repeats) / min(small over repeats) and its comment claimed that dividing one minimum by the other cancels the machine out. It does not. The two minima come from two batches run at different times, so a quiet window during the small batch and a busy window during the big batch multiply rather than cancel, and the quotient of two separately-taken minima is not a minimum of anything. Measured on 2 pinned CPUs under load, 15 trials per shape: strategy R1 R1-distant GLM V3 >= 6.0 min/min max 8.69 max 8.23 max 8.27 max 8.59 7 of 60 paired median max 4.26 max 4.83 max 4.83 max 5.42 0 of 60 End to end, 10 contended runs of the four linearity tests: the old form fails 3 of 10 runs, the new form 0 of 10. Each pair now times the small input and then the big one back to back and forms the ratio inside the pair, so contention hits both halves and divides out, which is what the old comment claimed for the unpaired form. The median across pairs then discards one that got unlucky in either direction. Detection is kept, which is the half worth checking before loosening a bar. Sabotaging the R1 sweep back to quadratic (re-adding a per-marker tail rescan) still fails, at 14.2x and 15.3x. On a synthetic 16x path the new form reports 8 of 8 over the bar, the same as the old one. On the marginal 6.7x shape (#10832's partially fixed sweep) it reports 9 of 12 against the old 10 of 12, a difference well inside the noise at that sample size, and that shape's sibling test measures 12.2x when broken, so the suite still catches it. The bar stays at 6.0. Nothing here loosens the threshold; it only stops the measurement fed to it from being dominated by whoever else is on the runner. The 60 second backstop still reads the BEST big time rather than the worst, so it fires on a path that is genuinely too slow and not on a runner that stalled once.
* Three CI failures that were not the PRs they failed on
Backend CI's (Python 3.13) leg has been failing intermittently on main and on
five open PRs with `KeyError: 'active'` out of
test_video_shape_validation.py, and Repo tests (CPU) has been failing on PRs
whose diffs touch none of the code involved. Three separate causes, all real,
none of them belonging to the branches that went red.
/video/generate-progress declares VideoGenerateProgressResponse but can return
account_access.hidden_resident_response(), which is {"loaded", "yours"} and has
no `active` at all. FastAPI does not validate a returned Response, so the
declared model is bypassed and a poller reading `active` gets a KeyError rather
than "nothing is running". /images/generate-progress has the same three early
returns. Add hidden_generate_progress_response(), beside the existing
hidden_chat_status_response() that already exists for exactly this reason, and
use it on both progress routes: the response model's own defaults are idle, so
the shape costs no privacy.
What made it fire is routes.video._generation_account, a module global written
by _note_generation_account() and never reset. A multi-account test leaves a
foreign id in it and the next test's poll reads as hidden. Six test files reset
it by hand; every other file was exposed. Reset it once in the backend
conftest, off sys.modules so no test pays an import for it.
Reproduces before this change and passes after:
pytest studio/backend/tests/multi_account \
studio/backend/tests/test_video_shape_validation.py
test_save_lora_without_vllm.py let peft resolve the load device. peft's
infer_device() answers "cuda" whenever torch.cuda.is_available() does, and on a
CPU-only runner that is True because tests/_zoo_aggressive_cuda_spoof.py sets it
so deliberately. The safetensors read then dispatches to a CUDA backend that is
not there and the test dies on aten::empty_strided, naming neither peft nor the
spoof. #10864 fixed the skip guards that read the same probe; this is the other
half, where the library reads it at runtime. Pin the device at the call site,
here and at the one other instance in tests/kaggle, and extend
test_accelerator_skip_guards.py so it scans for the shape rather than only for
skipif decorators.
test_rl_config_pickling.py's config sweep was the only construction in that file
that bypassed its own _make() helper, so on a CPU runner TRL's bf16=None resolved
to True and transformers raised before the assertion about pickling ran. That
error is what the sweep reported when the RL patch fell back, which is the thing
the file is actually about. Route it through _make(), filtered against each
config's declared fields, and front the subclass test with an explicit check that
the patch applied, so a fallback reports the patcher instead of
`assert 'TrainingArguments' == 'SFTConfig'`.
Verified against the full backend suite run the way CI runs it: identical
failure set to main, plus one new passing regression test.
* Tighten the comments this branch added
unslothai#10868 replaced the linearity check in test_pr5624_regressions.py after it failed on unslothai#10825 and again on unslothai#10864 at 6.56 against a 6.0 bound, both times on branches that touch none of that code. The same shape is elsewhere in the suite: sub-100ms budgets, two separately-taken durations compared against each other, and concurrency proved by how long four threads took. All of them run under pytest -n 4 on a shared runner, where descheduling is indistinguishable from the regression they guard. Each one is rewritten to assert the thing it is named for. test_llama_cpp_wait_for_vram_settle.py has five, all of them claims about the helper's sleeping: did it skip the wait, nap once per poll, clip the last nap to the deadline. Record the durations it asks for and assert on those. The tightest was elapsed < 0.05 around a short-circuit, which one GC pause exceeds. test_account_model_access.py proved eight probes ran together by taking under 0.4s. Its own sibling two functions up already uses a threading.Barrier for the same claim, so use one here too, sized off _PROBE_FANOUT so lowering the fan-out fails this rather than satisfying a Barrier(1). test_mcp_http_sessions.py had three. Two chats running concurrently needed a counter that spans clients, since no single client's max_live can see an overlap between two of them; six parallel closes get a Barrier(6), so a serial close deadlocks and says so instead of merely running slowly; and the eviction test asserts the caller returned while the victim's teardown was still running, which is the property the 0.5s bound was standing in for. test_stream_cancel_registration_timing.py compared two separately-taken durations, exactly what unslothai#10868 had to remove from _growth. The two patterns differ in chunks seen, deterministically: the blocking loop never lets the cancel through and drains all eight, the awaiting loop stops at the first. Four guards against a quadratic blow-up carried absolute budgets (test_tool_xml_strip.py, test_update_release_notes.py, test_rag_store.py). Backtracking is superlinear by definition, so growth is the property, and unslothai#10868's paired-ratio statistics already exist for it. Lift _growth and _assert_linear out of test_pr5624_regressions.py into tests/_shared/growth.py, generalised over the function under measurement, next to real_accelerator.py and for the same reason. test_profile_stats.py and the two liveness files keep a wall-clock bound, because "it did not block" is what they mean, but a generous one: the sharp claim in each is already asserted next to it (the row count is zero, stop() returned False, the stub raises if detection starts). test_backend_ci_parallel_isolation.py scans for this shape and required three named files to keep exhibiting it, which made it a second, invisible reason those files could not be fixed: rewriting the vram-settle bounds failed there, in a file about CI topology, with a message about a sample. It builds all three shapes itself now. Not touched: test_health_answers_within_probe_budget.py. Its bounds are the subject, derived from the real desktop probe timeout rather than from a guess, and it already asserts on state where state was the honest answer. Each rewritten assertion was checked against a deliberately broken implementation: no cold-start short-circuit, an unclipped sleep, a one-shot wait loop, _PROBE_FANOUT of 1, _MAX_CLOSE_THREADS of 1, and two synthetic quadratic sweeps. Full backend suite run the way CI runs it, three times: identical failure set to main.
#10897) * Stop ten test assertions from measuring the runner instead of the code #10868 replaced the linearity check in test_pr5624_regressions.py after it failed on #10825 and again on #10864 at 6.56 against a 6.0 bound, both times on branches that touch none of that code. The same shape is elsewhere in the suite: sub-100ms budgets, two separately-taken durations compared against each other, and concurrency proved by how long four threads took. All of them run under pytest -n 4 on a shared runner, where descheduling is indistinguishable from the regression they guard. Each one is rewritten to assert the thing it is named for. test_llama_cpp_wait_for_vram_settle.py has five, all of them claims about the helper's sleeping: did it skip the wait, nap once per poll, clip the last nap to the deadline. Record the durations it asks for and assert on those. The tightest was elapsed < 0.05 around a short-circuit, which one GC pause exceeds. test_account_model_access.py proved eight probes ran together by taking under 0.4s. Its own sibling two functions up already uses a threading.Barrier for the same claim, so use one here too, sized off _PROBE_FANOUT so lowering the fan-out fails this rather than satisfying a Barrier(1). test_mcp_http_sessions.py had three. Two chats running concurrently needed a counter that spans clients, since no single client's max_live can see an overlap between two of them; six parallel closes get a Barrier(6), so a serial close deadlocks and says so instead of merely running slowly; and the eviction test asserts the caller returned while the victim's teardown was still running, which is the property the 0.5s bound was standing in for. test_stream_cancel_registration_timing.py compared two separately-taken durations, exactly what #10868 had to remove from _growth. The two patterns differ in chunks seen, deterministically: the blocking loop never lets the cancel through and drains all eight, the awaiting loop stops at the first. Four guards against a quadratic blow-up carried absolute budgets (test_tool_xml_strip.py, test_update_release_notes.py, test_rag_store.py). Backtracking is superlinear by definition, so growth is the property, and #10868's paired-ratio statistics already exist for it. Lift _growth and _assert_linear out of test_pr5624_regressions.py into tests/_shared/growth.py, generalised over the function under measurement, next to real_accelerator.py and for the same reason. test_profile_stats.py and the two liveness files keep a wall-clock bound, because "it did not block" is what they mean, but a generous one: the sharp claim in each is already asserted next to it (the row count is zero, stop() returned False, the stub raises if detection starts). test_backend_ci_parallel_isolation.py scans for this shape and required three named files to keep exhibiting it, which made it a second, invisible reason those files could not be fixed: rewriting the vram-settle bounds failed there, in a file about CI topology, with a message about a sample. It builds all three shapes itself now. Not touched: test_health_answers_within_probe_budget.py. Its bounds are the subject, derived from the real desktop probe timeout rather than from a guess, and it already asserts on state where state was the honest answer. Each rewritten assertion was checked against a deliberately broken implementation: no cold-start short-circuit, an unclipped sleep, a one-shot wait loop, _PROBE_FANOUT of 1, _MAX_CLOSE_THREADS of 1, and two synthetic quadratic sweeps. Full backend suite run the way CI runs it, three times: identical failure set to main. * Size the growth fixtures off the old bound, and derive the liveness ceilings Two review findings, both right. assert_linear measures units AND units * factor, so replacing an absolute budget means passing the old size divided by factor. Three of the five conversions did that; the backtick-run and orphan-opens ones did not, and their big leg ran at 4x anything previously measured. That matters only on the regression each guards: the backtick parser took over a minute at 20k when broken, so at 80k it would take about sixteen, and the job timeout would kill the run before the ratio could say why. The big < 60.0 backstop cannot help, because it is checked after the measurement rather than during it. Both call sites now put the previously measured size on the big leg, and assert_linear says so where a caller reads it. The liveness ceilings were widened to a number with no relation to the product. commands.rs gives each watchdog probe HEALTH_PROBE_TIMEOUT, ten seconds, so a route that blocked for 10 to 29 seconds passed the test while timing out every real probe. Read that constant, as test_health_answers_within_probe_budget.py already does for its own budget, and use half of it: ten times the headroom of the 0.5s it replaces, and provably inside what the launcher allows. * Tighten the comments this branch added * Pin two timing assertions to what they are about, not to slack The eviction test's victim slept 1.5s, which a caller only had to outwait part of to read as prompt; it now holds its teardown on an event the test releases, so a caller that waits on it at all cannot return, and the remaining ceiling comes from _SESSION_CLOSE_TIMEOUT rather than being picked. The writer shutdown test now records the timeout stop() hands its join instead of allowing 5s of wall clock, so a stop() that waits whole seconds fails even though the elapsed budget would have passed it. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Assert both ends of the settle window, and stop buying slack this leg does not need The never-settles case only checked that the helper napped more than once, so a loop capped at two iterations recorded [0.1, 0.1] and passed while the VRAM was still moving. Both ends are now read off the recorded naps. The terminal-callback bound goes back to 1.0s: studio-backend-ci.yml ignores test_profile_stats.py in the -n 4 leg and reruns it serially, so a looser bound only lets a stalling callback through. * Bound liveness against a route that does nothing, not against the watchdog Half the watchdog's probe budget is 5s, which passes a route that grew seconds of synchronous work on the event loop. The probe snippets now serve a route that only returns a dict through the same app and client, so both pay the same interpreter and scheduler and what is left is the route's own cost. The watchdog bound stays as the second half of the pair: a relative bound cannot see an absolute timeout, since a control that took seconds would scale with it. * Bound the eviction call against the same call with nothing to evict Half of _SESSION_CLOSE_TIMEOUT is five seconds, which passes a caller that blocks for a second before handing the victim to the cleanup worker. The cap is now applied after a control call on a second URL, so the two differ only in whether an eviction happens and the claim is measured rather than budgeted. * Take the runner out of the clipping test, abort a known-slow growth run, drop a live dependency The slow-probe test asked for a nap that a correct helper need not make: if the scheduler ate the 0.1s left of the budget it returned at the deadline check instead, and the assertion failed on a good run. It now runs on a clock the test moves, so the probe charges its cost instead of sleeping and every sample is exact. growth() takes abort_over_s, so a big leg already over the backstop stops the repeats instead of measuring the same known-bad path three times. The parallel-isolation meta-test no longer requires the live backend suite to still contain a fragile assertion; the synthetic files cover every shape, and that requirement would have turned cleaning the last one into a failure. * Pair the liveness controls, clock the drift test, ask the eviction by thread A control taken in its own batch shares no scheduler delay with the request it is compared against, so a pause landing on the measurement alone was not divided out and the 50ms floor made that stricter than the bound it replaced. Both liveness snippets now alternate control and measurement and take the best of three on each side. The never-settles test moves to the same fake clock as the slow-probe one: its lower bound says the helper did not stop early, and real time spent outside sleep() retires the deadline without appearing in the naps. The eviction test asks which thread calls close() instead of how long the caller took. __aexit__ cannot answer it, since that always runs on the session's own loop thread, but the caller of close() is exactly the claim in the test's name. * Size the close barrier off the fan-out, and watch the join as well as the close A fixed Barrier(6) deadlocks a correctly batched close configured any narrower than six and then reports it as serial. It now waits for one batch and opens exactly that many sessions, so a partial last batch cannot leave stragglers waiting for a party that never arrives. The eviction test also records joins on the cleanup worker. Handing the teardown off and then waiting on the worker anyway spends the same deadline, and nothing else here can see it: a bounded join leaves the close off the calling thread and the session still open. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Why
tests/_zoo_aggressive_cuda_spoof.pysetstorch.cuda.is_availableto return True and leaves it there. That is deliberate and correct: unsloth's import chain has to see a card for the rest of the process. Every module undertests/version_compatandtests/vllm_compatapplies it at import.pytest imports every selected module before running anything, and a
@pytest.mark.skipifis evaluated at import. So one spoofing module in a session decides the guard for every module collected after it, in any directory. A test guarded onskipif(not torch.cuda.is_available())un-skips on a CPU-only box and dies inside torch with:That is a message about torch, from a cause that is neither torch nor the test. Run the same file alone and it skips correctly, which is what makes it hard to read.
How it turned up
I was sweeping unsloth's TRL source-transform patches across the supported range to check the #10854 anchor fix held.
tests/utils/test_packing.py::test_packing_sdpaand::test_enable_sample_packing_trl_collatorfailed on every pin:The same two, identically, from TRL 0.22.2 to 1.13.0. That ruled out version drift and pointed at the one thing every row had in common:
tests/version_compatwas in the same pytest session.Worth saying that the patches themselves are fine across that whole range, which is what the sweep was for. I also checked
_backport_vision_dataset_gateagainst realsft_trainer.pyfrom thirteen TRL tags: it early-returns from 0.24.0 up, and on 0.22.2 / 0.23.0 all four of itsstr.replacecalls land.Why it is not already red in CI
The three jobs that cover those directories each
--ignorethe others, so they never share a session. That is an accident of the current ignore lists, not a property anything checks. Dropping one--ignore, or adding a job that collects both, would have reopened this silently. So the fix is on the guard side rather than the ignore side.The change
tests/_shared/real_accelerator.pyrecords the answer once.tests/conftest.pyprimes it at its own import, which is ahead of every test module in the session, so every later caller gets the pre-spoof answer no matter what has patchedtorch.cudasince.conftestkeeps_has_real_accelerator()under that name and keeps itsif not _has_real_accelerator():block, becausetests/python/test_conftest_bitsandbytes_preimport.pyreads that shape out of this file's AST.20 guards across 11 files move over. A grep found 15 of them. The other 5 are multi-line spellings, including two that wrap the probe in a
hasattr()and one that readstorch.cuda.get_device_capability()in a second decorator. That is whytests/python/test_accelerator_skip_guards.pywalks theastrather than the text: a reformatted decorator or a# noqacannot get past it. It also asserts the recorded answer survives the spoof, and feeds itself the forbidden shape to prove the scan is not vacuous.Checks
Both directions, because a broken helper here would silently skip every GPU test forever rather than fail, which is the worse outcome and the quieter one.
2 failed, 192 passed, 37 skipped. After:0 failed, 192 passed, 39 skipped. The same 192 still pass, and exactly the two failures became skips.has_real_accelerator()returns True and both tests still run rather than skipping. They then fail onImportError: Please install bitsandbytes, which is that venv and not this change. 87 passed across the converted files.origin/mainwere both run throughtests/python/plus all 11 touched files, same venv, same flags. Both report the same 7 pre-existing failures (test_e2e_no_torch_sandbox,test_rl_config_pickling::test_training_arguments_conversion_keeps_unsloth_fields, and 5 intest_windows_studio_update_launcher), byte-identical lists. So this moves nothing else, and those 7 are a separate matter.ruff check --select E9,F63,F7,F82clean on the touched files, apart from one pre-existingF821intest_packing.pythat is present onorigin/maintoo. The pinnedruff-format-with-kwargshook is a fixed point.