Skip to content

tests: keep the fused-NVFP4 env in place after the split-reduction hook override - #14789

Merged
danielhanchen merged 1 commit into
mainfrom
nvfp4-split-reduction-test-env
Oct 22, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
nvfp4-split-reduction-test-env

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Test-only fix for test_split_reduction_matches_unsplit in tests/test_nvfp4_fused_gemm.py (re-verify note on #13840).

The test swaps _CONFIG_HOOK to force split 1, then calls monkeypatch.undo() and re-sets UNSLOTH_NVFP4_FUSED=1 before its final bitwise check. undo() also reverts the live_env fixture, so the last calls read whatever _fused_env was cached earlier in the session. When a previous test cached a dense decision, the final torch.equal compares a fused result against a dense one and all six cases fail.

Change

The _CONFIG_HOOK override now sits in a nested monkeypatch.context(), so only the hook is restored and the fixture's environment stays in place. No library code changes.

Validation

With a pytest plugin that seeds a cached dense decision before the test (the order-dependent case):

torch main this PR
2.10 6 failed 6 passed
2.14 6 failed 6 passed

Without the seeded cache the file passes on both sides as before (test_nvfp4_fused_gemm.py: 57 passed, 1 skipped on B200, torch 2.14).

…env reader

monkeypatch.undo() also undid the autouse live_env fixture, which swaps the
once-per-process _fused_env cache for the live os.environ reader. After it,
setting UNSLOTH_NVFP4_FUSED=1 no longer reached the gate: a process whose
cache already held a dense decision ran the final engagement check on the
dense path, and all six test_split_reduction_matches_unsplit cases failed
on torch.equal. The _CONFIG_HOOK override now lives in monkeypatch.context().
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T19:39:43.402133Z bfb0f94 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. Breezy!

Reviewed commit: bfb0f94342

ℹ️ 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 dfc3419 into main Oct 22, 2026
0 of 14 checks passed
@danielhanchen
danielhanchen deleted the nvfp4-split-reduction-test-env branch October 22, 2026 19:45
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