已合并
[sync] PR-40312: Update moe token unpermute DTensor support #42531
ascend-robot创建于 7月23日
[sync] PR-40312: Update moe token unpermute DTensor support #42531
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 ascend-robot 的贡献)7月23日 创建了 pull request,commit 4cf76307
7月23日 关联了issue:Update moe token unpermute DTensor support
ascend-robot
7月23日 评论:
7月23日 评论:
atomgit-bot
7月23日 评论:
7月23日 评论:
变更摘要
本次变更主要为 NPU MoE(混合专家)模块中的 token unpermute 相关算子新增 DTensor 分片策略支持。在 torch_npu/distributed/tensor/_moe_ops.py 中新增了两个分片策略注册函数,分别为 _npu_moe_token_unpermute 和 npu_moe_token_unpermute_grad_v2 算子提供全复制(Replicate)和 hidden_size 维度分片(Shard(1))两种分布式策略,使其能够在 DTensor 分布式场景下正确执行。
主要改动
- 新增
_npu_moe_token_unpermute_strategy分片策略:通过@register_sharding装饰器为npu._npu_moe_token_unpermute算子注册 DTensor 策略,支持全复制和hidden_size(第 1 维)分片两种策略,输出和输入张量均按对应策略标记Replicate或Shard(1)。 - 新增
npu_moe_token_unpermute_grad_v2_strategy分片策略:为npu.npu_moe_token_unpermute_grad_v2算子注册 DTensor 反向传播策略,同样支持全复制和hidden_size维度分片,其中分片策略下probs梯度标记为Partial()以适配分布式梯度聚合。


atomgit-bot
7月23日 评论:
7月23日 评论:
7月23日 添加了label:ascend-cla/yes
ascend-robot
7月23日 评论:
7月23日 评论:
ascend-robot
7月23日 评论:
7月23日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| torch_npu/distributed | ✅ 楚浩田, liangsongwei (2/2) | ✅ liangsongwei, 楚浩田 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


7月23日 添加了label:ci-pipeline-running
ascend-robot
7月23日 评论:
7月23日 评论:
ascend docs pipeline is running...


7月23日 添加了label:docs-ci-pipeline-running
ascend-robot
7月23日 评论:
7月23日 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


7月23日 删除了label:docs-ci-pipeline-running
7月23日 添加了label:docs-ci-pipeline-success
7月23日 删除了label:ci-pipeline-running
7月23日 添加了label:ci-pipeline-passed
ascend-robot
7月23日 评论:
7月23日 评论:
流水线 PR-pipeline_pytorch#48805 [ commitID:defc45bb ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_ARM_A3_Part_01 | 🛑 | >>> |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_DIST_ARM_Part_01 | ✅ | >>> | |
| UT_DIST_ARM_Part_02 | ✅ | >>> | |
| UT_DIST_ARM_Part_03 | ✅ | >>> | |
| UT_DIST_ARM_Part_04 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


7月23日 添加了label:approved
梁松伟
7月23日 评论:
7月23日 评论:
/approve


7月23日 添加了label:lgtm
7月23日 合入了pull request
ascend-robot
7月23日 评论:
7月23日 评论:
流水线 pytorch_gitcode_PR_multiVersion#13055 [ commitID:defc45bb ] 已完成


1. Origin pull request:
https://gitcode.com/Ascend/pytorch/merge_requests/40312
2. Original pull request related issue(s):
https://gitcode.com/Ascend/pytorch/issues/3108
3. Original pull request related commit(s):