Repository navigation
[Perf] kda: Batch strided FlashInfer prefill input copies - #47651
Conversation
|
/rerun-test test/registered/kernels/ops/attention/test_kda_input_pack.py test/registered/kernels/ops/attention/test_kda_prefill_graph.py |
|
🚀 |
BBuf
left a comment
There was a problem hiding this comment.
[BBuf Review Agent] LGTM. Please run the copy and graph tests on B200/B300 before merging.
|
/tag-and-rerun-ci |
|
/rerun-test test/registered/kernels/ops/attention/test_kda_input_pack.py test/registered/kernels/ops/attention/test_kda_prefill_graph.py |
|
🚀 |
|
/tag-and-rerun-ci |
1 similar comment
|
/tag-and-rerun-ci |
|
@BBuf Thanks for the review. Both requested test files have now been rerun against PR head There were zero skips in either file. This covers the Blackwell-only FlashInfer cases skipped by the earlier H100 CI run. A complete PR Python tree and a version-matched FlashInfer overlay were used; version checks remained enabled. The PR description now also contains the completed common-base full-service comparison: KDA-only +1.65% (one screening pair); combined KDA+MoE +3.27% over two A/B pairs (+3.24% / +3.31%). The combined gain is not attributed to this PR alone. All 768 formal requests and finite fixed-output regressions passed. Marked ready for review. Please re-review when convenient, including the documented overlap/choice with #47451. My account cannot dispatch targeted |
|
/rerun-failed-ci |
|
[BBuf Review Agent] @Codoge The zero-skip B300 runs on |
|
/rerun-failed-ci |
…t#47651) Co-authored-by: Codoge <12482210+Codoge@users.noreply.github.com>
Motivation
Kimi-K3's token-major prefill convolution leaves strided Q/K/V views, and its merged gate projection leaves a strided beta view. FlashInfer's KDA wrapper materializes these inputs with separate copies. Batch those required copies into one Triton launch without changing KDA arithmetic, gates, state precision, or checkpoint handling.
This integrates the measured PP8 prototype into upstream
main. Full-model serving validation now passes for these production changes on the common upstreammainbase592754fc5e, with FlashInfer 0.7.2; the standalone and repeated combined results are reported below. Real GPU operator tests pass on both FlashInfer 0.7.1 and the pinned 0.7.2.Relationship to #47451
The optimizations overlap on the Q/K/V materialization cost, but use different approaches:
FlashInferKDAPrefillKernel.extendandFlashInferKDAPrefillGraph.runthrough the same helper.Modifications
kernels/ops/attentionand use it at the FlashInfer KDA input boundary.Accuracy Tests
On an idle B300/B30Z (SM103), PyTorch 2.14.1+cu130, separately using FlashInfer 0.7.1 and 0.7.2:
[1, 16384, 96, 128]and CUDA Graph replay with changed inputs.git diff --checkpassed.The current six full-service runs each pass 12 fixed greedy output checks covering input lengths 1,024 / 16,383 / 16,384 / 16,385 / 32,768 / 65,536, each repeated twice. All 60 comparisons against A1 match output token IDs and input SHA256 hashes. An additional eight C4 concurrent fixed-input checks match between A2 and B2. These are finite output-regression checks, not logits-level equality or a full task-accuracy benchmark.
Blackwell review follow-up (2026-11-01)
Reran both complete files on B300/B30Z (SM103), PyTorch 2.14.1+cu130 and FlashInfer 0.7.2, using the complete Python tree from PR head
7933473906e291d9a14d26ba78aca0284820ae1e:test/registered/kernels/ops/attention/test_kda_input_pack.py: 5 tests passed, 0 skipped.test/registered/kernels/ops/attention/test_kda_prefill_graph.py: 9 tests passed, 0 skipped, including the FlashInfer/Blackwell cases that were skipped on the H100 CI runner.Speed Tests and Profiling
Full serving validation of the upstream integration (2026-11-01)
Tested production changes from #47651 (
7933473906e) and #47653 (34238f31a5d) on the same upstreammainbase592754fc5e, using FlashInfer 0.7.2 for every arm. Kimi-K3, one 8-GPU B300/B30Z, TP1/PP8/EP1, chunk 16,384, pipeline async depth 1, client C4, ISL 65,536 / OSL 1. CUDA Graphs and radix caching disabled; model precision and all serving settings held fixed. Each formal run contains 128 requests after a separate 8-request warmup. Formal measurements exclude profiler/diagnostic requests and prototype hooks.Each run uses an independent autotune cache cloned from the same baseline startup cache. Baseline/KDA caches contain no 16K MoE seed; MoE/combined caches contain the FlashInfer 0.7.2
(128, 4)record on all eight PP ranks. Separate post-benchmark Torch GPU traces of all eight PP ranks confirm the actual production paths: 1,104 KDA input-copy kernels become 276 pack kernels, and all 736 MoE GEMMs change token tile 192 to 128. These C1 diagnostic traces verify execution paths; their timings are not used as C4 serving measurements.KDA-only throughput changes by +1.65% against A1. This is one standalone screening pair. The repeated combined KDA+MoE result changes throughput by +3.27% (paired runs +3.24% / +3.31%); it must not be attributed to either PR alone. Pooled throughput is total input tokens / total formal duration; P50/P99 are recomputed from all formal request TTFTs. All 768 formal requests succeed with zero cached tokens and retractions. The combined pooled P50/P99 TTFT decrease by 3.28% / 3.17%; no formal request reaches 15 seconds. OSL is 1, so TPOT/ITL are not reported.
Earlier prototype evidence
Historical prototype results, not a new end-to-end benchmark of this branch. Kimi-K3 / SGLang 0.5.22 / FlashInfer 0.7.1, one 8-GPU B300, TP1/PP8, chunk 16,384, client concurrency 4, ISL 65,536 / OSL 1. CUDA Graphs and radix caching disabled; all model precision settings unchanged. Warmups and profiling requests excluded.
Pooled throughput changes by +1.67%. Throughput uses total tokens / total duration; percentiles are recomputed from all formal requests, not averaged between runs. All requests succeeded with no cache hits or retractions. Only one output token is generated, so TPOT/ITL are not reported.
The combined prototype's NSYS trace showed KDA copy-related time changing from 1.5405 to 0.3566 ms per matched layer invocation. That includes remaining copies and is not the complete KDA layer time. Required element traffic is unchanged. The combined MoE+KDA serving gain is not attributed to this PR alone.
Checklist
CI States
Latest PR Test (Base): ✅ Run #41201160895
Latest PR Test (Extra): ❌ Run #41201160980
Latest PR Test (AMD ROCm 10): ❌ Run #41201160985
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: