已合并
fix: 修复dflow非0卡部署context校验失败并保证API层context透明 #4697
lining23666创建于 9 天前
fix: 修复dflow非0卡部署context校验失败并保证API层context透明 #4697
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 lining23666 的贡献)9 天前 创建了 pull request,commit 6207b6ad
9 天前 添加了label:stat/needs-squash
9 天前 添加了label:cann-cla/yes
CANN-robot
9 天前 评论:
9 天前 评论:
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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ge | ✅ yangyongqiang0606, stevenaw0, xchu42 (3/2) | ✅ yangyongqiang0606 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
lining23666, thanks for your pull request. All authors of the commits have signed the CLA. 👍


9 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为评审人
9 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为评审人
9 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为审查人
9 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,fu-jun2,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为审查人
lining23666
9 天前 评论:
9 天前 评论:
compile


Llining23666
9 天前 update merge request[project id: 8824148, iid: 4697, commit_id: b70f65be543714b04dcd545a8b0fa18dbf226721] virtual merging success
9 天前 update merge request[project id: 8824148, iid: 4697, commit_id: b70f65be543714b04dcd545a8b0fa18dbf226721] virtual merging success
CANN-robot
9 天前 评论:
9 天前 评论:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


9 天前 添加了label:ci-pipeline-running
9 天前 删除了label:ci-pipeline-running
9 天前 添加了label:ci-pipeline-passed
8 天前 取消了草稿状态
黄桂军
8 天前 评论:
8 天前 评论:
/lgtm


xchu42
8 天前 评论:
8 天前 评论:
/lgtm


8 天前 添加了label:lgtm
yangyongqiang
7 天前 评论:
7 天前 评论:
/approve


7 天前 添加了label:approved
7 天前 合入了pull request
Pull Request
描述
修复 dflow 部署模型到非 0 卡时加载失败的问题,并保证 dflow API 对调用线程 runtime context 的透明性。包含两个配套修改:
1. SubmitEventSync 入口绑卡(dflow/deployer/common/data_flow/event/proxy_event_manager.cc)
根因:runtime context 是线程私有的,
ProxyEventManager::SubmitEventSync会在部署线程池工作线程(ge_dpl_ldlm 加载子模型线程等)中调用rtEschedSubmitEventSync,而该线程从未执行过aclrtSetDevice,报EE1018: No valid context is bound to the current thread。部署 0 卡时命中 runtime 默认 context 侥幸通过,非 0 卡(如 numa_config 仅配置 2/3/4/5 卡)必现。修复:
SubmitEventSync入口统一aclrtSetDevice(device_id),单点覆盖全部 6 类远程内存组事件(CreateGroup/AddGroup/AllocCache/AllocMbuf/FreeMbuf/CopyQMbuf),与库内 DestroyQueue、UnloadSubmodels 既有做法一致。该路径仅在部署期和变量同步期调用,不在推理热路径。2. dflow API 入口 context save/restore(dflow/runner/session/dflow_api.cc)
背景:内部路径(如 feed 的 io_helper)会在 API 调用线程上 SetDevice 并残留切换,污染调用方(如 torch_npu 用户主线程)的 context。
修复:API 层新增
RtCtxGuard(RAII),入口记录调用线程 context,出口恢复,使内部设备/context 切换对调用方透明:两个修改配合形成完整方案:内部各依赖 context 的调用点用前自行绑卡(可自由切换),API 层对调用方上下文透明。
变更类型
关联的Issue
如何测试
核对清单
其他信息
本 PR 为草稿状态,真机验证进行中,完成后转正式。