[Bugfix][ROCM] Fix the MXFP8 block scale exponent - #53110
Merged
AndreasKaratzas merged 2 commits intoAug 22, 2026
Merged
Conversation
The Triton path picked the block scale with floor(log2(amax)), which maps the block maximum onto 1.0 rather than onto the top of the e4m3 range. Small elements of a block then land in the subnormal region and the result drifts from the torch reference, which the Minimax M3 ops test reports as `assert 8 <= 1`. Use ceil(log2(amax / FP8_MAX)) instead, as _mxfp8_e4m3_quantize_torch already does, and pass both that limit and the empty-block clamp in as constexprs so the two paths read off the same torch.finfo values. Signed-off-by: Stefan Koncarevic <Stefan.Koncarevic@amd.com>
stefankoncarevic
requested review from
mgoin,
pavanimajety,
robertgshaw2-redhat,
tlrmchlsmth,
yewentao256 and
zyongye
as code owners
August 20, 2026 13:22
Member
|
/ci run |
|
✅ Triggered Buildkite CI #84854 for commit |
Member
|
@stefankoncarevic is the failure related? |
Contributor
Author
I don't think so. It looks like the regression from #51665, which #53170 has just fixed on main. |
Member
|
/ci run |
|
✅ Triggered Buildkite CI #85095 for commit |
AndreasKaratzas
approved these changes
Aug 22, 2026
AndreasKaratzas
enabled auto-merge (squash)
August 22, 2026 00:59
am-cohere
pushed a commit
to am-cohere/vllm
that referenced
this pull request
Sep 1, 2026
Signed-off-by: Stefan Koncarevic <Stefan.Koncarevic@amd.com>
mikeshawcode
pushed a commit
to mikeshawcode/vllm
that referenced
this pull request
Sep 1, 2026
Signed-off-by: Stefan Koncarevic <Stefan.Koncarevic@amd.com> Signed-off-by: mikeshawcode <michaelwshaw2@gmail.com>
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.
The test belongs to the Kernels Root Misc Test group, which AMD CI does not run yet.
This fix should land before the PR that enables that group (#50519).
Purpose
The fused Triton MXFP8 quantizer picks the shared block scale with
floor(log2(amax)) + 127, which maps the block maximum onto 1.0 instead of ontothe top of the e4m3 range. Small elements of a block then land in the subnormal
region, so the Triton result drifts from
_mxfp8_e4m3_quantize_torch, whichscales by
ceil(log2(amax / FP8_MAX)).mxfp8_e4m3_quantizeonly routes to the Triton kernel on ROCm, for the 2Dnon-swizzled activation-quant case used by the native MX linear/MoE path, so the
mismatch does not appear on CUDA.
This change uses the same exponent as the torch reference and passes the e4m3
limit and the empty-block clamp in as constexprs, so both paths read off the same
torch.finfovalues instead of hardcoding them.Test Plan
tests/kernels/test_minimax_m3_amd_ops.pyexercises the Triton path against thetorch reference. The file is skipped outside ROCm.
Test Result
Without the fix the quantization cases fail the closeness check with
assert 8 <= 1. With the fix, on MI355 (gfx950, ROCm 7.2.3):Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.