[Kimi-K3] AG-GEMM for Sequence Parallelism - #54151
gau-nernst wants to merge 1 commit into
Conversation
Hi, may I ask which moe backend do you plan to use? I recently found that DeepGEMM mega moe is slower than default FI non-mega moe.(But notice that I run mega moe on b200 by TP8 + EP8 + PP2). So I'm a bit curious whether it's also true on GB300 by TP8 + EP8. From my experience before, mega moe should be faster than non-mega. |
|
When Anyway, TEP8+SP with MegaMoE is meant for prefill. Its decode performance might not be competitive. |
6316632 to
61035f6
Compare
Signed-off-by: Thien Tran <gau.nernst@yahoo.com.sg> Co-authored-by: OpenAI Codex <codex@openai.com>
61035f6 to
8b0cc8d
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
Purpose
This PR implements overlapping AG-GEMM with CUDA streams pipelining: compute local shard while sending the local activation shard to neighboring remote rank, and continue the rotation until all shards are computed. No custom kernel required, and technically we can adapt to any quantization kernels in the future.
Implementation details
cuMemcpyDtoDAsync-> CopyEngine-based, no SM usage. Hence, this only requires P2P, no multicast is needed.handle.put_signal(next_rank, channel=channel)andhandle.wait_signal(previous_rank, channel=step).vLLM integration
The AG-GEMM logic alone is very straight forward:
ag_gemm.pyonly has 150 LOC. The rest of the changes target some refactoring of SP collective ownership and initialization logic.DecoderLayer. When fused AG-GEMM and GEMM-RS are not used (either because it's not supported or disabled), KDA/MLA/MLP modules are now responsible to invoke the unfused AG/RS collectives.multicast_ptris not None [Kimi-K3] Extend GEMM-RS to GEMM-AR #53053 (thanks @wzhao18)use_sequence_parallelnow implies AG-GEMM and GEMM-RS, whilerun_gemm_arcontrols GEMM-AR onlyRowParallelLinearso all models can benefit from it, and we don't need manual dispatch for each model.Microbenchmark results
Using
benchmarks/kernels/benchmark_kimi_k3_ag_gemm.py, TP8, GB300Component breakdown
At very large bs, the overlap is ideal, which makes sense because our GEMM efficiency is determined by local GEMM shape (M/8). Future work can improve performance for medium M by having a single GEMM kernel that perform in-kernel waiting.
E2E perf
Baseline is 3bb19cd
Mixed prefill-decode (aggregated serving)
8k-1k
Prefill-only (PD serving)
8k-1
Test Plan
TP8
TEP8+SP (MegaMoE)
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.