mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #404] feat: add opt-in MegaMoE EVICT_FIRST weight loads #422
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#422
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/404
Author: @freeliuzc
Created: 8/12/2026
Status: 🔄 Open
Base:
main← Head:pr/mega-moe-evict-first📝 Commits (4)
9a2a4ddfeat: add opt-in MegaMoE EVICT_FIRST weight loadsd149ce1fix: gate MegaMoE EVICT_FIRST at 512 tokensf03a59efix: pass MegaMoE cache hint through JIT template12aa4d5fix: constrain supported TMA cache hints📊 Changes
4 files changed (+29 additions, -11 deletions)
View changed files
📝
README.md(+2 -0)📝
csrc/jit_kernels/impls/sm100_fp8_fp4_mega_moe.hpp(+9 -2)📝
deep_gemm/include/deep_gemm/common/tma_copy.cuh(+14 -8)📝
deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh(+4 -1)📄 Description
Add an opt-in EVICT_FIRST hint for small-batch MegaMoE
Summary
This change adds an opt-in SM100 FP8xFP4 MegaMoE cache-policy tuning switch.
When
DG_MEGA_MOE_WEIGHT_EVICT_FIRST=1, routed expert-weight demand TMA loadsuse the GPU L2
EVICT_FIRSTreplacement hint. The normal path remains thedefault (
0), and shared-expert weights and scale-factor loads are unchanged.The hint is deliberately independent of speculative previous-active-expert
prefetch. Prefetch remains excluded from this PR because its benefit is
routing-sensitive.
The switch is enabled only when
num_tokens <= 512; larger batches always usethe normal cache policy.
Performance
Measured on 8 SM100 GPU ranks with the DeepSeek-V4-Flash-FP8 configuration,
FP8xFP4 MegaMoE, random routing with sequence length 8, one shared expert,
hidden size 4096, intermediate size 2048, 256 total experts, and top-k 6.
These measurements use the existing upstream/origin MegaMoE heuristic; no
v3,v6, tiling, cluster, or prefetch experiment is included in this PR.Each value is the mean across 8 ranks from a correctness-plus-performance run.
EVICT_NORMALEVICT_FIRSTThe 1024-token result is expected to be effectively unchanged because the
runtime gate selects
EVICT_NORMALfor that case.Repro
Build the branch in a CUDA/SM100 environment, use a fresh JIT cache for
each variant, and run the two variants in alternating order on an otherwise
idle 8-GPU node.
num_shared_experts=1andnum_max_tokens_per_rank=2048intentionally match the measurements above.The commands above use only arguments available in the existing upstream test
script and reproduce correctness plus a basic A/B measurement. The reported
performance table was collected with a separate experiment harness that cycled
a deterministic sequence of eight random routings during benchmarking. Collect
fused-kernel latency and report rank means. The default path (
hint=0) mustretain
EVICT_NORMALbehavior.Scope
No routing, scheduler, tiling, cluster, synchronization, numerical, or public
Python API behavior changes are included.
Testing
git diff --checkpython -m py_compile tests/test_mega_moe.pyEVICT_NORMALwhen the variable is unset or0Known Limitations
default.
counts.
this PR and remains in the experiment archive for a separate proposal.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.