mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #389] fix: fence combine buffer reuse in mega moe #408
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#408
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/389
Author: @Bruce-Lee-LY
Created: 7/22/2026
Status: 🔄 Open
Base:
main← Head:feat/fix_mega📝 Commits (1)
bbbf8e4fix: fence combine buffer reuse in mega moe📊 Changes
3 files changed (+8 additions, -0 deletions)
View changed files
📝
deep_gemm/include/deep_gemm/impls/sm100_bf16_mega_moe.cuh(+2 -0)📝
deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh(+2 -0)📝
deep_gemm/include/deep_gemm/ptx/utils.cuh(+4 -0)📄 Description
Summary
This PR fixes a shared-memory reuse race in the final combine stage of the SM100 Mega MoE kernels:
fp8_fp4_mega_moebf16_mega_moeBoth kernels use two shared-memory load stages. A stage is filled by TMA through the async proxy, consumed by the warp through generic shared-memory loads, and then reused by a later TMA load. The old code did not order the generic reads against the next async-proxy write to the same stage.
The fix adds
fence.proxy.async.shared::ctaafter every lane has consumed the current stage and before that stage can be selected for reuse.Problem
The combine loop overlaps loading and reduction with a two-stage ping-pong buffer:
The mbarrier wait makes the previous TMA load visible before the warp reads the stage. It does not, by itself, order those generic reads before a later TMA async-proxy write that reuses the same shared-memory addresses. Under unlucky timing, the new TMA load can overwrite data while lanes are still consuming the old contribution, corrupting the final reduction.
Fix
The new fence establishes the required generic-to-async proxy ordering at CTA scope:
The PTX instruction is exposed through a small helper in
deep_gemm/ptx/utils.cuhand used by both affected kernels. There are no API, layout, scheduling, or numerical changes.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.