[common] Fix UE8M0 code 0 (2^-127) and code 255 (NaN) expansion in ptx::exp2f - #3262
Open
xiuhu17 wants to merge 1 commit into
Open
[common] Fix UE8M0 code 0 (2^-127) and code 255 (NaN) expansion in ptx::exp2f#3262xiuhu17 wants to merge 1 commit into
xiuhu17 wants to merge 1 commit into
Conversation
Contributor
Greptile SummaryCorrects UE8M0 extreme-code expansion and adds regression coverage.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "Fix UE8M0 code 0 and 255 expansion in pt..." | Re-trigger Greptile |
This was referenced Jul 25, 2026
|
@ptrendx Anyone from your team can help review this? |
ptrendx
approved these changes
Jul 28, 2026
Member
|
/te-ci |
Member
|
@xiuhu17 Please sign your commit - please refer to https://github.com/NVIDIA/TransformerEngine/blob/main/CONTRIBUTING.rst#sign-your-work Thanks! |
UE8M0 code 0 is 2^-127 and code 255 is NaN, but the exponent-field shift produced +0.0 and +Inf, so MXFP8 software dequantize zeroed every 1x32 block whose scale byte was 0. Mirror the special cases already present in exp2f_rcp and add a dequantize test with planted extreme scale codes. Signed-off-by: zhihaow6 <zhihaow6@illinois.edu>
Contributor
Author
Fixed, thanks for reminding |
Contributor
Author
|
Hi @ptrendx, would you like to run the ci for this one? Thanks! |
Member
|
Actually, for this test to run you need to add it to the qa/L0_pytorch_unittest/test.sh |
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.
Description
ptx::exp2f(e8m0_t)builds the scale by shifting the biased exponent into the fp32 exponent field. Two UE8M0 codes cannot be built that way:0is2^-127— an fp32 subnormal (0x00400000), so the shift yields+0.0. MXFP8 software dequantize (dequantize_mxfp8.cuh,group_dequantize_mxfp8.cuh) then zeroes every 1x32 block whose scale byte is 0.255is NaN — the shift yields+Inf.exp2f_rcpnext to it already special-cases both; this applies the same handling toexp2f.Repro:
Type of change
Checklist: