已合并
[sync] PR-40339: modify _dynamo_device.py for benchmarks multi process set device error #40448
[sync] PR-40339: modify _dynamo_device.py for benchmarks multi process set device error #40448
已合并
ascend-robot创建于 7月8日
ascend-robot
ascend-robot成员
7月8日

1. Origin pull request:

https://gitcode.com/Ascend/pytorch/merge_requests/40339

https://gitcode.com/Ascend/pytorch/issues/2645

Sha Datetime Message
bcd765c7 2026-07-07 16:19:48 +0800 CST modify _dynamo_device.py for benchmarks multi process set device error
likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 ascend-robot 的贡献)
ascend-robotascend-robot成员
7月8日 创建了 pull request,commit 18825bbf
ascend-robotascend-robot成员
7月8日 关联了issue:[Bug]: A5 跑benchmark的triton 后端 BERT_pytorch模型,plog报set_device卡死
atomgit-bot
atomgit-bot
7月8日 评论:

变更摘要

本次变更是从上游 PR #40339 同步而来,主要修复了 torch_npu/utils/_dynamo_device.pyNpuInterface.exchange_device 方法在多进程 benchmark 场景下调用 set_device 报错的问题。修复方式是在切换设备前增加当前设备与目标设备的比较判断,仅当两者不同时才执行 set_device,避免不必要的设备设置操作引发错误。

主要改动

  • NpuInterface.exchange_device 增加设备相等性检查:在调用 set_device(device) 前,新增 if curr_device != device 条件判断,仅当当前设备与目标设备不同时才执行设备切换,从而避免多进程场景下因重复/无效的设备设置导致的错误。
  • 保留原有设备返回逻辑不变:无论是否执行 set_device,方法始终返回切换前的当前设备编号 curr_device,对外接口行为无变化。
likedislike
atomgit-bot
atomgit-bot
7月8日 评论:

代码审查

✅ 未发现问题

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
7月8日 评论:

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/utils htchu, ffmh (2/2) htchu (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

ascend-ds-bot, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
7月8日 评论:
流水线 PR-pipeline_pytorch#42266 [ commitID:4020b856 ] 运行中
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 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_X86_Part_01 🕚 >>>
UT_X86_Part_02 🕚 >>>
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 🕚 >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
ascend-robot
ascend-robot成员
7月8日 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
7月8日 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
7月8日 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
7月8日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
7月8日 添加了label:docs-ci-pipeline-success
LucciC
LucciC成员
7月9日 评论:

retry

likedislike
ascend-robot
ascend-robot成员
7月9日 评论:

重试流水线失败:PR-pipeline_pytorch 仅失败状态流水线支持重试操作。

likedislike
ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月9日 评论:
流水线 PR-pipeline_pytorch#42266 (重试第1次) [ commitID:4020b856 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 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_X86_Part_01 🛑 >>>
UT_X86_Part_02 🛑 >>>
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 >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
htchu成员
7月9日 评论:

/approve

likedislike
ascend-robotascend-robot成员
7月9日 添加了label:approved
ffmh
ffmh成员
7月9日 评论:

/lgtm

likedislike
ascend-robotascend-robot成员
7月9日 添加了label:lgtm
ascend-robotascend-robot成员
7月9日 合入了pull request
ascend-robot
ascend-robot成员
7月9日 评论:
流水线 pytorch_gitcode_PR_multiVersion#12290 [ commitID:4020b856 ] 已完成
likedislike