Skip to content

Tests: run the precision template in one namespace, keep the block-compile packing test off leaked env - #14425

Merged
danielhanchen merged 1 commit into
mainfrom
fix/v100-precision-test-one-namespace
Oct 21, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/v100-precision-test-one-namespace

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Two tests on main fail in CI for reasons in the tests, not the product. They are red on unrelated PRs, for example #14409 and #14365.

1. tests/python/test_v100_fullft_precision.py (10 tests, Repo tests (CPU, studio))

tests/python/test_v100_fullft_precision.py:80: in _decide
    exec(CODE, {"torch": torch, "os": os}, {"args": args, "model": model})
E   NameError: name 'args' is not defined

The test runs the mixed_precision template from unsloth/models/rl.py with separate globals and locals dicts. #14394 added _unsloth_precision_requested = tuple(getattr(args, k, False) for k in (...)) to that template. In the generated trainer this runs inside a function, where the generator sees args, so the product is fine. A generator inside exec with a separate locals dict cannot see those locals, so the test raises NameError.

2. tests/test_legacy_block_compile_install.py::test_packed_calls_keep_the_unsloth_layer_forward (Repo tests (CPU, rest))

tests/test_legacy_block_compile_install.py:105: in test_packed_calls_keep_the_unsloth_layer_forward
E   assert []

The test (from #14398) expects an unpacked call to go through the compiled block. _block_compile._wrap keeps every call on the stock forward when UNSLOTH_COMPILE_DISABLE is 1, UNSLOTH_BLOCK_COMPILE is 0, or UNSLOTH_FORCE_FLOAT32 is 1. Eight test modules run os.environ.setdefault("UNSLOTH_COMPILE_DISABLE", "1") at import time, so the result depends on which modules a worker collected. The test passes alone and fails with any of those variables set.

Fix

Test only:

  • test_v100_fullft_precision.py: exec the template in one namespace, as in the trainer's function scope. Results are still read from args and the environment.
  • test_legacy_block_compile_install.py: the packing test clears the three variables with monkeypatch.delenv before wrapping.

Verification

  • test_v100_fullft_precision.py: on main 10 failed (the NameError above); with this change 10 passed.
  • test_legacy_block_compile_install.py on main:
    • with any one of UNSLOTH_COMPILE_DISABLE=1, UNSLOTH_BLOCK_COMPILE=0 or UNSLOTH_FORCE_FLOAT32=1 set: 1 failed (the packing test), 5 passed;
    • with this change: 6 passed in each of those three cases and with none set.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T02:09:20.513091Z e1cfbd9 Manual request
🔒 Security Review ⚠️ Failed 2026-10-21T02:08:13.769129Z
We couldn’t complete this review. Comment @codex security review to try again.
e1cfbd9 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. What shall we delve into next?

Reviewed commit: e1cfbd975b

ℹ️ 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 b93e4dc into main Oct 21, 2026
@danielhanchen
danielhanchen deleted the fix/v100-precision-test-one-namespace branch October 21, 2026 02:14
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