Repository navigation
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Collaborator
|
it's a bug if we need zeros these tensor |
Contributor
|
@hangy-amd @valarLip This PR has been inactive for over 2 months. Is the MLA decode splitK accumulator zero-init fix still applicable? If you still plan to pursue it, please rebase onto current main and push an update. If there's no response within ~2 weeks, we'll close this to keep the PR queue clean — it can always be reopened or resubmitted. |
Contributor
|
No activity for 15 days, so this is now labelled |
4 of 7 tasks
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.
Summary
Replace
torch.emptywithtorch.zerosfor the three split-K accumulators (logits,attn_lse,final_lse) allocated inmla_decode_fwd(aiter/mla.py, both the non-persistent and persistent paths).Bug
On the non-persistent path (taken whenever
max_seqlen_q > 1, sinceget_mla_metadata_v1is qseqlen=1 only),mla_decode_stage1_asm_fwddoes not always populate every(qrow, kv_split, head)cell that_fwd_kernel_stage2_asmlater reduces over. The stage-2 Python clampnum_valid_kv_splits = min(splits, ceil(kv_seq_len/mgc))bounds the number of splits read, but does not guarantee every(qrow, head)within a valid split was written by stage 1 — that depends on the ASM binding's tile/work distribution.When the per-split KV count is small, stage 2 reads the unwritten cells. With a cold caching allocator the leftovers are zero (silent); with a warm pool (long-running vLLM worker) the leftovers are arbitrary fp32 values that propagate into the output.
Hit by vLLM
AiterMLAImpl(rocm_aiter_mla) for spec-decode verify (dflashnum_speculative_tokens=15→ qseqlen=16; Eagle3 spec=7 → qseqlen=8) on the eager / PIECEWISE-cudagraph path, gfx950.Repro
/home/hangy/dflash_debug/aiter_bug_repro/clean_repro_test_mla.pymonkey-patchesaiter.mla.torch.emptyto fill fp32 allocations with sentinel1e30.ctx_lens=65, decode_qlen=16, nhead=16, stage 2 reads the sentinel and the output's first 8 of 16 query rows become1e30(50.0% of elements;8 × 16 × 512 = 65,536)./home/hangy/aiter/aiter/jit/module_mla_asm.so(May-2 build); the older Apr-28 prebuilt binding tile-distributes differently and does not surface the bug.Fix
Zero-init the three accumulators. Stage 2's reduction on a zero
attn_lsecell yieldsexp(0 − e_max) · 0 = 0weight contribution, so unwritten cells become inert.This is a defensive fix in Python; the proper long-term fix belongs in
mla_decode_stage1_asm_fwditself — it should write every(token, split, head)position that stage 2 will read.Test plan
op_tests/test_mla.py—decode_qlen ∈ {8, 16}, ctx_lens ∈ {65, 128, 256}, bf16 + fp8clean_repro_test_mla.pywithforce_dirty_empty(1e30)—decode:err == 0for all shapesmla_reduce_v1is also safe under zero-init accumulators