mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #394] MegaMoE: add cluster-paired FP4 weight packets #414
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#414
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?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/394
Author: @foraxe
Created: 7/28/2026
Status: 🔄 Open
Base:
main← Head:pr/mega-moe-fp4-weight-packets📝 Commits (4)
c99da9cfeat(mega-moe): add cluster-paired FP4 weight packets1097cbatest(mega-moe): add packet-layout A/B coverage779e283test(mega-moe): expose deterministic A/B seedd1e7368refactor(mega-moe): clarify packet layout invariants📊 Changes
9 files changed (+522 additions, -59 deletions)
View changed files
📝
csrc/apis/mega.hpp(+71 -13)📝
csrc/jit_kernels/heuristics/mega_moe.hpp(+16 -5)📝
csrc/jit_kernels/impls/sm100_fp8_fp4_mega_moe.hpp(+79 -23)📝
deep_gemm/include/deep_gemm/common/tma_copy.cuh(+9 -7)📝
deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh(+54 -4)📝
deep_gemm/mega/__init__.py(+73 -3)➕
tests/compile_mega_moe_tile_packets.cu(+47 -0)📝
tests/test_mega_moe.py(+74 -4)➕
tests/test_mega_moe_tile_packets.py(+99 -0)📄 Description
Summary
This change adds an optional weight layout for FP8xFP4 Mega MoE:
scale words consumed by that tile;
The packet and scale views share one allocation. Expert ownership remains
sharded by rank, so this does not replicate expert weights.
Motivation
Sparse Mega MoE batches touch many experts but read only a small part of each
expert at a time. In the row-major layout, cooperating CTAs and their scale
loads can be far apart in memory.
The packet layout follows the kernel's actual access order:
expert -> CTA pair -> K tile -> CTA peerThis keeps each CTA pair's weight bodies adjacent and places the matching
scale words directly after each body.
For sparse small-token work, the packet path also uses one output warpgroup
and marks one-use routed weight loads as
EVICT_FIRST. Other workloads keepthe existing production heuristic.
API
The layout is opt-in during the existing model-load weight transform:
The runtime detects the packet layout from its shape and strides. Existing
row-major weights continue to use the original path.
Correctness
On four GB200 GPUs, row-major and packet layouts produced bitwise-identical
output tensors and cumulative expert statistics for every reported workload.
Performance
Configuration: FP8xFP4, EP4, 384 experts, top-k 6, hidden size 7168,
intermediate size 3072, no shared experts, deterministic random routing.
The metric is the maximum rank median from alternating same-process A/B runs.
The small-token candidate includes the packet layout, one output warpgroup,
and
EVICT_FIRSTfor routed packet loads. The large-token comparisons usethe same default compute setting on both sides and differ only in weight
layout.
Reproduce the correctness and alternating A/B measurements with:
Scope and fallback
Validation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
pack_ue8m0_to_intCUDA graph capture safe #470