Skip to content

Stop the CUDA test spoofs reporting an exhausted card - #8123

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
danielhanchen:fix/cuda-spoof-reports-zero-free
Aug 8, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
danielhanchen:fix/cuda-spoof-reports-zero-free

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The bug

Both CUDA spoofs answer mem_get_info as (0, 80 * 1024**3):

  • tests/conftest.py:100, whose docstring says it returns "plausible Ampere values"
  • tests/_zoo_aggressive_cuda_spoof.py, in _CudaRt.cudaMemGetInfo

That tuple is (free, total), so what it actually describes is a card with nothing left. And torch.cuda.mem_get_info delegates to cudart().cudaMemGetInfo, so patching only the torch.cuda.memory binding does not help: the aggressive spoof's zero is what every caller sees.

Anything that sizes work against the free pool then refuses to run. unsloth_zoo's fused cross entropy takes half of it as its chunk target:

free, total = torch.cuda.mem_get_info(0)
target_gb = min(free / 1024**3 * 0.5, 4.0)
if target_gb <= 1e-9:
    raise RuntimeError("Unsloth: No or negligible GPU memory available for fused cross entropy.")

so it raises rather than chunking, and tests/version_compat/test_trl_fake_train_cpu.py::test_sft_trains_on_cpu fails on a host with four completely idle GPUs. The error names GPU memory, so it reads as a product bug until you look at the fixture.

CI does not run that file (studio-backend-ci.yml passes --ignore=tests/version_compat, and version-compat-ci.yml runs only the pinned-symbol files), which is why this has been red only locally.

The change

Both spoofs report 60GB free of 80GB. Nothing else about them moves.

tests/test_cuda_spoof_reports_free_memory.py holds every mem_get_info spoof in the suite to a positive free figure that does not exceed the total, and to at least 8GB, since half the free pool is the fused loss's chunk target and it caps that at 4GB. It reads the sources with ast rather than importing them, because importing either spoof mutates the interpreter's torch for whatever runs next. It fails on main for both files.

Tests

tests/version_compat/ goes from 1 failed, 1580 passed to 1620 passed, 191 skipped together with the rest of the spoof consumers (tests/studio/test_xpu_spoof_pipeline.py, tests/test_gguf_basename_platform_matrix.py, tests/vllm_compat/).

Two failures in tests/vllm_compat/test_unsloth_zoo_imports.py are unrelated and reproduce identically on a clean main checkout.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

danielhanchen and others added 4 commits August 8, 2026 03:21
Both spoofs answer mem_get_info as (0, 80GB). That tuple is (free, total),
so it describes a card with nothing left rather than the plausible Ampere
values the docstring promises, and torch.cuda.mem_get_info delegates
straight to cudart().cudaMemGetInfo, so the aggressive spoof's zero reaches
everything.

Code that sizes work against the free pool then refuses to run at all.
unsloth_zoo's fused cross entropy takes half of it as its chunk target and
raises

  RuntimeError: Unsloth: No or negligible GPU memory available for fused
  cross entropy.

instead of chunking, which fails tests/version_compat/test_trl_fake_train_cpu.py
::test_sft_trains_on_cpu on a host with four idle GPUs. CI does not run that
file, so this has been red only locally.

Both now report 60GB free of 80GB, and a source-level test holds every
mem_get_info spoof to a positive free figure that does not exceed the total.
@danielhanchen
danielhanchen force-pushed the fix/cuda-spoof-reports-zero-free branch from 4ccce27 to f48eb68 Compare August 8, 2026 03:21
@danielhanchen
danielhanchen merged commit 7e5df70 into unslothai:main Aug 8, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant