Skip to content

Tests: ignore torch.compile resume functions when counting MLP-skip arming layers - #18688

Merged
danielhanchen merged 1 commit into
mainfrom
ci/gc-skip-test-ignores-dynamo-resume
Nov 20, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/gc-skip-test-ignores-dynamo-resume

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Repo tests (CPU, rest) fails intermittently on current main. It is seen on #18650 and #18532, both based on recent main, and both runs include #18607 and #18641:

FAILED tests/test_gc_skip_replay_mlp_down.py::test_only_the_post_norm_free_layer_arms
E   AssertionError: assert ['LlamaDecode...e_at_514_178'] == ['LlamaDecode...fast_forward']
E     Left contains one more item: '__resume_at_514_178'

Cause

#18607 added this test. It collects every module-level function in unsloth.models.{llama, gemma, ...} whose source calls arm_mlp_output_unread( and expects exactly LlamaDecoderLayer_fast_forward.

When an earlier test in the same xdist worker compiles that layer and hits a graph break, Dynamo parks the continuation function (__resume_at_<offset>_<n>) in the compiled function's module globals. That puts it in unsloth.models.llama. Its code object points at LlamaDecoderLayer_fast_forward's lines, so inspect.getsource returns the same source, and it counts as a second arming layer. The test passes alone and fails only when such a compile ran first in the worker. The product code is right; the test's view of the module namespace was not.

Change

tests/test_gc_skip_replay_mlp_down.py: only count a function when its code name matches the name it is bound under (fn.__code__.co_name == fn_name). Dynamo's resume functions are bound as __resume_at_* but named torch_dynamo_resume_in_*, so they drop out. Every function defined in the module with def still matches.

Testing

  • tests/test_gc_skip_replay_mlp_down.py: 18 passed, 6 skipped (the six need CUDA).
  • Reproduced the CI failure with a conftest that plants a resume function exactly as Dynamo does: same code with co_name = "torch_dynamo_resume_in_LlamaDecoderLayer_fast_forward_at_514", bound as __resume_at_514_178 in unsloth.models.llama. The test from main fails with Left contains one more item: '__resume_at_514_178'; this version passes.
  • The guard still does its job: planting a real second arming function in unsloth.models.gemma still fails it (Left contains one more item: 'GemmaDecoderLayer_arming').

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 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-20T21:29:35.661406Z 3432619 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 3432619724

ℹ️ 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 347e97a into main Nov 20, 2026
@danielhanchen
danielhanchen deleted the ci/gc-skip-test-ignores-dynamo-resume branch November 20, 2026 21:29
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