[Feature][NPU] Add FP8 KV-slice dense FIA path for packed FP8 attention (MINDIESD_FP8_KV_SLICE) - #6800
Open
brandneway wants to merge 3 commits into
Open
[Feature][NPU] Add FP8 KV-slice dense FIA path for packed FP8 attention (MINDIESD_FP8_KV_SLICE)#6800brandneway wants to merge 3 commits into
brandneway wants to merge 3 commits into
Conversation
brandneway
requested review from
Isotr0py,
NickCao,
RuixiangMa,
SamitHuang,
ZJY0516,
david6666666,
gcanlin,
princepride,
wtomin,
xuechendi and
yenuo26
as code owners
August 30, 2026 04:47
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
This PR appears to belong to: docs/design/module/quantization.md. Module owners: @david6666666 @Isotr0py @lishunyang12 @brandneway, please review your own changes and leave a short self-review comment describing what you checked. PRs without author self-review may not be assigned a reviewer. Please take a look when you have a chance. If you would like an automated review, mention @vllm-omni-review-bot in a comment. |
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.
What
Adds an opt-in FP8 attention path for NPU where K/V are sliced to the
valid prefix outside the operator, so packed
[real, pad]attentionruns as a single dense MindIE-SD FIA call instead of relying on the
operator's varlen feature:
vllm_omni/platforms/npu/quant/kv_quant_npu.pyfp8_rotate_quant_kv_slice(query, key, value, kv_len):K/V are sliced to the valid prefix (zero-copy
narrow) beforerotation and quantization — padding rows are neither attended nor
quantized — then one dense block-FP8 FIA call runs with the varlen
feature (
actual_seq_*/NTD_TND) entirely off.fp8_kv_slice_enabled()readsMINDIESD_FP8_KV_SLICEper call(no cache), matching the
MINDIE_SD_FA_TYPEdispatch convention._load_quant_ops, so the existing densefp8_rotate_quant_fapathkeeps working against MindIE-SD builds that do not provide it; the
kv-slice entry point raises a clear
ImportErrorin that case.vllm_omni/diffusion/attention/backends/flash_attn.pyforward_npu: whenkv_cache_dtype=fp8rides thenpu_attn_varlenpacked route andMINDIESD_FP8_KV_SLICEis set,dispatch to
_forward_prefix_kv_slice_quant_npu, which resolves thepacked boundaries and hands the backend unsliced BSND q/k/v plus the
real document length. If the packed contract does not hold, falls
back to unquantized attention — dense FP8 would ignore document
boundaries. With the env unset the dispatch is unchanged.
Why
input_layout="BNSD"regardless of thecaller-facing layout:
fa_block_quant_preprocesstransposes BSNDinputs before the quant kernel, so its output (and the FIA output) is
always BNSD-logical; the wrapper transposes back for BSND callers.
downstream (same contract as the unquantized prefix-K/V-slice path).
Per-block scales can mix pad rows in the boundary block — exact when
the packing pads with zeros, which is the MiniMax-H3 packing this path
is built for.
kv_cache_dtype=fp8, K/V slices shrink to the valid prefix, soquantization and attention both skip the padding document entirely.
Usage