Skip to content

QAT test: spoof CUDA in the unpickling child on GPU-less runners - #14415

Merged
danielhanchen merged 1 commit into
mainfrom
fix/qat-unpickle-child-spoof
Oct 20, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/qat-unpickle-child-spoof

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

tests/test_qat_phone_deployment.py::test_fake_quantized_embedding_unpickles_in_fresh_process, added in #14376, fails in the CPU Repo tests (CPU, rest) shard on every PR whose merge includes #14376 (for example #14350):

File "/home/runner/work/unsloth/unsloth/unsloth/_gpu_init.py", line 245, in <module>
  import unsloth_zoo
...
NotImplementedError: Unsloth cannot find any torch accelerator? You need a GPU.

The test pickles the fake-quantized embedding and loads it in a fresh python -c child. That class is defined in unsloth.models._utils, so unpickling imports unsloth. With a CPU-only torch, unsloth refuses to import. That refusal is by design, so the product is right and the test is not. The parent test process gets the CUDA spoof from tests/conftest.py, but the child has no conftest.

Fix

The child adds tests/ to sys.path. When torch reports no CUDA, it applies _zoo_aggressive_cuda_spoof before unpickling, the same spoof the CPU CI uses. On a host with a real GPU the branch is skipped, so the child loads the embedding exactly as before.

Verification

In a CPU-only venv (torch 2.10.0+cpu, torchao 0.18.0, unsloth-zoo e1d0b6d6d4 as CI installs it), with PYTHONPATH cleared:

  • main: the test fails with the error above.
  • This change: tests/test_qat_phone_deployment.py 20 passed.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T23:05:08.710308Z 6891694 Manual request
🔒 Security Review ⚠️ Failed 2026-10-20T23:04:05.368005Z
We couldn’t complete this review. Comment @codex security review to try again.
6891694 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. Delightful!

Reviewed commit: 689169409f

ℹ️ 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 f095e78 into main Oct 20, 2026
@danielhanchen
danielhanchen deleted the fix/qat-unpickle-child-spoof branch October 20, 2026 23:06
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