perf(fp8): run per-tensor fp8 as W8A8 via scaled_mm - #7
Merged
Conversation
jason-fxz
force-pushed
the
fp8-scaled-mm
branch
from
August 19, 2026 00:48
982f1a2 to
879beab
Compare
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.
Problem
fp8_pertensor_linearsends every M>1 to_gemm, a prefill kernel with no split-K. At decodebatch sizes its grid collapses to
cdiv(N,128)CTAs, so runtime tracks K and ignores N and M —594 GB/s flat from M=2..16, against 1334 GB/s for the M=1 GEMV and a 1461 GB/s copy roof.
Qwen3.8-27B-NVFP4 puts 7.21 of its 17.56 GB of weights on that path.
Fix
Route to
torch._scaled_mm(W8A8) using the checkpoint'sinput_scale, which the loaderpreviously dropped. The scheme is chosen by
(has input_scale, sm_89+)— a deployment property,never by M, so a reply reproduces at bs=1 regardless of concurrency. Merged projections use
row-wise scaling to stay exact.
All per-tensor-FP8 projections in one forward (7.21 GB of weights), CUDA-graph captured, L2-cold:
End to end on Qwen3.8-27B-NVFP4: decode tps at 16 concurrent 657 → 799 (+21.7%), bs=1 −1.9%.
Prefill gains more, which shows up as TTFT −45% at bs=1, −14% at bs=16.
Caveats
the checkpoint was calibrated for. Accuracy benchmark not run (
tests/e2e/test_aime.py,no local AIME jsonl); smoke-checked on 8 concurrent prompts.
_gemm.tests/kernels/test_fp8_pertensor_linear.py(33 cases) — the module had none.🤖 Generated with Claude Code