Repository navigation
[Testcase Refactoring] Tag test_format_utils.py with hw_classification - #192045
shichuanliujie9527 wants to merge 2 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/192045
Note: Links to docs will display an error until the docs builds have been completed.
|
|
@pytorchbot label "module: tests/distributed" |
… gating Refactor TestTPFSDPIntegration to the device-agnostic pattern from the testcase-refactoring initiative (pytorch#185590) so it runs on out-of-tree PrivateUse1 backends (NPU) without patching common_fsdp module globals. Introduce TPFSDPIntegrationTestBase(FSDPTestContinuous) that resolves the device and backend at runtime: _resolved_device_type() resolves the generic "privateuse1" token to the registered backend name, backend_str goes through dist.get_default_backend_for_device (npu->hccl, cuda->nccl, no hardcoding), and world_size is accelerator-aware. This mirrors DTensorPPTestBase in pytorch#192051. Tag the class HardwareClassification.ACCELERATOR, since all three methods run multi-device FSDP+TP collectives on an accelerator. Replace @skip_if_lt_x_gpu(4) with @requires_world_size(4) plus @requires_capabilities(Capability.distributed.backend/dtensor/fsdp), the same gates pytorch#192045 uses for the FSDP+DTensor path. Drop the module-level device_type global and point its six call sites at self._resolved_device_type(); the nested TestModel captures the resolved device via closure. Switch instantiate_parametrized_tests to instantiate_device_type_tests(only_for=["cuda","xpu","privateuse1"], allow_xpu=True) so per-device variants are generated and registered PrivateUse1 backends are auto-discovered. No torch_npu or backend-specific import is introduced; backend capability registration is handled separately via register_privateuse1_capabilities (pytorch#192043). Test Plan: The capability-gated form depends on pytorch#190846 (Capability/ requires_capabilities) and pytorch#191919 (Capability.distributed namespace + generalized requires_world_size), not on main yet, so opened as draft until they land (same as pytorch#192045/pytorch#192046). NPU runtime additionally needs pytorch#192043 (register_privateuse1_capabilities) plus the backend's distributed.* registration in the torch_npu repo. The full capability-gated form was validated end-to-end on 4x Ascend 910B4 (privateuse1=npu) by porting the foundation mechanism onto a local checkout (the foundation PRs do not apply cleanly to the older base). With NPU registering distributed.backend/dtensor/fsdp as supported, instantiate_device_type_tests generates the TestTPFSDPIntegrationPRIVATEUSE1 variant and all three tests pass: python test/distributed/fsdp/test_fsdp_tp_integration.py # Testing class TestTPFSDPIntegrationPRIVATEUSE1 on 4 npu # Ran 3 tests ... OK This exercises the FSDPTestContinuous x PrivateUse1TestBase MRO and the @requires_capabilities / @requires_world_size gates on a multiprocess test, both previously open risks for this test type. Authored with the assistance of an AI assistant (Claude Code). Co-Authored-By: Claude <[email protected]>
… gating Refactor TestTPFSDPIntegration to the device-agnostic pattern from the testcase-refactoring initiative (pytorch#185590) so it runs on out-of-tree PrivateUse1 backends (NPU) without patching common_fsdp module globals. Introduce TPFSDPIntegrationTestBase(FSDPTestContinuous) that resolves the device and backend at runtime: _resolved_device_type() resolves the generic "privateuse1" token to the registered backend name, backend_str goes through dist.get_default_backend_for_device (npu->hccl, cuda->nccl, no hardcoding), and world_size is accelerator-aware. This mirrors DTensorPPTestBase in pytorch#192051. Tag the class HardwareClassification.ACCELERATOR, since all three methods run multi-device FSDP+TP collectives on an accelerator. Replace @skip_if_lt_x_gpu(4) with @requires_world_size(4) plus @requires_capabilities(Capability.distributed.backend/dtensor/fsdp), the same gates pytorch#192045 uses for the FSDP+DTensor path. Drop the module-level device_type global and point its six call sites at self._resolved_device_type(); the nested TestModel captures the resolved device via closure. Switch instantiate_parametrized_tests to instantiate_device_type_tests(only_for=["cuda","xpu","privateuse1"], allow_xpu=True) so per-device variants are generated and registered PrivateUse1 backends are auto-discovered. No torch_npu or backend-specific import is introduced; backend capability registration is handled separately via register_privateuse1_capabilities (pytorch#192043). Test Plan: The capability-gated form depends on pytorch#190846 (Capability/ requires_capabilities) and pytorch#191919 (Capability.distributed namespace + generalized requires_world_size), not on main yet, so opened as draft until they land (same as pytorch#192045/pytorch#192046). NPU runtime additionally needs pytorch#192043 (register_privateuse1_capabilities) plus the backend's distributed.* registration in the torch_npu repo. The full capability-gated form was validated end-to-end on 4x Ascend 910B4 (privateuse1=npu) by porting the foundation mechanism onto a local checkout (the foundation PRs do not apply cleanly to the older base). With NPU registering distributed.backend/dtensor/fsdp as supported, instantiate_device_type_tests generates the TestTPFSDPIntegrationPRIVATEUSE1 variant and all three tests pass: python test/distributed/fsdp/test_fsdp_tp_integration.py # Testing class TestTPFSDPIntegrationPRIVATEUSE1 on 4 npu # Ran 3 tests ... OK This exercises the FSDPTestContinuous x PrivateUse1TestBase MRO and the @requires_capabilities / @requires_world_size gates on a multiprocess test, both previously open risks for this test type. Authored with the assistance of an AI assistant (Claude Code).
06cc0ca to
6f6bbbc
Compare
… gating Refactor TestTPFSDPIntegration to the device-agnostic pattern from the testcase-refactoring initiative (pytorch#185590) so it runs on out-of-tree PrivateUse1 backends (NPU) without patching common_fsdp module globals. Introduce TPFSDPIntegrationTestBase(FSDPTestContinuous) that resolves the device and backend at runtime: _resolved_device_type() resolves the generic "privateuse1" token to the registered backend name, backend_str goes through dist.get_default_backend_for_device (npu->hccl, cuda->nccl, no hardcoding), and world_size is accelerator-aware. This mirrors DTensorPPTestBase in pytorch#192051. Tag the class HardwareClassification.ACCELERATOR, since all three methods run multi-device FSDP+TP collectives on an accelerator. Replace @skip_if_lt_x_gpu(4) with @requires_world_size(4) plus @requires_capabilities(Capability.distributed.backend/dtensor/fsdp), the same gates pytorch#192045 uses for the FSDP+DTensor path. Drop the module-level device_type global and point its six call sites at self._resolved_device_type(); the nested TestModel captures the resolved device via closure. Switch instantiate_parametrized_tests to instantiate_device_type_tests(except_for="cpu", allow_xpu=True) so per-device variants are generated and registered PrivateUse1 backends are auto-discovered. No torch_npu or backend-specific import is introduced; backend capability registration is handled separately via register_privateuse1_capabilities (pytorch#192043). Test Plan: The capability-gated form depends on pytorch#190846 (Capability/ requires_capabilities) and pytorch#191919 (Capability.distributed namespace + generalized requires_world_size), not on main yet, so opened as draft until they land (same as pytorch#192045/pytorch#192046). NPU runtime additionally needs pytorch#192043 (register_privateuse1_capabilities) plus the backend's distributed.* registration in the torch_npu repo. The full capability-gated form was validated end-to-end on 4x Ascend 910B4 (privateuse1=npu) by porting the foundation mechanism onto a local checkout (the foundation PRs do not apply cleanly to the older base). With NPU registering distributed.backend/dtensor/fsdp as supported, instantiate_device_type_tests generates the TestTPFSDPIntegrationPRIVATEUSE1 variant and all three tests pass: python test/distributed/fsdp/test_fsdp_tp_integration.py # Testing class TestTPFSDPIntegrationPRIVATEUSE1 on 4 npu # Ran 3 tests ... OK This exercises the FSDPTestContinuous x PrivateUse1TestBase MRO and the @requires_capabilities / @requires_world_size gates on a multiprocess test, both previously open risks for this test type. Authored with the assistance of an AI assistant (Claude Code).
JamesD18
left a comment
There was a problem hiding this comment.
Since the test was not written for XPU, we suggest retaining the current setup without using allow_xpu.
|
Good point — this test hasn't been validated on XPU, so For context, |
… gating Refactor TestTPFSDPIntegration to the device-agnostic pattern from the testcase-refactoring initiative (pytorch#185590) so it runs on out-of-tree PrivateUse1 backends (NPU) without patching common_fsdp module globals. Introduce TPFSDPIntegrationTestBase(FSDPTestContinuous) that resolves the device and backend at runtime: _resolved_device_type() resolves the generic "privateuse1" token to the registered backend name, backend_str goes through dist.get_default_backend_for_device (npu->hccl, cuda->nccl, no hardcoding), and world_size is accelerator-aware. This mirrors DTensorPPTestBase in pytorch#192051. Tag the class HardwareClassification.ACCELERATOR, since all three methods run multi-device FSDP+TP collectives on an accelerator. Replace @skip_if_lt_x_gpu(4) with @requires_world_size(4) plus @requires_capabilities(Capability.distributed.backend/dtensor/fsdp), the same gates pytorch#192045 uses for the FSDP+DTensor path. Drop the module-level device_type global and point its six call sites at self._resolved_device_type(); the nested TestModel captures the resolved device via closure. Switch instantiate_parametrized_tests to instantiate_device_type_tests(except_for="cpu", allow_xpu=True) so per-device variants are generated and registered PrivateUse1 backends are auto-discovered. No torch_npu or backend-specific import is introduced; backend capability registration is handled separately via register_privateuse1_capabilities (pytorch#192043). Test Plan: The capability-gated form depends on pytorch#190846 (Capability/ requires_capabilities) and pytorch#191919 (Capability.distributed namespace + generalized requires_world_size), not on main yet, so opened as draft until they land (same as pytorch#192045/pytorch#192046). NPU runtime additionally needs pytorch#192043 (register_privateuse1_capabilities) plus the backend's distributed.* registration in the torch_npu repo. The full capability-gated form was validated end-to-end on 4x Ascend 910B4 (privateuse1=npu) by porting the foundation mechanism onto a local checkout (the foundation PRs do not apply cleanly to the older base). With NPU registering distributed.backend/dtensor/fsdp as supported, instantiate_device_type_tests generates the TestTPFSDPIntegrationPRIVATEUSE1 variant and all three tests pass: python test/distributed/fsdp/test_fsdp_tp_integration.py # Testing class TestTPFSDPIntegrationPRIVATEUSE1 on 4 npu # Ran 3 tests ... OK This exercises the FSDPTestContinuous x PrivateUse1TestBase MRO and the @requires_capabilities / @requires_world_size gates on a multiprocess test, both previously open risks for this test type. Authored with the assistance of an AI assistant (Claude Code).
JamesD18
left a comment
There was a problem hiding this comment.
LGTM.Thanks for addressing the review comments.
68d063f to
6caf06a
Compare
|
Good point. I removed the module-level This is the only code change in the follow-up. |
JamesD18
left a comment
There was a problem hiding this comment.
LGTM.Thanks for addressing the review comments.
orangeH25
left a comment
There was a problem hiding this comment.
Hi @shichuanliujie9527 , I left a few comments. Please take a look when you have a chance.
|
@orangeH25 @JamesD18 @KarhouTam Both threads are addressed on the latest head (unused |
|
@pytorchbot merge |
|
This PR has pending changes requested. Please address the comments and update the PR before merging. |
|
@pytorchbot merge |
Merge failedReason: Approvers from one of the following sets are needed:
|
0891e4a to
2b5c5f1
Compare
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
acd78fe to
524cd3f
Compare
Summary
Classify the distributed format test as
ACCELERATORand keep the two conversion-only tests in a separateGENERICclass.Changes
TestFormatUtilswithexcept_for="cpu", allow_xpu=True.TestFormatUtilsNoDistwithout device instantiation.Validation
The online conversion test passed on four HCCL ranks. Each worker used its own device and the restored weights matched the original state dictionary. With one device available, the worker setup skipped before spawning any processes. The successful CUDA/NCCL path on a mixed-accelerator host remains untested.
Part of #185590.