mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[GH-ISSUE #320] [Question]About the new maga kernel and swapab feature #158
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepGEMM#158
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yonghaogu2805 on GitHub (Apr 27, 2026).
Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/320
I have some question about the new mega kernel and other w4a8 group gemm kernel.
1. For mega kernel, The first mma result can load from tmem to register, the epilogue multiply src can complete in a thread with 'swapab'. It should be a performance benefit. Is there other perf optimization from the 'swapab'?
2. For w4a8 grouped gemm kernel, Is it to reduce memory load from global memory or to reduce invalid computation of umma?
Thanks!
@zheanxu commented on GitHub (Apr 30, 2026):
Thanks for the questions!
After swapping A/B,
block_m/block_nmap toumma_n/umma_mrespectively. For MoE, this enables a 2-CTA GEMM withumma_m=256fixed andumma_ndynamically scheduled. The 2-CTA design saves shared memory, allowing more pipeline stages for better latency hiding, and placing the token dimension onumma_navoids wasted Tensor Core compute when experts are assigned few tokens. The epilogue scaling can also be completed within the same thread as you noted. For w4a8 grouped GEMM, it's primarily to reduce HBM bandwidth pressure.For the combine phase, tokens are scattered to different remote addresses at ~256B granularity. TMA instructions have high launch latency overhead, making them inefficient for many fine-grained irregular stores — regular store instructions are more suitable here.
Hope this helps!
@yonghaogu2805 commented on GitHub (Apr 30, 2026):
Hi, @zheanxu thank you for your detailed explanation, but I still have some questions.
@zheanxu commented on GitHub (Apr 30, 2026):
Hi @gyhintel, thanks for following up.
We chose layout D / layout A mainly because a larger
ummablock reduces shared memory bandwidth pressure, and placing the token dimension onumma_nlets us dynamically shrinkumma_nfor experts with few tokens, saving Tensor Core work. Layout B would fixumma_nand varyumma_m, giving less control over wasted compute for tail experts.In our case
umma_ncan be as large as 232, so reducing it definitely avoids idle cycles; even smaller reductions help cut latency and you can measure the effect yourself.The HBM bandwidth saving comes almost entirely from the
w4data type, not from swapping A/B. The swap A/B primarily improves thefp8GEMM performance ceiling by better utilizing the Tensor Core pipeline – for pure grouped GEMM we saw roughly a 15% speedup.@yonghaogu2805 commented on GitHub (May 6, 2026):
@zheanxu I see the layout B is "M = 128 + .cta_group::2 + Dense A matrix" in the doc. It should fix
umma_mis 128 and varyumma_nin "N = {16, 32, … 256} steps of 16"?