Repository navigation
PrefixGrouper compile check test: keep the throwaway package importable for Dynamo - #19034
Merged
danielhanchen merged 1 commit intoNov 23, 2026
Merged
Conversation
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
deleted the
fix/prefix-grouper-check-keeps-pkg-registered
branch
November 23, 2026 09:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Repo tests (CPU, rest-2)fails on PR runs rebased past #18975 (for example the staging run for #19000), and the same two tests fail on a local checkout of currentmain:Both tests were added by #18975 and already fail at its merge commit (
03c989b0a7) with torch 2.10 CPU, the same as CI.Root cause
The test, not the kernel.
_load()importsprefix_grouper.pyunder a throwaway package and removes it fromsys.modulesstraight away. These two tests are the only ones in the file that wrap the kernel intorch.compile(fullgraph=True), and Dynamo resolves a traced function's globals by importing its module by name (symbolic_convert._import_module), so the compile dies on the missing package before reaching the code under test.Keeping the package registered exposed a second problem:
_import_moduleisfunctools.cached for the process, so with one fixed package name the[no_grad]compile resolved the[grad]test's kernel module and guarded on its_COMPILE_CHECKED(Guard failed on the same frame it was created). Each parametrization passes on its own.Fix
tests/test_prefix_grouper_compile_check.pyonly:_load(monkeypatch)registers the package and both modules throughmonkeypatch, so they stay importable for the whole test and are removed at teardown._pg_check_pkg_under_test_<n>), so Dynamo's import cache can never hand one test another test's kernel state.No change to
unsloth/utils/prefix_grouper_kernel.py.Testing
tests/test_prefix_grouper_compile_check.py: 18 passed (was 2 failed), also under-n 3.tests/test_prefix_grouper*.py: 100 passed, 3 skipped._pg_check_pkg_under_test*module is left insys.modulesafter the file runs.if in_graph_reuse: needs_check = False) makes both tests fail, so they now check the kernel instead of failing before it.