Repository navigation
perf(megamoe): prioritize routed backward with Pull input replay - #8
Merged
davidhe91 merged 1 commit intoDec 3, 2026
Conversation
forever-moe
marked this pull request as ready for review
December 3, 2026 10:59
forever-moe
force-pushed
the
feat/megamoe-backward-optimization
branch
3 times, most recently
from
December 3, 2026 11:58
ee7b7b5 to
b5f9569
Compare
forever-moe
force-pushed
the
feat/megamoe-backward-optimization
branch
from
December 3, 2026 12:35
b5f9569 to
410ceb1
Compare
forever-moe
force-pushed
the
feat/megamoe-backward-optimization
branch
2 times, most recently
from
December 3, 2026 12:40
651b546 to
410ceb1
Compare
davidhe91
approved these changes
Dec 3, 2026
davidhe91
merged commit Dec 3, 2026
8701a75
into
davidhe91:megamoe-ascend950-integration
0 of 2 checks passed
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
class MegaMoeSchedulerOptions: prioritize_shared: Mapping[Literal["forward", "backward"], str] | None = None + prioritize_routed: bool = Trueprioritize_routed默认允许ascend950MXFP8 逐专家反向的路由调度优化。实际生效需要同时使用 Pull 分发、输入重算(permute=True)和窗口8。prioritize_shared继续按阶段前缀控制共享任务能否提前参与。输入重算可单独使用或与激活重算组合。其他配置按关闭路径编排。显式设置
prioritize_routed=False可关闭优化。Cube 主窗口内就绪的路由
dA/dX优先。候选窗口根据数据依赖识别为共享 AIV0 供数的 Cube 任务,让其后续 Vector 计算与路由权重梯度重叠。例如共享
dA先产出 SwiGLU 梯度量化的输入,Cube 随后执行就绪的路由
dW1/dW2。任务仍需满足自身依赖和共享候选范围。适配目标基线
e8167ff的融合反向收尾。BF16 路由权重梯度回写等待实际发布的 rank 级 Cube 汇合事件,融合 token 梯度恢复在共享
dX和 Combine 都就绪后才能被选中。Evidence
prioritize_shared={"backward": "dx"}、窗口8、设备路由及 FP32 partial dW。三种重算组合各测 FC2 前、后加权,路由开关前后共 336 项输出和梯度逐位一致。
下表保留制定默认策略前的六组开关对照。仅激活重算的两组用于说明关闭依据,当前默认生效范围为两种包含输入重算的组合。
每档 12 步独立计时。表内为关 → 开,单位 ms。Cube、AIV0 和 AIV1 间隙按 rank 0、2 的每核首末有效任务之间的空闲取平均。
Combine 收尾取两个采样 rank 中较晚者。单次 trace 和未打点计时分别采集。
整步 P50 有 4/6 组下降,最大降幅为双项重算、FC2 后加权的 1.02 ms(5.03%)。仅激活重算时,FC2 后加权上升 0.19 ms(1.01%),FC2 前加权上升 0.21 ms(1.11%)。百分比按各组关闭路由优先时的整步 P50 计算。
双项重算、FC2 后加权时,Cube 平均间隙为 0.63 → 0.17 ms。rank 0 首个路由 dW2 在 6.19 → 5.18 ms 启动。
共享 dA 与 SwiGLU 梯度量化分别在 0.36 → 0.69 ms 和 0.57 → 2.03 ms 启动。
开启后,共享 SwiGLU 梯度量化仍与路由 dA 重叠,共享 dX 留在主反向 kernel 尾部。
Combine 与共享 dX 分别在 7.60 → 7.04 ms 和 2.63 → 10.40 ms 收尾。
输入重算与激活重算
六组计时与阶段数据
Merge Danger
双向门。符合条件的 Pull 输入重算层可用
prioritize_routed=False逐层关闭优化。MXFP8 运行需要配套 ABI11制品。两类候选同时存在时使用 worker 队列布局5。