Repository navigation
[Perf] dsa: Native-head FlashMLA and a precomputed schedule for DCP decode - #49980
Conversation
…ule from #48414 Co-authored-by: Yuhao Yang <[email protected]>
…d drop an unported test field
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
[BBuf Review Agent] Could you add before/after numbers with hardware and workload? |
|
/rerun-test registered/kernels/ops/attention/test_flashmla_sched_meta.py |
|
🚀 |
|
Accuracy check on GB300 (2 trays, 2x4 GPUs), Kimi-K3.1, TP8 / DCP8 / EP2, FP8 KV,
The differences are within sampling noise at temperature 1.0, so I see no accuracy change from this PR in this configuration. The native-head path was active for the PR arm: on this GPU (SM 10.3, Also ran Not covered: B300, performance before and after, and other models on the |
# Conflicts: # python/sglang/srt/layers/attention/dsa_backend.py
Original authors: @BBuf, @yhyang201
Port of #48414
sgl-flash-mla1.0.4 (#49362) runs the SM100 legacy sparse decode at any head count in [1, 128], but the DSA backend still pads q to 64 or 128 heads, so Kimi-K3.1's 96 heads (and the 12 a TP8 rank keeps) run padded. #48721 left this out because the kernel was not on main yet. This PR ports the two FlashMLA pieces of the Kimi-K3.1 Day-0 branch's DCP decode path:flashmla_kvruns the real head count on SM100 when the installed wheel supports it, and pads as before otherwise.topk_length, so it is rebuilt on every call. It now comes from the scheduler kernel'swindowedschedule (on main since [Feat] dsa: Kernel prerequisites for a DCP-sharded indexer #48501) instead of FlashMLA's own scheduling launch.Against the raw port (first commit):
_dcp_flashmla_sched_metagets the empty schedule through_call_get_mla_metadata, the hook hardware backends override, instead of callingget_mla_metadatadirectly._flashmla_kv_pad_q_in_place, a field this PR does not port, is dropped; one comment is shortened.Left for later ports: the zero-padded q buffer written in place (
_flashmla_kv_q, only used where padding remains) and absorbing q under the indexer, which builds on it.Modifications
_flashmla_kv_padded_headspicks the head countflashmla_kvruns;flashmla_kv_num_q_headsandflashmla_kv_num_q_heads_prefilluse it._maybe_precompute_flashmla_sched_metatakes ascheduleargument, accepts native head counts, and sizes the schedule withsparse_decode_num_sm_partswhen the wheel has native heads._forward_flashmla_kvunder DCP calls_dcp_flashmla_sched_meta. Where the scheduler kernel does not apply, the schedule stays empty and FlashMLA schedules itself, as before.Two things to review:
flashmla_kvDSA path on SM100, not only Kimi-K3.1. The Day-0 branch only exercised Kimi-K3.1.windowedschedule splits the KV differently from FlashMLA's, so DCP decode outputs can differ in the last bits from before.Tests
test_native_heads_schedule_and_output(SM100, 12 and 96 heads): the precomputed schedule matches FlashMLA's own, outputs are bit-identical to the padded run, and a captured graph recomputes the schedule whentopk_lengthchanges.pre-commit,ruff --select F). GPU validation owed: this test, and Kimi-K3.1 TP8 / DCP8 on B300 before and after.CI States
Latest PR Test (Base): ❌ Run #43133315952
Latest PR Test (Extra): ❌ Run #43133315886
Latest PR Test (AMD ROCm 10): ❌ Run #43133315919
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: