[BugFix] bound FlashMLA sparse decode intermediate tensors size - #49357
Open
cjackal wants to merge 5 commits into
Open
[BugFix] bound FlashMLA sparse decode intermediate tensors size#49357cjackal wants to merge 5 commits into
cjackal wants to merge 5 commits into
Conversation
Contributor
Author
|
@MatthewBonanni ping in case if this issue is still of interest to you. |
This was referenced Jul 24, 2026
cjackal
force-pushed
the
flashmla-fp8-subchunk
branch
from
July 29, 2026 15:25
b7834be to
44fdd0e
Compare
3 tasks
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
cjackal
force-pushed
the
flashmla-fp8-subchunk
branch
from
August 13, 2026 13:45
44fdd0e to
de7fcad
Compare
Leoyzen
added a commit
to Leoyzen/vllm
that referenced
this pull request
Aug 14, 2026
…ap long lines - mla_attention.py: add get_current_vllm_config_or_none, cp_lse_ag_out_rs, dcp_a2a_lse_reduce imports for _dcp_merge_and_v_up_proj (vllm-project#48196); drop unused finalize_mla_pcp_decode import - test_mtp.py: add missing torch import for prefix-cache test (vllm-project#50897) - cli_args.py: wrap >88-col lines (vllm-project#50668) - flashmla_sparse.py: wrap long comment (vllm-project#49357) - flashinfer_mla_sparse.py: drop unused np_to_pinned_tensor import (vllm-project#48196) - kv_cache_coordinator.py: fix factory-function param indentation (vllm-project#50897) Co-authored-by: Sisyphus <sisyphus@openci.dev>
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
cjackal
force-pushed
the
flashmla-fp8-subchunk
branch
from
August 19, 2026 17:55
e40912e to
7b1fc6d
Compare
Signed-off-by: cjackal <44624812+cjackal@users.noreply.github.com>
Signed-off-by: cjackal <44624812+cjackal@users.noreply.github.com>
Signed-off-by: cjackal <44624812+cjackal@users.noreply.github.com>
Signed-off-by: cjackal <44624812+cjackal@users.noreply.github.com>
Signed-off-by: cjackal <44624812+cjackal@users.noreply.github.com>
cjackal
force-pushed
the
flashmla-fp8-subchunk
branch
from
August 20, 2026 01:28
4e11c2a to
e2236c6
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.
Purpose
Fix #44545 - not in an ideal way though.
When FlashMLA sparse kernel is selected with FP8 KV cache dtype, FlashMLA sparse decode kernel(https://github.com/vllm-project/FlashMLA/blob/a8f794d1251cbfd88a5011445dd5582289c727e4/csrc/api/sparse_decode.h#L184) is called in mixed batch mode. This kernel internally allocates intermediate tensors (
o_accum) on call, which quickly dominates the usual unallocated workspace size (~2GB per the comment inflashmla_sparse.py) for long prefill:For 32k input on H200, the bytesize of
o_accumisFor BF16 KV cache, a different kernel (FlashMLA sparse prefill kernel - https://github.com/vllm-project/FlashMLA/blob/a8f794d1251cbfd88a5011445dd5582289c727e4/csrc/api/sparse_fwd.h#L101) is called, which does not allocate a massive VRAM on kernel call and thus does not suffer an OOM contrary to the FP8 code branch. (Note the additional
d_vfactor in the formular foro_accum, no other scratch tensors in FlashMLA have this factor thus negligible in terms of VRAM occupancy)Hence we chunk the mixed-batch input into manageable bytes (
VLLM_FLASHMLA_SPARSE_MAX_SCRATCH_MB) and loop over the chunks to aggregate the output attention tensor, which is in the same spirit as the indexer budget management logic in #36178.Due to the mechanism (looping the kernel over sub-chunks instead of single big shot), it may incur a throughput penalty as a tradeoff, but I have no better idea yet.
As the context window for MLA model families keep growing, FP8 KV cache is kind of inevitable, so I think this PR can work as a bandaid.
Test Plan
No OOM for the reproducer in #44545
Test Result
pass
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.