Repository navigation
[CPU][Bugfix] Flatten >2-D activations in the AMX int8 W8A8 linear path - #61965
Merged
bigPYJ1151 merged 3 commits intoOct 19, 2026
Merged
Conversation
_apply_weights_sgl passed B x T x D activations straight to int8_scaled_mm_with_quant, which requires a 2-D input, so W8A8 Whisper encoder layers failed on AMX CPUs. Flatten to [M, K] and restore the leading dims, matching _apply_weights_onednn. Fixes vllm-project#61964 Co-authored-by: Claude Signed-off-by: Harshal Adhav <harshal.adhav@amd.com>
harshaladhav-amd
requested review from
AndreasKaratzas,
WoosukKwon,
mgoin,
tlrmchlsmth,
yewentao256 and
zyongye
as code owners
October 16, 2026 06:02
Contributor
Author
|
@bigPYJ1151 could you please review this PR? It fixes the AMX int8 W8A8 path ( |
Member
|
/ci run |
|
✅ Triggered Buildkite CI #95817 for commit ℹ️ This PR is 5 commits behind upstream |
bantianyue
pushed a commit
to bantianyue/vllm
that referenced
this pull request
Oct 28, 2026
…th (vllm-project#61965) Signed-off-by: Harshal Adhav <harshal.adhav@amd.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.
Purpose
Fixes #61964.
On AMX CPUs,
CPUInt8ScaledMMLinearKernelroutes symmetric W8A8 linears with aligned shapes to_apply_weights_sgl(the SGLang-derivedint8_scaled_mm_with_quantkernel), which has been the default since #50801. That path passes activations straight to the kernel, and the kernel enforcesCHECK_DIM(2, mat1). The Whisper encoder runs onB x T x D, so W8A8 Whisper fails on AMX machines withRuntimeError: mat1 must be a 2D tensor. Non-AMX CPUs fall back to_apply_weights_onednn, which already flattens to[M, K]and restores the leading dims, so the model works there.This PR applies the same flatten/reshape in
_apply_weights_sgl. It matches_apply_weights_onednnandCPUFp8BlockScaledMMKernelin the same file, and the W4A16 fix in #58268. 2-D inputs (all decoder-only models) are unaffected.Not a duplicate: I searched open PRs and issues for
_apply_weights_sgl,int8_scaled_mm_with_quant, and CPU/Whisper W8A8. The only related item is #56029, which fixes the ROCm Tritonscaled_mmpath (#56024) and doesn't touch the CPU kernel.Test Plan
test_cpu_sgl_int8_linear_accepts_3d_inputintests/kernels/quantization/test_scaled_mm_kernel_selection.py(already acpu_testfile). It builds a layer throughCPUInt8ScaledMMLinearKernel.process_weights_for_sgl, runsapply_weightson a[2, 3, K]input, and checks the result is bit-identical to the flattened[6, K]call reshaped back. The test is skipped whenint8_scaled_mm_with_quantis not built.pytest tests/kernels/quantization/test_scaled_mm_kernel_selection.py -vpre-commit run --files <changed files>Test Result
Run on an AVX512-BF16 host (AMD EPYC 9454). It loads the same
_Clibrary, so the SGL int8 op runs there through its non-AMX fallback.RuntimeError: mat1 must be a 2D tensor.I don't currently have AMX hardware available, so I haven't run an end-to-end W8A8 Whisper accuracy check on GNR/SPR. The change only affects inputs that previously raised, and the 2-D path is unchanged. I'd appreciate an AMX run from CPU CI or reviewers (cc @bigPYJ1151).
AI assistance was used to prepare this change. I reviewed every changed line and ran the tests above.