Repository navigation
feat: make shared GMM and EP collectives traceable - #1267
Merged
yu-chen-code merged 1 commit intoOct 26, 2026
Merged
Conversation
yu-chen-code
requested review from
liuchongming74,
suteng,
yangzhenzhang02 and
yaoyifanx
as code owners
October 21, 2026 16:37
Contributor
Author
|
/check-pr |
Contributor
Author
|
/retest |
|
yu-chen-code
force-pushed
the
feat-ep-gmm-primitives
branch
2 times, most recently
from
October 21, 2026 18:23
b111b4c to
aff3f4d
Compare
Contributor
Author
|
/check-pr |
Contributor
Author
|
/check-pr |
Contributor
Author
|
/retest |
|
|
Contributor
Author
|
/retest |
|
|
Contributor
Author
|
/retest |
|
Gate trigger failed: please fix the /check-pr findings and obtain the |
Contributor
Author
|
/check-pr |
Contributor
Author
|
/retest |
Contributor
Author
|
/check-pr |
Contributor
Author
|
/retest |
|
|
yangzhenzhang02
approved these changes
Oct 23, 2026
yaoyifanx
approved these changes
Oct 23, 2026
5 tasks done
This was referenced Dec 1, 2026
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.
Paired: GitHub #1267 ↔ GitCode !1819
What type of PR is this?
/kind feature
/kind refactor
What does this PR do / why do we need it:
让基础同步 EP 的真实变长路由能够被捕获,同时沿用现有动态图的计算和参数布局。本 PR 提供 #1221 所需的公共 EP/GMM 能力,不包含编译器改动。
现有执行顺序保持为:模型 EP adapter 完成专家分片和 forward 绑定 → Router 产生专家编号与权重 → 按目标 rank/专家排序 token → 交换 counts 和 payload → 本地 GMM 专家计算 → 回传并按原 token 位置加权合并。
ep_exchange_counts:eager 继续使用同步dist.all_to_all_single;捕获时记录 functional count A2A,并显式等待 counts 可读。ep_split_sizes:eager 读取具体 split;捕获时从 counts 形成数据相关的符号长度,约束长度非负,并在已知发送行数时检查 split 总和。路由变化对应的收包长度仍由每次运行的 counts 决定。ep_all_to_all:捕获时使用带 autograd 的 functional payload A2A,由消费者插入等待;eager 继续走原有后端分支。正常的变长 dispatch 只把 count 交换和 split 提取改为调用上述 helper。grouped_matmul和 SwiGLU 的_get_npu_grouped_matmul缓存 autograd wrapper 均保留。两者只在非 compile、numel 为 int 且等于零时使用零权重梯度;其他情况执行原生 split-K GMM,避免对数据相关形状做 Python 布尔判断。本 PR 不修改
hyper_parallel/compile/或 EP 指南。ShapeEnv、图内运行约束、dense/EDP 分组及 GraphCompiler 接入由 #1221 完成。重计算和 EP overlap 本阶段不开发。Which issue(s) this PR fixes:
Part of #1112;为 #1221 提供公共 EP/GMM 前置能力,不单独关闭整图 EP 总需求。
Test Plan and Test result:What scenarios were tested, and what were the verification results(Function, performance, reliability, etc.):
验证环境:Ascend 910B2,Python 3.12.13,PyTorch
2.9.1+cpu/ torch_npu2.9.1,CANN 9.3。以下为当前提交b9350695的本地验证结果。python -m pytest -q tests/ut/core/expert_parallel tests/ut/auto_models/distributed tests/ut/components/functional/test_grouped_matmul.py:252 passed;生产代码增量覆盖率 29/29(100%)。独立 tests/安装包目录布局下的新增 GMM UT 也通过。python -m pytest -q -s tests/torch/expert_parallel/test_grouped_matmul_graph.py:2 passed。两个 GMM wrapper 均保留 forward/dgrad/wgrad 三个原生节点;同图重放全零、单专家及混合负载,与 eager 逐张量零误差。上述结果对应当前代码;正式门禁请查看该提交的构建 1038,不沿用旧提交的通过结果。
Code review checklist [illustration]:
Special notes for your reviewers:
公共前置的审阅重点是:eager 通信和计算语义是否保持,以及同一 GMM 图能否处理专家负载从非零到全零的切换。这里不单独完成 GraphCompiler 接入。
动态 split 提取仍包含 CPU/host 读取;functional 节点可被 FX 捕获不等于训练 step 没有 host 同步,也不代表设备图编译后端已完成。与 #1221 的公共文件保持一致,后者在此基础上接入基础 EP 联合图训练。