已合并
Optimize the patch for FSDP #34631
yc_233创建于 4月28日
Optimize the patch for FSDP #34631
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 yc_233 的贡献)ascend-robot
4月28日 评论:
4月28日 评论:
ascend-robot
4月28日 评论:
4月28日 评论:
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 |
|---|---|---|
| repo-Ascend/pytorch | ✅ liujunzhu, chengpeng25 (2/2) | ✅ liujunzhu (1/1) |
| test | ✅ liujunzhu, wjlflyer, kisnwang, chengpeng25 (4/2) | ✅ liujunzhu, wjlflyer (2/1) |
| torch_npu/distributed | ✅ liujunzhu, wjlflyer, kisnwang, chengpeng25 (4/2) | ✅ liujunzhu, wjlflyer (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhenyu10, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4月28日 添加了label:ascend-cla/yes
ascend-robot
4月28日 评论:
4月28日 评论:
当前仓库存在以下 保护分支 :
| Protected Branch | Version | Release |
|---|---|---|
| master | ||
| v2.7.1 | ||
| v2.9.0 | ||
| v2.10.0 | ||
| v2.11.0 | ||
| v2.8.0 |
评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作
注意:
- /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
- 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭


此处折叠了396条消息 查看更多
liujunzhu
5月25日 评论:
5月25日 评论:
/approve


5月25日 添加了label:approvedlgtm
ascend-robot
5月25日 评论:
5月25日 评论:
5月25日 合入了pull request
ascend-robot
5月28日 评论:
5月28日 评论:
The repo or branch is not access to PR-cooperate, please check the current repo https://gitcode.com/Ascend/pytorch.git, branch=v2.11.0


【合入来源】
社区 issue:https://gitcode.com/Ascend/pytorch/issues/1788
【修改方案】
采用“上层复用原生,下层补齐后端语义”的设计:
torch-npu 删除 FSDP2 collectives patch:
_get_param_all_gather_inputstorch.ops.fsdp.all_gather_copy_inFSDPParamGroup.finalize_backwardfully_shard()入口只保留 NPU 侧增强 patch,例如内存缓存和 recompute/prefetch 状态管理op-plugin 在 foreach copy 算子中对齐同设备 D2D fast path:
at::native::can_use_fast_route(self, src)check_tensor_dtype_support_base(src)can_use_fast_route(self, src)本身会检查self/srcdtype 一致,因此 dtype 不同不会进入 NPU fast path,保持当前 NPU 不支持跨 dtype fast path 的既有语义。split_and_exec_npu_cmd_copy(self, src, /*non_blocking=*/true);memcpyBatch(self, src, non_blocking)不变foreach_tensor_copy_list_kernel_slow_(self, src, non_blocking)不变DO_COMPATIBILITY回退仍使用原始non_blocking【资料变更】
不涉及。
【接口变更】
不涉及。无新增客户可见接口;FSDP 对外使用方式不变。
_foreach_copy_的 NPU 后端实现由 op-plugin 承接,不新增 Python 侧公开接口。【功能验证】
测试场景:
fully_shard继续复用上游 PyTorch 原生finalize_backward、_get_param_all_gather_inputs、all_gather_copy_in主流程;_foreach_copy_在 op-plugin 中优先走 D2D fast path,不满足条件时回退到已有 batch copy / slow path;测试方法:
python test/test_v2r1_ops/test_foreach_copy.pypython test/test_v2r2_ops/test_foreach_copy.py执行结果:
UT看护:
torch.npu.synchronize(),覆盖新增异步 D2D fast path 行为。【CheckList】