mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #331] fix: use 64-bit mega moe sf offsets #369
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#369
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/331
Author: @netaddi
Created: 5/10/2026
Status: 🔄 Open
Base:
main← Head:fix/mega-moe-sf-offset-u64-pr📝 Commits (1)
b0ba0cbfix: use 64-bit mega moe sf offsets📊 Changes
3 files changed (+279 additions, -6 deletions)
View changed files
📝
deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh(+9 -5)➕
tests/test_mega_moe_capacity.py(+264 -0)📝
tests/test_sanitizer.py(+6 -1)📄 Description
Summary
Fix SM100 Mega MoE scale-factor pool address arithmetic for large
num_max_tokens_per_rank.This PR:
Bug Discovery
While validating Mega MoE in a serving-like SM100 setup, the output changed when
only the symmetric-memory buffer capacity changed.
The reproducer uses identical live tokens, inputs, routing, and weights, then
runs:
num_max_tokens_per_rank=32num_max_tokens_per_rank=200000The capacity should only affect allocation size. It should not affect the
mathematical output for the same live tokens.
Root Cause
In
sm100_fp8_fp4_mega_moe_impl, some SF-pool offsets were computed with32-bit intermediate values.
For large
num_max_tokens_per_rank,kNumPaddedSFPoolTokensbecomes largeenough that expressions like:
and:
can overflow 32-bit arithmetic before being used as addresses.
That makes the kernel write or read FP8/FP4 scale factors at the wrong SF-pool
locations, so the subsequent GEMMs consume incorrect scales and produce wrong
outputs.
Fix
Promote the SF-pool offset calculations to uint64_t in both affected paths:
This keeps the indexing valid for large Mega MoE capacities while preserving the
existing layout and kernel behavior for normal capacities.
Validation
Syntax / diff checks:
Manual SM100 regression test:
Expected result after the fix:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.