Repository navigation
feat(megamoe): add MXFP8 Token Wave and streamline device routing - #4
Merged
davidhe91 merged 5 commits intoDec 2, 2026
Conversation
forever-moe
force-pushed
the
feat/megamoe-token-wave-integration
branch
2 times, most recently
from
December 2, 2026 10:43
9ae1daa to
c325528
Compare
The double-buffer events only order MTE2 reuse. Join the final MTE3 write to the scalar pipe before a completed copy may publish a credit. Token Wave can otherwise consume an unfinished self GET.
Add forward and backward row-tile scheduling for UDMA Pull. Use the existing policy selector with configurable compute_split, and publish Dispatch and first-GMM readiness to AIV0 through per-invocation bitmaps. Add sparse Wave profiling and enforce the matching runtime and native ABI contracts.
Apply the routed backward dependency rules across policies. Whole-expert policies wait for all local dX before weight gradients. Token Wave prioritizes dA and dX while allowing ready weight gradients in gaps.
Clear Token Wave forward scratch in bounded route metadata and use device validation for shared expert preflight errors. Allocate shared buffers on the caller stream after submitting metadata and reuse validated forward weight views within each invocation.
forever-moe
force-pushed
the
feat/megamoe-token-wave-integration
branch
from
December 2, 2026 10:58
c325528 to
d44048b
Compare
Use the merged input-list parameter when loading the quantization descriptor. The old parameter name prevents Ascend C compilation after the rebase.
davidhe91
approved these changes
Dec 2, 2026
davidhe91
merged commit Dec 2, 2026
def37a6
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.
/kind feature
接口变更
tuning = MegaMoeTuningOptions( dispatch_mode="pull", dispatch_split=128, combine_split=128, - scheduler=MegaMoeSchedulerOptions(policy="two_expert_pipeline"), + scheduler=MegaMoeSchedulerOptions(policy="token_wave"), + compute_split=256, ) -with profiler.mega_kernel_profile() as capture: +with profiler.mega_kernel_profile(granularity="wave") as capture: train_step()compute_split支持 256 和 512,启用 Token Wave 时默认 256。Wave 采集只用于 Token Wave。当前支持 Ascend950、32 个 AIC、EP8、MXFP8 UDMA Pull、t6、hidden_size=7168、intermediate_size=3072和 FC2 后概率加权。共享专家和选择性重算各自走整专家路径。开启设备路由时,同一 EP 组要求等长输入,并使用平均接收量作为容量上界。Token Wave 调度
dY并累积行数QuantX和SwiGLUQuant,优先做激活量化QuantDY和SwiGLUGradQuantdA、dX,在可用空档执行已就绪的整专家权重梯度dX对应分片写回即可开始 Combine计算 Tile 从专家行起点切分。AIC0 发布 Wave,AIC 滚动分配 M×N 块。512 行 Tile 最多由两个 256 行 M 块组成。完整行块的 Wave 复用 Blaze batch,含短尾的 Wave 走通用 GMM。AIV 收到最后一次相关 FIX 信用才发布就绪。本地 MTE 拷贝在 Scalar 发布 GET 信用前增加
MTE3→Scalar完成同步。整专家的
builder_order和two_expert_pipeline在本 rank 所有路由专家完成dX后执行权重梯度。各专家的 Combine 按自己的dX就绪时刻启动。设备路由
稳态的纯路由专家按「提交计数交换 → 排列 token → 等待计数交换 → 生成元数据」在调用流上执行。设备路由 kernel 同时清零 Token Wave 的正向 scratch,省去一次单独的清零提交。共享专家在元数据提交后准备前向缓冲区,并复用本次调用已验证的权重视图。涉及容量增长时,流间顺序先保证元数据校验,再进入集体扩容。
本次 rebase 后的短测
实测提交为
6b06122,基底为40a66d4。环境为 Ascend950、CANN 9.2、MXFP8 UDMA Pull,使用 t6 配置并关闭 Profiling。每组预热 4 步、计时 12 步,关闭设备路由的用例运行两组。每步取最慢 Rank,再统计 P50。dX和共享专家dW1有逐字节差异,rebase 前的c325528使用同一输入复现了这两项差异。.cpu()和.tolist()回读拦截检查。短测的端到端和 Host 提交数字适用于表中的输入规模。6b06122修正了 MXFP8 量化描述符的输入列表引用。正反向 CANN 内核和 Torch 桥接均已重编,设备短测加载 ABI 9。Rank 2 正反向 Profiling
下列时间线来自首轮 EP8 全尺寸验收
18febd7。每 rank 7 专家、3584 token、TopK=6、UDMA 双 QP。两图都从首个有效 Dispatch 对齐,分别列出 AIC、AIV0 和 AIV1。正向
GMM1 提前 204 µs,首片 Combine 提前 680 µs。GMM2 最后完成时刻相差约 5 µs,末片 Combine 提前 87 µs。
反向
dA提前 391 µs,首片 Combine 提前 1.29 ms,末片 Combine 提前 3.68 ms。Tile 版最后一次权重梯度比末片 Combine 晚 3.36 ms。首轮关闭 Profiling,每组预热 7 步并保留 55 步,逐步取 8 rank 的最大值。端到端 P50 从 15.501 ms 降到 15.206 ms,AB 和 BA 两组分别下降 2.72% 和 0.44%。
回退与影响
Token Wave 和设备路由均可通过配置关闭。本分支的 MXFP8 路径需要配套构建 ABI 9 原生包。回退提交时,Python 与原生包须一起回到同一版本。