Repository navigation
[Testcase Refactoring] Resolve default backend from device in common test base classes - #194992
shichuanliujie9527 wants to merge 7 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194992
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit cf5505b with merge base ed1fcb4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "module: tests/distributed" |
2c0d53c to
37b8902
Compare
48adf7c to
5634c8c
Compare
5634c8c to
1a3273e
Compare
236d2cd to
444a80d
Compare
JamesD18
left a comment
There was a problem hiding this comment.
LGTM.DistributedTestBase ( DynamoDistributedMultiProcTestCase )are referenced across 12 files, and ShardedTensorTestBase spans 15 files. All of these changes are within the scope of the test‑decoupling work.
444a80d to
f2386de
Compare
|
The focused CPU run exposed one issue in the previous head: for a bare The current head changes only that precheck to Targeted validation on the current implementation:
@JamesD18, could you please re-review this one-line follow-up on the current |
…ckend - Remove module-level device_type and backend variables; use self.backend property from ShardedTensorTestBase (PR pytorch#194992) via @with_comms() default backend=None - Revert init_rpc=False (unrelated to device-generic refactor) - Add allow_xpu=True to instantiate_device_type_tests - Change except_for=['cpu'] to except_for='cpu' - Pass device parameter through get_device_specs and _test_common_failures using torch.device(device).type for per-variant device_type
|
@pytorchmergebot revert -c ghfirst -m "breaks internal build" |
|
Issue reproduces in OSS:
Diagnostic (sanitised): Raised at torch/distributed/rpc/backend_registry.py in _validate_device_maps, reached from rpc.init_rpc in init_rpc, from init_comms, from with_comms.wrapper in torch/testing/_internal/distributed/_shard/sharded_tensor/init.py. Worker processes exit with code 10. |
|
@pytorchbot revert -c ghfirst -m "breaks internal build" |
|
@pytorchbot successfully started a revert job. Check the current status here. |
|
@shichuanliujie9527 your PR has been successfully reverted. |
… common test base classes (#194992)" This reverts commit 8bf87da. Reverted #194992 on behalf of https://github.com/atalman due to breaks internal build ([comment](#194992 (comment)))
This PR was reopened (likely due to being reverted), so your approval was removed. Please request another review.
|
@pytorchbot successfully started a revert job. Check the current status here. |
Reverting PR 194992 failedReason: Command Details for Dev Infra teamRaised by workflow job |
fffrog
left a comment
There was a problem hiding this comment.
Hi @shichuanliujie9527, this PR have been reverted, please update this PR, thank you
d5b9ec6 to
cf5505b
Compare
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
- Remove module-level device_type/backend globals; backend resolved via ShardedTensorTestBase.backend (PR pytorch#194992) through @with_comms() default backend=None - Reorder decorators: @requires_capabilities before @with_comms so capability is checked before communicator initialization - Pass device parameter to get_device_specs/_test_common_failures, derive device_type via torch.device(device).type - Add allow_xpu=True and except_for='cpu' to instantiate_device_type_tests
Motivation
Device-instantiated subclasses of
ShardedTensorTestBasealready receivedevice_type, but a bare@with_commsstill selects the fixed"nccl"default.Use the device's registered default backend for these subclasses while retaining
the existing decorator argument for callers that have not yet adopted
instantiate_device_type_tests.Changes
Only
torch/testing/_internal/distributed/_shard/sharded_tensor/__init__.pychanges:
backend(self, device), using the existingdistimport to calldist.get_default_backend_for_device(device).with_comms, resolve the backend fromself.device_typewhen it ispresent and non-
None; otherwise use the decorator'sbackendargument.backend_name, avoiding shadowing the outer decoratorargument, and use it for both the device-count check and
init_comms.skip if there are fewer devices than
world_size. Remove thecurrent_accelerator()probe and the comparison against its default backend.The
"nccl"defaults ofwith_comms,init_comms, andinit_pgremain.Existing backend availability checks, rank binding, RPC initialization, and
cleanup methods are unchanged. There are no changes to
common_distributed.py.Behavior
self.device_type; this takes precedence over the decorator argumentdevice_type"nccl"init_pg/init_commscall"nccl"defaultValidation
backend selection, reuse of the same closure, RPC flag forwarding, and
the insufficient-device skip.
TestDistributedStateDictSaveLoadWithCachingNPU.test_read_write_shard_tensor_npuin
test/distributed/checkpoint/test_file_system_checkpoint.py.The unmodified business test completed two save/load rounds, data equality
checks, and process-group destruction. Parent and worker imports were verified.
The run reused an existing PyTorch/torch_npu binary environment with isolated
test-helper sources and device-test capability support from #191919 and #192043.
The final review cleanup reuses
dist.get_default_backend_for_deviceinsteadof importing
distributed_c10dseparately; both names refer to the same function.That two-line cleanup passed patch replay, syntax, PYFMT, and Ruff checks.
The device test was run before this import-only cleanup.