Skip to content

FP8 tests: same automatic dequant route on sm89+, no Fp8Dequantize leak between files - #15078

Merged
danielhanchen merged 1 commit into
mainfrom
fix/fp8-tests-sm89-and-batch-isolation
Oct 24, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/fp8-tests-sm89-and-batch-isolation

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Three FP8 tests fail on main depending on the GPU and on which other test files run in the same pytest session. These are test bugs, not library bugs. This PR changes tests only.

Failures

1. test_fp8_dequant_save_policy.py::test_explicit_and_automatic_dequantize_reload[False]

  • What the test assumes: transformers dequantizes a device_map = "cpu" FP8 load by itself.
  • What transformers does: in 5.x, FineGrainedFP8HfQuantizer.validate_environment only does that when there is no CUDA, or when the GPU is below sm89. On L4, H100 and B200 the weights stay FP8 and the first assert fails.
  • Where it fails: run alone, it fails on L4 and B200 and passes on A100, T4 and CPU.
  • Fix: when CUDA is present, the automatic case now reports a pre-sm89 capability, so every GPU takes the same route.

2. test_fp8_ragged_block_dequant.py::test_ragged_rows_match_block_reference[glm5_3] and [ling3]

  • Cause: shared state from an earlier file. test_fp8_16bit_text_loader_dequant.py does real in-process FP8 loads, and Unsloth's quantizer wrapper then patches transformers' Fp8Dequantize with the ragged-block fix for the rest of the session. After that, the unpatched case in the ragged test no longer raises ValueError.
  • Where it fails: on every GPU, but only when the two files share a session. Both IDs pass when their file runs alone.
  • Fix:
    • the loader file restores Fp8Dequantize after each test, with the same fixture test_fp8_dequant_save_policy.py already uses;
    • the ragged test unwraps any inherited ragged-block wrapper before building its unpatched class.

Either change alone made the IDs pass. Both are kept so neither file depends on the other.

Results

Colab, transformers 5.17.0, main (09e30cf) and this branch in the same VM per GPU. "Batch" means all tests/test_fp8_* files in one pytest call.

GPU torch main, batch failures this PR, batch
L4 (sm89) 2.10.0 / 2.14.1 save_policy[False], ragged[glm5_3], ragged[ling3] 718 passed, 0 failed
A100 (sm80) 2.10.0 / 2.14.1 ragged[glm5_3], ragged[ling3] 479 passed, 0 failed
T4 (sm75) 2.10.0 / 2.14.1 the 2 ragged IDs + 5 more the same 5
B200 (sm100) 2.10.0 the same 3 as L4 712 passed, 0 failed

The 5 other T4 failures are the same IDs on both sides and are not touched here:

test_explicit_and_automatic_dequantize_reload[False] relied on transformers
dequantizing a device_map="cpu" fp8 load by itself, which it only does
without CUDA or below sm89; report a pre-sm89 card so L4/H100/B200 take the
same route.

test_fp8_16bit_text_loader_dequant does real fp8 loads in process, which
patch transformers' Fp8Dequantize for the rest of the session, so the
ragged-block test's unpatched case stopped raising when run after it.
Restore the class after each loader test, and unwrap the ragged patch in
the ragged test's unpatched class.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 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 🔄 Running since 2026-10-24T06:16:19.663959Z 4ee4615 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

@danielhanchen
danielhanchen merged commit feddc0b into main Oct 24, 2026
17 of 20 checks passed
@danielhanchen
danielhanchen deleted the fix/fp8-tests-sm89-and-batch-isolation branch October 24, 2026 07:31
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