Skip to content

[Bugfix][ROCM] Fix the MXFP8 block scale exponent - #53110

Merged
AndreasKaratzas merged 2 commits into
vllm-project:mainfrom
stefankoncarevic:fix-mxfp8-block-scale
Aug 22, 2026
Merged

AndreasKaratzas merged 2 commits into
vllm-project:mainfrom
stefankoncarevic:fix-mxfp8-block-scale

Conversation

@stefankoncarevic

@stefankoncarevic stefankoncarevic commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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 onto
the 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, which
scales by ceil(log2(amax / FP8_MAX)).

mxfp8_e4m3_quantize only routes to the Triton kernel on ROCm, for the 2D
non-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.finfo values instead of hardcoding them.

Test Plan

tests/kernels/test_minimax_m3_amd_ops.py exercises the Triton path against the
torch reference. The file is skipped outside ROCm.

pytest tests/kernels/test_minimax_m3_amd_ops.py

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):

55 passed, 17 warnings in 25.13s

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added quantization rocm Related to AMD ROCm bug Something isn't working labels Aug 20, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Aug 20, 2026
@AndreasKaratzas

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #84854 for commit 61c8a8576bcc.

@AndreasKaratzas

Copy link
Copy Markdown
Member

@stefankoncarevic is the failure related?

@stefankoncarevic

Copy link
Copy Markdown
Contributor Author

@stefankoncarevic is the failure related?

I don't think so. It looks like the regression from #51665, which #53170 has just fixed on main.

@AndreasKaratzas

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #85095 for commit 6f54e26c7ced.

@AndreasKaratzas
AndreasKaratzas enabled auto-merge (squash) August 22, 2026 00:59
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 22, 2026
@AndreasKaratzas
AndreasKaratzas merged commit 7f4a1b7 into vllm-project:main Aug 22, 2026
112 of 113 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Aug 22, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working quantization ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants