[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
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.
Contributor
Greptile SummaryFixes MXFP8 dequantization of UE8M0 edge codes.
Confidence Score: 5/5The PR appears safe to merge with focused regression coverage for the corrected UE8M0 edge-code behavior. The new branches return the required FP32 subnormal and NaN representations, and existing MXFP8 dequantization callers consume those values as block scales without exposing a conflicting contract. Important Files Changed
Reviews (1): Last reviewed commit: "Fix UE8M0 code 0 and 255 expansion in pt..." | Re-trigger Greptile |
This was referenced Jul 25, 2026
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: