Repository navigation
[xpu][test] Port distributed _shard tests cases on Intel GPUs - #195952
madhumitha0102 wants to merge 30 commits into
Conversation
…ed/optim , test/distributed/flight_recorder and test/distributed/checkpoint to XPU
This reverts commit d89e05b.
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:
Findings (3): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195952
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (5 Unrelated Failures)As of commit b0a833e with merge base 2bc3d41 ( FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@newtdms could you please help review this test port / refactor PR? Thanks! |
etaf
left a comment
There was a problem hiding this comment.
Please fix the CI failure first.
There was a problem hiding this comment.
Automated review of dbcf39b: changes requested before human review.
Test-only PR that makes distributed checkpoint, flight recorder and pipelining tests device-agnostic for XPU. The pipelining DeterministicGuard changes and the stager backend change look sound. However, TestNoCPU now fails instead of skipping on hosts that have the CUDA/XPU dist backend compiled in but fewer accelerators than world_size, because the new decorator only checks that the backend is available, not how many devices there are.
🔴 1 blocking finding is attached to the code below.
⚪ 2 non-blocking findings
This module-level get_default_backend_for_device() call makes a pure-data test depend on the host machine. It raises at import (ValueError) on accelerators with no registered default backend (MTIA, privateuse1, HPU without the plugin), and with AttributeError on USE_DISTRIBUTED=0 builds, so every test in the file fails to collect. It adds no coverage, since FlightRecorderOpBackendTest already covers per-backend parsing. Keep a fixed backend constant instead.
Only the share_memory=True + pin_memory=True case uses the cudart pin path (torch.cuda._pin_memory_utils), but this skip drops the whole test on XPU, including the default, pin-only and share-only cases. Guard just that sub-case. If the whole test stays excluded, use expectedFailure rather than skipIf, since the failure is deterministic.
Please address the findings and push; a new commit normally gets a fresh automated review.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
| return dist.get_default_backend_for_device(self.device_type) | ||
|
|
||
| @with_comms | ||
| @requires_accelerator_dist_backend() |
There was a problem hiding this comment.
🔴 Regression: before, backend was hardcoded to 'nccl', so init_pg skipped the test (multi-device-N) when there were too few GPUs. Now backend comes from self.device_type, which _get_device_type sets to 'cpu' when DEVICE_COUNT < world_size, so backend becomes gloo. @ requires_accelerator_dist_backend() only checks that NCCL/XCCL is compiled in. On a CUDA build with 0 or 1 GPUs, the test therefore runs on gloo, async_save does not raise, and assertRaisesRegex fails. Fix: skip on device count (e.g. @ skip_if_lt_x_gpu(NUM_DEVICES)) or skip when self.device_type == 'cpu'. The backend override is n
There was a problem hiding this comment.
Automated review of a152458: nothing blocking; ready for human review.
This PR makes the distributed checkpoint, pipelining and flight-recorder tests device-generic so they run on XPU. Every inline request from maintainer etaf is now reflected in the code: DeterministicGuard replaces the looser tolerances, the unrelated files were dropped, and hw_classification and the continuous base class are back. What remains is minor robustness: a cpu branch that never runs, an import-time backend lookup, and a cpu:N device string.
⚪ 3 non-blocking findings
etaf said this cpu branch isn't needed. The author replied that without it the string becomes a duplicate cpu:gloo, but the class is skipped when there are fewer than 4 accelerators (line 955), so device_type=='cpu' never reaches here. Drop the branch or link the CI failure it fixes.
get_default_backend_for_device runs at import time. On builds without distributed it raises AttributeError, and on accelerators with no registered default (hpu, privateuse1) it raises ValueError. Either way the whole module fails to import, including tests that don't need the backend; fall back to a literal backend name.
On CPU-only machines rank 1 builds the device 'cpu:1', which trips a debug-only assertion in c10::Device. The .to(device) call also does nothing, because MyShardedModel3 has no params or buffers, so it can simply be removed.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
Withdrawn: the automated review of a152458 found nothing blocking.
|
@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 |
…h#195952) For pytorch#114850, we will port distributed tests to Intel GPU. We will enable Intel GPU with following methods and keep the original code styles: Example: "torch.accelerator.current_accelerator()" to determine the accelerator backend enabled XPU for the following files: 1. test/distributed/checkpoint/_experimental/test_staging.py 2. test/distributed/checkpoint/e2e/test_e2e_save_and_load.py 3. test/distributed/checkpoint/test_file_system_checkpoint_cpu.py 4. test/distributed/checkpoint/test_state_dict_stager.py 5. test/distributed/checkpoint/test_state_dict_utils.py 6. test/distributed/flight_recorder/test_fr_analysis.py 7. test/distributed/optim/test_zero_redundancy_optimizer.py 8. test/distributed/pipelining/test_backward.py 9. test/distributed/pipelining/test_microbatch.py 10. test/distributed/pipelining/test_schedule_multiproc.py Pull Request resolved: pytorch#195952 Approved by: https://github.com/newtdms, https://github.com/etaf, https://github.com/jansel
Rebased onto latest main, resolving conflicts with pytorch#197704 and pytorch#195952: TestCheckpointOrderingAndOverwrite (upstream) now owns test_different_ordered_state_dict_keys and test_overwrite, so this PR no longer moves test_overwrite into TestInitStateDict, and test_different_ordered_state_dict_keys keeps only the device_type = self.device_type fix on top of upstream's copy. Review fixes for can-gaa-hou's latest comments: TestNoCPU is now classified ACCELERATOR instead of GENERIC. With pytorch#195952 landed, its backend resolves via get_default_backend_for_device and the test is gated by skip_if_lt_x_gpu(NUM_DEVICES), so it is accelerator-generic rather than CUDA-specific; GENERIC contradicted both the skip gating and the taxonomy. except_for=("cpu",) is removed from instantiate_device_type_tests. It was requested by fffrog earlier but reintroduced by a later commit. Every test method in TestE2ESaveAndLoad is gated by skip_if_lt_x_gpu(4), so CPU variants skip cleanly without it. TestCheckpointOrderingAndOverwrite is annotated ACCELERATOR for consistency with the rest of this file. Assisted-by: Claude (Anthropic) Test Plan: - python3 -m py_compile test/distributed/checkpoint/e2e/test_e2e_save_and_load.py - ruff check --config pyproject.toml test/distributed/checkpoint/e2e/test_e2e_save_and_load.py - CI on the PR (4-GPU distributed suites).
For #114850, we will port distributed tests to Intel GPU.
We will enable Intel GPU with following methods and keep the original code styles:
Example: "torch.accelerator.current_accelerator()" to determine the accelerator backend
enabled XPU for the following files:
cc @gujinghui @EikanWang @fengyuan14 @guangyey