Repository navigation
perf(megamoe): prioritize shared dX before routed weight gradients - #9
Merged
davidhe91 merged 1 commit intoDec 4, 2026
Conversation
Schedule eligible shared dX in the Cube candidate window so the fused token-gradient restore can overlap routed weight gradients in the direct FP32 path.
davidhe91
approved these changes
Dec 4, 2026
davidhe91
merged commit Dec 4, 2026
5e2b332
into
davidhe91:megamoe-ascend950-integration
1 check failed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
允许共享
dX提前调度时,将 Dense BMM 的共享dX从共享候选 FIFO 提升到 Cube 候选窗口。这项调整适用于prioritize_routed生效、prioritize_shared["backward"]到达dx,且融合反向收尾直接写 FP32 权重梯度的路径。Cube 先扫描路由主窗口。主窗口没有就绪任务时,已就绪的共享
dX可以先于路由权重梯度执行。共享dX尚在等待自身输入时,候选窗口可跳过它并继续选取就绪的dW1/dW2。Stream-K 的共享dXpartial 继续通过已有的 AIV0 归并供数规则进入候选窗口。BackwardRestoreDx等待共享dX和 Combine 接收完成。优化前,候选窗口中持续就绪的路由权重梯度会把共享dX留在 FIFO,导致 token 梯度归并等到 Cube 尾部。提升共享dX后,AIV0 可以在 Combine 收齐后开始归并,与 Cube 上剩余的路由权重梯度重叠。编排复用现有的事件、依赖和 worker 队列 ABI。Evidence
Ascend950DT EP4,4096 tokens,hidden 7168,intermediate 2560,每 rank 8 个本地专家,Top-K 8。使用 MXFP8 UDMA Pull、Host 路由、共享专家全量优先、输入和激活重算及 FC2 前加权。ABBA 每个策略 96 个关闭 profiler 的 NPU Event 样本,先按迭代取各 rank 最大值,再计算分位数。
独立采集的 rank 0 内部 trace 中,Combine 在两组均约 6.34 ms 完成,共享
dX从 10.46 ms 提前至 5.99 ms,token 梯度归并从 11.88 ms 提前至 7.97 ms 结束。dX、路由概率梯度和 4 项权重梯度的字节摘要全部一致。EP4 全核流水
4 个 rank 的优化前后并排比较。每个 rank 按 Cube、AIV0、AIV1 分组,各 32 条轨道。横轴以各 rank 自身的反向 kernel 入口为零点。浅灰轨道表示该核在这次反向采集中无记录。
Merge Danger
prioritize_routed生效且融合收尾直接写 FP32 权重梯度的反向队列。