Skip to content

CPU backend: sync the compile cache tag only on the GPU backend (unsloth.kernels loaded on CPU since #18111) - #18117

Merged
danielhanchen merged 1 commit into
mainfrom
ci-cpu-backend-no-kernels-import
Nov 17, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-cpu-backend-no-kernels-import

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Two CPU-backend tests fail on main in the CPU rest shard since #18111 (seen on the staging runs of #18075 and #18076):

tests/test_cpu_backend_init.py::test_no_accelerator_loads_the_cpu_backend
tests/test_cpu_backend_tiled_mlp.py::test_cpu_backend_loader_tiles_like_the_gpu_loaders
E   AssertionError: assert ['unsloth.kernels', ...] == []

Cause

#18111 added, at the end of unsloth/__init__.py:

from .kernels.triton_launch import sync_compile_cache_tag_to_workers as _sync_tag

It runs for every backend. On a machine with no accelerator, import unsloth now loads unsloth.kernels (and everything its package __init__ pulls in, 87 modules) even though the CPU backend deliberately never loads GPU kernels; the tests above guard exactly that.

The sync itself is right, but it only matters where kernels add tags to torch.compiler.config.cache_key_tag, i.e. the GPU backend, which has already imported unsloth.kernels by then. On the CPU backend there is no tag to hand to compile workers.

Fix

Run the sync only when the GPU backend was selected (_IS_CPU_BACKEND is False). The MLX branch never defines _IS_CPU_BACKEND, so it is skipped there too.

Verification

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T09:31:35.703994Z 88d4b46 Manual request
ℹ️ 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. 🎉

Reviewed commit: 88d4b46c15

ℹ️ 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 ab16c9f into main Nov 17, 2026
@danielhanchen
danielhanchen deleted the ci-cpu-backend-no-kernels-import branch November 17, 2026 09:32
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