Skip to content

CUDA spoof: cover CUDA wheels on GPU-less runners, not only CPU wheels - #14056

Merged
danielhanchen merged 2 commits into
mainfrom
fix/cuda-spoof-driverless-raw-stream
Oct 17, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix/cuda-spoof-driverless-raw-stream

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

The 2026-10-17 06:39 scheduled Notebooks CI run on main (1018ecbf, run 39010742438) failed the nb/Llama3.1_(8B)-GRPO.ipynb install-cell smoke leg, which passed on the previous scheduled run (2026-10-01):

unsloth/kernels/utils.py:251: torch._C._cuda_getCurrentRawStream(index)
torch.AcceleratorError: CUDA error: CUDA driver version is insufficient for CUDA runtime version

The notebook's non-Colab branch runs pip install unsloth vllm, which now brings in torch 2.13.0+cu130. tests/_zoo_aggressive_cuda_spoof.py only supplied _cuda_getCurrentRawStream when the symbol was absent, which is the CPU-wheel case from #11328. A CUDA wheel on a GPU-less runner has the symbol, but calling it raises, so import unsloth under the spoof died at that line. The product is fine. The spoof did not cover this wheel.

Change

  • tests/_zoo_aggressive_cuda_spoof.py: _cuda_getCurrentRawStream is now replaced when it is absent or when calling it raises. A working handle on a real CUDA machine is still kept.
  • tests/test_cuda_spoof_supplies_the_raw_stream.py: new test_the_spoof_replaces_a_raw_stream_that_has_no_driver_behind_it stages a raw-stream function that raises the driver error and requires the spoof to replace it. The existing test_the_spoof_leaves_a_real_raw_stream_alone still passes.

Testing

  • End to end with the same torch 2.13.0+cu130 and CUDA_VISIBLE_DEVICES="": applying the spoof and then import unsloth fails on main with AcceleratorError: CUDA error: no CUDA-capable device is detected, and passes with this change.
  • Spoof tests: test_cuda_spoof_supplies_the_raw_stream.py and test_cuda_spoof_reports_free_memory.py give 6 passed. With the spoof reverted, the new test fails.
  • Every test file that imports the spoof: this change and main fail on exactly the same test IDs in my local venv, which lacks the pinned TRL / vLLM versions those tests need. This change adds the new passing test.
  • Notebooks CI with include_smoke=true on the first revision of this branch (run 39015954144): the GRPO leg passes. That revision also set UV_SYSTEM_PYTHON on the install step. It turned the Nemotron and Qwen3_5 failures into different ones and broke gpt-oss, so it is not part of this PR (see below).

Not in this PR

The Nemotron-3-Nano and Qwen3_5 Vision legs fail for a different reason, which this PR leaves alone. Their install cells call !uv pip install. Colab sets UV_SYSTEM_PYTHON=true (checked on a live release-colab-external-images_20261014 runtime), but the smoke job does not. The job also sets no COLAB_* variable, so the notebooks take their non-Colab branch.

Setting only UV_SYSTEM_PYTHON lets the uv lines run, but without the Colab branch the result is not Colab's environment:

  • transformers==4.57.6 is installed with --no-deps next to huggingface_hub 1.29.
  • gpt-oss loses triton.

Making the job match Colab needs both variables together, and it should be a separate change with its own smoke run.

The static + transitive resolve red (Colab oracle drifted from its committed snapshot) is also untouched. It has failed on every scheduled run since at least 2026-09-27.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T08:15:56.796847Z 3850e34 Manual request
🔒 Security Review ⚠️ Failed 2026-10-17T08:04:35.727493Z 3a29e95 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 3a29e95b45

ℹ️ 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".

@danielhanchen danielhanchen changed the title Notebooks smoke: run uv the way Colab does, cover driverless CUDA wheels in the spoof CUDA spoof: cover CUDA wheels on GPU-less runners, not only CPU wheels Oct 17, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 3850e34665

ℹ️ 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".

@danielhanchen
danielhanchen merged commit e0dc284 into main Oct 17, 2026
@danielhanchen
danielhanchen deleted the fix/cuda-spoof-driverless-raw-stream branch October 17, 2026 08:24
danielhanchen added a commit that referenced this pull request Oct 17, 2026
## Summary

Two install-cell smoke legs fail on main's scheduled `Notebooks CI`
(2026-10-17 06:39, run 39010742438):
- `nb/Nemotron-3-Nano-30B-A3B_A100.ipynb`
- `nb/Qwen3_5_(4B)_Vision.ipynb`

Both fail like this:

```
error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment
FileNotFoundError: [Errno 2] No such file or directory: 'unsloth'
```

Their install cells use `!uv pip install`, and the next line is
`!unsloth install-kernels` (unslothai/notebooks #385). On Colab the uv
lines work because Colab sets `UV_SYSTEM_PYTHON=true`. I checked this on
a live `release-colab-external-images_20261014` runtime, along with its
`COLAB_*` keys. The smoke job installs into the runner's system
interpreter as a stand-in for Colab's, but its install step set neither:
- uv refused to run.
- The notebooks also took their non-Colab branch, since they choose the
branch on any environment key containing `COLAB_`.

Setting only `UV_SYSTEM_PYTHON` is not enough, which I tried first while
working on #14056. The non-Colab branch then left `transformers==4.57.6`
(installed `--no-deps`) beside `huggingface_hub` 1.29, which it refuses
to import with, and the gpt-oss leg lost `triton`. Colab's own branch
reinstalls with dependencies, so the job has to take that branch to test
what Colab users run.

## Change

- **`notebooks-ci.yml`:** the `Run install cell` step sets
`UV_SYSTEM_PYTHON: 'true'` and a `COLAB_SMOKE_SHAPED: '1'` marker, with
a comment explaining why.
- The marker is scoped to that one step, which stops before `from
unsloth import`.
- Its name matches none of the specific `COLAB_*` keys Unsloth reads
(`COLAB_ENVIRONMENT`, `COLAB_IFRAME_HEIGHT`, ...).
  - `disk_utils`' generic `COLAB_` scan never runs inside that step.
- **`tests/notebooks/test_smoke_install_contract.py`:**
`test_the_install_cell_runs_the_way_colab_does` requires a `COLAB_*` key
and `UV_SYSTEM_PYTHON` on every step that runs the converted install
cell.

## Testing

- **`Notebooks CI` with `include_smoke=true` on this branch (run
39017258647):** all eight smoke legs pass, including Nemotron-3-Nano and
Qwen3_5 Vision, which fail on main. GRPO and gpt-oss also still pass.
- **The Nemotron leg did real work rather than skipping:**
  - It printed no `No virtual environment found`.
  - uv installed and uninstalled packages.
- `unsloth install-kernels` ran and chose its torch fallback for
causal_conv1d and mamba_ssm on CPU torch.
  - `OK: imports pass under CUDA spoof`.
- **Contract test:** `test_smoke_install_contract.py` gives 39 passed.
With the workflow change reverted, the new test fails.

The `static + transitive resolve` job is still red in that run. That is
the Colab oracle snapshot drift that has failed on every scheduled run
since at least 2026-09-27, and it is unrelated to this change.
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