feat(npu): support CANN 9.1 MegaMoe for Qwen3.5#1989
Draft
pjgao wants to merge 6 commits into
Draft
Conversation
pjgao
force-pushed
the
feat/cann91-megamoe-qwen35
branch
from
July 21, 2026 05:45
95f44e7 to
024e1de
Compare
This was referenced Jul 21, 2026
georgezhanglei85-eng
pushed a commit
to georgezhanglei85-eng/xllm
that referenced
this pull request
Jul 21, 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.
背景与目标
Qwen3.5-35B-A3B 是 MoE 模型。原有 NPU FusedMoE 路径将专家路由、跨 rank token dispatch、专家 FFN、激活和 combine 拆成多个阶段,存在额外的 kernel launch、中间张量读写以及通信与计算衔接开销。
CANN 9.1 ops-transformer 提供的 MegaMoe 将 MC2 通信与专家 FFN 组合到统一算子路径中,可以减少阶段切换和中间数据搬运,并为后续在 A3 上优化 Qwen3.5 的 decode 吞吐与时延提供基础。本 PR 的目标是把该算子安全接入 xLLM,同时不影响不满足条件的模型和原有 FusedMoE fallback。
接入方案
1. 配置与能力判断
mega_moe_policy中集中检查平台、模型、dtype、shape、EP 拓扑和算子可用性。2. ProcessGroup 级通信资源
MegaMoeCommResource,由 NPU ProcessGroup 持有并管理 KFC/HCCL context、远端 window 和拓扑信息。3. ACL 算子适配
aclnnMegaMoeGetWorkspaceSize与aclnnMegaMoe。libcust_opapi;标准 OPP 可作为其他算子的 companion vendor,但不能覆盖 MegaMoe ABI。4. FusedMoE 运行时接入
fused_moe根据 policy 选择 MegaMoe 或原有 fallback。mega_moe_runtime负责整理本地专家权重、输入、top-k 结果、通信 context 和输出张量,并调用 NPU kernel adapter。5. 异步 launch 生命周期
aclnnMegaMoe在设备任务入队后即可返回,而同一 rank 的多个 FusedMoE 层会复用 ProcessGroup 级 KFC context 和 HCCL window。定位过程中遇到的问题与解决方法
intermediate_hidden=512,A2/A3 共用检查采用了 A2 的 1024 下界KernelRegistry代码改动规模与分布
当前 PR 相对目标分支共修改 38 个文件,新增 3589 行、删除 16 行,净增 3573 行。
+2432/-12。+1153/-0。+4/-4。MegaMoeCommResource、ProcessGroup 生命周期、buffer span 与 launch fence新增代码主要集中在通信资源、运行时和测试三个部分,合计 2765 行,占全部新增行约 77%;模型层只做最小兼容修改,核心接入逻辑保持在 NPU 通信、kernel adapter 和 FusedMoE runtime 内。
依赖关系
5d42d7ccc213d0c135463f782afba2c792ee6e92。21cab2b6af14f18f56b7453024319065c8fb9764。2d281a246f438d026b277319b3126ba430f9ae8a。建议先合入三个算子、wrapper 依赖 PR,再刷新 xLLM submodule gitlink,最后合入本 PR。
验证环境
ascend910_93,EP8 使用 8 张 NPU,每张 64 GiB HBMnpu-smi 26.0.rc120260616_1851084487a8ae13c16daf1a2179d7520e71e6b21445f3b2f0a838b8c2c55d932fbdcdbba3c6cda1f88be816473a676ea9d95051e0be6481aecad9231b921e66dfa1b0f34c72915f308f0ca18验证结果
聚焦测试与构建
-Werror编译通过。EP8 服务级验证
immutable attempt:
fix-launch-fence-refactor-ep8-20260721T1215CST。579该结果属于针对本次 MegaMoe 跨 rank 随机 token 问题的 L2 集成回归,不等同于完整 CEval/GSM8K 分数评测。PR 历史清理仅移除了不随代码发布的机器适配,MegaMoe 接入和精度修复 diff 与上述验证路径一致。
PR 范围
本 PR 只提交 MegaMoe 接入、EP/DP 适配、通信资源管理、ABI/shape 校验和异步生命周期修复;机器相关适配不进入上游代码。