已合并
[sync] PR-37189: fix: unskip test_reductions test case in test_multiprocessing_api.py #37686
ascend-robot创建于 6月5日
[sync] PR-37189: fix: unskip test_reductions test case in test_multiprocessing_api.py #37686
已合并
ascend-robot创建于 6月5日
ascend-robot
ascend-robot成员
6月5日

1. Origin pull request:

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

Sha Datetime Message
908d8d41 2026-06-05 11:03:14 +0800 CST test(reductions): add skipUnless decorator for driver version check

Add @unittest.skipUnless to test_reductions to skip the test when
driver version < 25.3, as NPU IPC reduce/rebuild requires driver >= 25.3.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
e00edd92 2026-06-04 15:25:45 +0800 CST Revert "test(reductions): add debug logging for NPU IPC reduce/rebuild path"

This reverts commit d1ee69dcbd891a48ced0f34471547b25710a5679.
d1ee69dc 2026-06-03 15:53:58 +0800 CST test(reductions): add debug logging for NPU IPC reduce/rebuild path

Add torch_npu.multiprocessing.reductions debug logger to trace:
- _npu_reduce_tensor: which branch (NPU/meta/CPU), share_npu() return values, cache key format
- rebuild_npu_tensor: cache lookup key format, HIT/MISS, _new_shared_npu() result, rebuilt tensor data
- test worker: rebuild_fn args, rebuilt tensor data in child process

Purpose: verify cross-process IPC reduce→rebuild takes correct code path.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
5f3fe781 2026-06-01 10:50:39 +0800 CST fix(test): send tensor data as list to avoid resource_sharer connection reset

CPU tensor pickled through Queue uses rebuild_storage_fd which requires
resource_sharer Unix socket. Child process exits before parent can
establish connection. Convert tensor to plain list before sending.

Co-Authored-By: Claude noreply@anthropic.com
4fbab4e4 2026-06-01 10:37:09 +0800 CST test(multiprocessing): use explicit reduce/rebuild in cross-process test

Address review comments:
- Worker now receives (rebuild_fn, args) from reduce_tensor, explicitly
calls rebuild_fn(*args) to reconstruct tensor
- Main process puts reduced_npu handle instead of raw tensor
- Main process compares result with original npu_tensor instead of
hardcoding expected values in worker

Co-Authored-By: Claude noreply@anthropic.com
8b7be3c2 2026-05-30 17:28:58 +0800 CST fix(test): synchronize NPU before putting tensor to Queue

Child process received all zeros because NPU write cache was not
flushed before IPC handle export. torch.npu.synchronize() ensures
data is written to physical memory before cross-process transfer.

Co-Authored-By: Claude noreply@anthropic.com
89953a94 2026-05-30 17:21:03 +0800 CST fix(test): add diagnostic info for NPU tensor mismatch

Include actual received data in failure message to diagnose IPC issue.

Co-Authored-By: Claude noreply@anthropic.com
ad27f741 2026-05-30 17:07:25 +0800 CST fix(test): capture child process error in test_reductions

Worker now sends result status back via Queue instead of relying on
exitcode. This propagates actual error messages from the child process
for diagnosis.

Co-Authored-By: Claude noreply@anthropic.com
9b2a8888 2026-05-30 16:42:56 +0800 CST fix(test): fix NPU tensor cross-process transfer direction

Main process puts tensor to Queue, child process gets and validates.
Matches torch_npu multiprocessing test patterns. Use Queue instead of
SimpleQueue to avoid resource_sharer lifecycle issues.

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
db6b692b 2026-05-30 16:37:35 +0800 CST fix(test): remove unsupported timeout from SimpleQueue.get()

SimpleQueue.get() does not accept timeout parameter in Python 3.10.

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
c0820b36 2026-05-30 16:20:09 +0800 CST test(multiprocessing): merge multiprocess rebuild into test_reductions

Combine NPU multiprocess rebuild into test_reductions instead of a separate
test case. CPU tensor uses same-process rebuild, NPU tensor uses cross-process
rebuild via Queue.

Co-Authored-By: Claude noreply@anthropic.com
aedaa436 2026-05-30 16:17:22 +0800 CST fix(test): move worker function to module level for spawn pickle

spawn mode cannot pickle local functions. Move _npu_tensor_worker to
module top level.

Co-Authored-By: Claude noreply@anthropic.com
0e37c8f8 2026-05-30 10:40:03 +0800 CST test(multiprocessing): fix test_reductions and add multi-process NPU test

- Remove @unittest.skip decorator from test_reductions
- Remove unreliable same-process NPU tensor reconstruction assertion
(IPC handles cannot be imported in the same process that exported them)
- Add test_reductions_multiprocess to validate cross-process NPU tensor
sharing via Queue, aligned with PyTorch upstream CUDA test pattern

Co-Authored-By: Claude noreply@anthropic.com
likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 ascend-robot 的贡献)
ascend-robotascend-robot成员
6月5日 创建了 pull request,commit 50564b88
ascend-robotascend-robot成员
6月5日 添加了label:stat/needs-squash
ascend-robotascend-robot成员
6月5日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
6月5日 评论:

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
test liujunzhu, wanglijun55 (2/2) liujunzhu (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
wuyouqi1
wuyouqi1成员
6月5日 评论:

compile

likedislike
ascend-robot
ascend-robot成员
6月5日 评论:

Ascend docs pipeline is running...

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

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

likedislike
ascend-robotascend-robot成员
6月5日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
6月5日 添加了label:docs-ci-pipeline-success
ascend-robot
ascend-robot成员
6月5日 评论:

Ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
6月5日 删除了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
6月5日 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
6月5日 评论:

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

likedislike
ascend-robotascend-robot成员
6月5日 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
6月5日 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
6月5日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
6月5日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
6月5日 评论:
流水线 PR-pipeline_pytorch#29909 已完成
阶段 任务名 状态 详情
编译构建 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 >>>
likedislike
liujunzhu
liujunzhu成员
6月5日 评论:

/approve

likedislike
ascend-robotascend-robot成员
6月5日 添加了label:approved
wanglijun55成员
6月5日 评论:

/lgtm

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