Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/191419
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit f300a83 with merge base dadc7bd ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "module: tests/distributed" |
|
@pytorchbot rebase |
|
You don't have permissions to rebase this PR since you are a first time contributor. If you think this is a mistake, please contact PyTorch Dev Infra. |
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
46c1d5b to
1c2380d
Compare
1c2380d to
c2b0218
Compare
9eeac21 to
0353829
Compare
|
please resolve the conflict |
c95d5fc to
45d048e
Compare
Conflict resolved |
|
Hi @d4l3k, please help to review this PR, thank you! |
45d048e to
ee55ed1
Compare
…device list
Summary:
- Replace `devices = ("cuda", "hpu", "xpu")` + `only_for=devices` with
`except_for=("cpu",)` in `instantiate_device_type_tests` for
`TestFSDPCheckpointSubmodule`, removing the hard-coded device whitelist.
This allows the FSDP checkpoint submodule test to run on any accelerator
registered via `torch.accelerator` (including PrivateUse1-based
out-of-tree backends) instead of being gated by an enumerated device list.
…devices and label ACCELERATOR classes Summary: - Add `hw_classification = HardwareClassification.ACCELERATOR` to both `TestFSDPCheckpoint` and `TestFSDPCheckpointSubmodule`, and import `HardwareClassification`. - Switch `TestFSDPCheckpoint` from `@instantiate_parametrized_tests` to `instantiate_device_type_tests(..., allow_xpu=True)`, and use the same form for `TestFSDPCheckpointSubmodule` (its hard-coded device list was already removed in the preceding commit). - Gate all three test methods with the variant-aware `@onlyAccelerator` instead of excluding the CPU variant: the CPU variant is now collected and skips cleanly on every host (the guard reads the running variant's `device_type`, so CPU-only machines report explicit skips instead of the classes being invisible), while accelerator variants run unchanged. Same gating form as pytorch#192712 (landed) and pytorch#191905. - Migrate the test methods off the module-level `device_type` string: every method takes the injected `device` parameter, and the bodies create tensors, move modules, and pass the FSDP `device_id` with the per-variant type-only `self.device_type`; `SequentialModule.__init__` receives the device. Delete the module-level `device_type = torch.device(get_devtype())` and the `get_devtype` import. - Replace 4 `TestFSDPCheckpoint.SequentialModule(...)` references in class-1 test bodies with `self.SequentialModule(...)`. `instantiate_device_type_tests` removes the original class name from scope (replaces it with per-device variants like `TestFSDPCheckpointPRIVATEUSE1`), so a test body referencing the original class name raises `NameError` at runtime. The variants inherit from the original class, so `self.SequentialModule` resolves the nested class correctly. This was latent until the c10d backend-type lookup for PrivateUse1 was fixed (pytorch#187650 / out-of-tree accelerator issue pytorch#3947), because workers previously exited at `dist.barrier(device_ids=)` before reaching this code. This aligns both classes' mechanism with their ACCELERATOR classification and removes the hard-coded device whitelist so any accelerator registered via `torch.accelerator` is admitted. The device-parameter migration ensures each per-device variant uses its own device rather than a module-level constant, which is the correct pattern under `instantiate_device_type_tests`. Rebase note: upstream has since moved both classes onto the FSDPTestContinuous base; this is kept, and the type-only device idiom in test bodies is normalized to self.device_type (equivalent to the previous torch.device(device).type, and unambiguous under type-only injection). Verified end to end on an 8-card accelerator backend (the verification host runs an older torch snapshot; its common_distributed.py carries the previously-applied verification patches - the skip_if_lt_x_gpu device-agnostic rewrite and the device-backend registry resolution - plus the worker-side method-level SkipTest pass-through that current main already has): python test/distributed/fsdp/test_fsdp_checkpoint.py -v -> 34 cases collected: 17 accelerator-variant cases pass across both classes, and 17 CPU-variant cases (the two generated CPU classes) are collected and skipped with the exact reason "onlyAccelerator: doesn't run on CPU or meta devices"; 0 errors.
…TER allowlist Summary: - This PR migrates test/distributed/fsdp/test_fsdp_checkpoint.py to the TEST_LINTER's requirements (hw_classification on every test class plus the per-classification structure rules), and the file currently sits in test_linter_allowlist.json. Drop its one-line entry in the same PR: the allowlist is a regenerated snapshot of non-compliant files, and a migration landing without the deletion leaves a silently-stale exemption (canonical: pytorch#191905 needed the follow-up pytorch#202866). This lets the linter enforce its requirements on future changes to this file as part of the same change, instead of a separate cleanup PR later.
1c88687 to
f300a83
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 |
|
@pytorchbot merge |
|
The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command |
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 |
…devices and label ACCELERATOR classes (pytorch#191419) ## Summary This PR labels `TestFSDPCheckpoint` and `TestFSDPCheckpointSubmodule` as `HardwareClassification.ACCELERATOR`, switches both to `instantiate_device_type_tests(..., allow_xpu=True)` with the variant-aware `@onlyAccelerator` gate on every test method, and completes the device-parameter migration in the test bodies. Rebased onto upstream's migration of both classes onto the `FSDPTestContinuous` base (kept); type-only device access in test bodies uses `self.device_type` (canonical idiom, unambiguous under `DeviceTypeTestBase` injection). ## Changes - **`test/distributed/fsdp/test_fsdp_checkpoint.py`**: - Added `hw_classification = HardwareClassification.ACCELERATOR` to both classes, plus the import. Both classes' `test_*` methods require an accelerator (`@skip_if_lt_x_gpu(2)`, `device` param) and exercise FSDP checkpoint behavior on the device-tensor path. - Switched `TestFSDPCheckpoint` from `@instantiate_parametrized_tests` to `instantiate_device_type_tests(..., allow_xpu=True)` (deleting the class decorator avoids the double-expansion trap); `TestFSDPCheckpointSubmodule`'s hard-coded `only_for=("cuda","hpu","xpu")` device list was removed in the preceding commit and it now uses the same form. ACCELERATOR classes must not use `only_for` (landed test linter pytorch#190173). - All three test methods carry the variant-aware `@onlyAccelerator` (stacked above `@skip_if_lt_x_gpu(2)`): the CPU variant is generated and collected everywhere but skips cleanly with the exact reason `onlyAccelerator: doesn't run on CPU or meta devices` (the guard reads the running variant's `device_type`, unlike availability-based guards), so CPU-only machines report explicit skips instead of the classes being invisible, while accelerator variants run unchanged. Same gating form as pytorch#192712 (landed) and pytorch#191905. - Migrated every test method to the injected `device` parameter: added `device` to both class-1 methods and to `SequentialModule.__init__`, deleted the module-level `device_type` constant and the `get_devtype` import. - Replaced 4 `TestFSDPCheckpoint.SequentialModule(...)` references with `self.SequentialModule(...)` — `instantiate_device_type_tests` removes the original class name from scope, so module-level references raise `NameError` at runtime (latent until pytorch#187650 fixed the backend-type lookup for PrivateUse1 / out-of-tree accelerator issue pytorch#3947, because workers previously exited at `dist.barrier(device_ids=)` first). - Device access in test bodies uses `self.device_type` (type-only) for FSDP `device_id` (`fsdp_kwargs`), `.to(...)`, `torch.randn(device=...)`, and `SequentialModule(device=...)`; `SequentialModule.__init__` receives the type-only device from its callers and uses it directly. Type-only `device_id` keeps `_get_device_from_device_id` resolving each rank to its own current device (no single-card degeneration). - **`tools/linter/adapters/test_linter_allowlist.json`**: removed the single `test/distributed/fsdp/test_fsdp_checkpoint.py` entry — this PR migrates that file to the linter's requirements. ## Motivation Both classes had no `hw_classification` (silently dropped under `--hw-classification ACCELERATOR` filtering) and used `only_for=("cuda","hpu","xpu")`, excluding PrivateUse1-based out-of-tree accelerators. The module-level `device_type` constant does not change across per-device variants, and an indexed `device` passed bare to FSDP `device_id` silently degenerates multi-rank tests to single-card. ## Test Plan - FSDP infra routes to the real accelerator backend (not a gloo/CPU false pass): `python -c "from torch.testing._internal.common_fsdp import DEVICE_TYPE, DISTRIBUTED_BACKEND, DEVICE_COUNT; print(...)"` resolves to the verify backend's accelerator type, its native comm backend, and 8 on the verify host. - End-to-end on an 8-card accelerator backend (the verify host runs an older torch snapshot; its `common_distributed.py` carries the previously documented verification patches plus the worker-side method-level SkipTest pass-through that current main already has): ``` python test/distributed/fsdp/test_fsdp_checkpoint.py -v # 34 cases collected: 17 accelerator-variant cases pass across both classes; # 17 CPU-variant cases (the two generated CPU classes) are collected and # skipped with the exact onlyAccelerator reason; 0 errors. ``` - The earlier revision of this PR (CPU variant excluded at instantiation) verified as `Ran 17 tests, OK (0 errors)`; accelerator-variant behavior is unchanged between the two forms. - `lintrunner` clean; landed test linter: 0 violations. - With the entry removed, the TEST_LINTER full re-check passes for the migrated file: `python3 tools/linter/adapters/test_linter.py tools/linter/adapters/test_linter_allowlist.json` (the allowlist-as-argument form lintrunner triggers in CI) — rc=0, zero lint messages for `test/distributed/fsdp/test_fsdp_checkpoint.py`. ## Notes - The method-level `@onlyAccelerator` form (rather than `except_for=("cpu",)`) keeps the CPU variant in collection so CPU-only hosts report explicit skips instead of the classes silently disappearing. This PR's base already translates a worker-side `unittest.SkipTest` into a skip result, and the trade-off — one extra class-level worker/PG lifecycle per generated CPU class on accelerator hosts, with no change in accelerator-variant execution — was accepted for collection visibility. Same form as pytorch#192712 (landed) and pytorch#191905. - This is part of the test case refactoring initiative tracked in pytorch#185590. Pull Request resolved: pytorch#191419 Approved by: https://github.com/jialinw77, https://github.com/can-gaa-hou, https://github.com/d4l3k
…devices and label ACCELERATOR classes (pytorch#191419) ## Summary This PR labels `TestFSDPCheckpoint` and `TestFSDPCheckpointSubmodule` as `HardwareClassification.ACCELERATOR`, switches both to `instantiate_device_type_tests(..., allow_xpu=True)` with the variant-aware `@onlyAccelerator` gate on every test method, and completes the device-parameter migration in the test bodies. Rebased onto upstream's migration of both classes onto the `FSDPTestContinuous` base (kept); type-only device access in test bodies uses `self.device_type` (canonical idiom, unambiguous under `DeviceTypeTestBase` injection). ## Changes - **`test/distributed/fsdp/test_fsdp_checkpoint.py`**: - Added `hw_classification = HardwareClassification.ACCELERATOR` to both classes, plus the import. Both classes' `test_*` methods require an accelerator (`@skip_if_lt_x_gpu(2)`, `device` param) and exercise FSDP checkpoint behavior on the device-tensor path. - Switched `TestFSDPCheckpoint` from `@instantiate_parametrized_tests` to `instantiate_device_type_tests(..., allow_xpu=True)` (deleting the class decorator avoids the double-expansion trap); `TestFSDPCheckpointSubmodule`'s hard-coded `only_for=("cuda","hpu","xpu")` device list was removed in the preceding commit and it now uses the same form. ACCELERATOR classes must not use `only_for` (landed test linter pytorch#190173). - All three test methods carry the variant-aware `@onlyAccelerator` (stacked above `@skip_if_lt_x_gpu(2)`): the CPU variant is generated and collected everywhere but skips cleanly with the exact reason `onlyAccelerator: doesn't run on CPU or meta devices` (the guard reads the running variant's `device_type`, unlike availability-based guards), so CPU-only machines report explicit skips instead of the classes being invisible, while accelerator variants run unchanged. Same gating form as pytorch#192712 (landed) and pytorch#191905. - Migrated every test method to the injected `device` parameter: added `device` to both class-1 methods and to `SequentialModule.__init__`, deleted the module-level `device_type` constant and the `get_devtype` import. - Replaced 4 `TestFSDPCheckpoint.SequentialModule(...)` references with `self.SequentialModule(...)` — `instantiate_device_type_tests` removes the original class name from scope, so module-level references raise `NameError` at runtime (latent until pytorch#187650 fixed the backend-type lookup for PrivateUse1 / out-of-tree accelerator issue pytorch#3947, because workers previously exited at `dist.barrier(device_ids=)` first). - Device access in test bodies uses `self.device_type` (type-only) for FSDP `device_id` (`fsdp_kwargs`), `.to(...)`, `torch.randn(device=...)`, and `SequentialModule(device=...)`; `SequentialModule.__init__` receives the type-only device from its callers and uses it directly. Type-only `device_id` keeps `_get_device_from_device_id` resolving each rank to its own current device (no single-card degeneration). - **`tools/linter/adapters/test_linter_allowlist.json`**: removed the single `test/distributed/fsdp/test_fsdp_checkpoint.py` entry — this PR migrates that file to the linter's requirements. ## Motivation Both classes had no `hw_classification` (silently dropped under `--hw-classification ACCELERATOR` filtering) and used `only_for=("cuda","hpu","xpu")`, excluding PrivateUse1-based out-of-tree accelerators. The module-level `device_type` constant does not change across per-device variants, and an indexed `device` passed bare to FSDP `device_id` silently degenerates multi-rank tests to single-card. ## Test Plan - FSDP infra routes to the real accelerator backend (not a gloo/CPU false pass): `python -c "from torch.testing._internal.common_fsdp import DEVICE_TYPE, DISTRIBUTED_BACKEND, DEVICE_COUNT; print(...)"` resolves to the verify backend's accelerator type, its native comm backend, and 8 on the verify host. - End-to-end on an 8-card accelerator backend (the verify host runs an older torch snapshot; its `common_distributed.py` carries the previously documented verification patches plus the worker-side method-level SkipTest pass-through that current main already has): ``` python test/distributed/fsdp/test_fsdp_checkpoint.py -v # 34 cases collected: 17 accelerator-variant cases pass across both classes; # 17 CPU-variant cases (the two generated CPU classes) are collected and # skipped with the exact onlyAccelerator reason; 0 errors. ``` - The earlier revision of this PR (CPU variant excluded at instantiation) verified as `Ran 17 tests, OK (0 errors)`; accelerator-variant behavior is unchanged between the two forms. - `lintrunner` clean; landed test linter: 0 violations. - With the entry removed, the TEST_LINTER full re-check passes for the migrated file: `python3 tools/linter/adapters/test_linter.py tools/linter/adapters/test_linter_allowlist.json` (the allowlist-as-argument form lintrunner triggers in CI) — rc=0, zero lint messages for `test/distributed/fsdp/test_fsdp_checkpoint.py`. ## Notes - The method-level `@onlyAccelerator` form (rather than `except_for=("cpu",)`) keeps the CPU variant in collection so CPU-only hosts report explicit skips instead of the classes silently disappearing. This PR's base already translates a worker-side `unittest.SkipTest` into a skip result, and the trade-off — one extra class-level worker/PG lifecycle per generated CPU class on accelerator hosts, with no change in accelerator-variant execution — was accepted for collection visibility. Same form as pytorch#192712 (landed) and pytorch#191905. - This is part of the test case refactoring initiative tracked in pytorch#185590. Pull Request resolved: pytorch#191419 Approved by: https://github.com/jialinw77, https://github.com/can-gaa-hou, https://github.com/d4l3k
Summary
This PR labels
TestFSDPCheckpointandTestFSDPCheckpointSubmoduleasHardwareClassification.ACCELERATOR, switches both toinstantiate_device_type_tests(..., allow_xpu=True)with the variant-aware@onlyAcceleratorgate on every test method, and completes the device-parameter migration in the test bodies. Rebased onto upstream's migration of both classes onto theFSDPTestContinuousbase (kept); type-only device access in test bodies usesself.device_type(canonical idiom, unambiguous underDeviceTypeTestBaseinjection).Changes
test/distributed/fsdp/test_fsdp_checkpoint.py:hw_classification = HardwareClassification.ACCELERATORto both classes, plus the import. Both classes'test_*methods require an accelerator (@skip_if_lt_x_gpu(2),deviceparam) and exercise FSDP checkpoint behavior on the device-tensor path.TestFSDPCheckpointfrom@instantiate_parametrized_teststoinstantiate_device_type_tests(..., allow_xpu=True)(deleting the class decorator avoids the double-expansion trap);TestFSDPCheckpointSubmodule's hard-codedonly_for=("cuda","hpu","xpu")device list was removed in the preceding commit and it now uses the same form. ACCELERATOR classes must not useonly_for(landed test linter [Lint] Add TEST_LINTER linter for testcase linter checks #190173).@onlyAccelerator(stacked above@skip_if_lt_x_gpu(2)): the CPU variant is generated and collected everywhere but skips cleanly with the exact reasononlyAccelerator: doesn't run on CPU or meta devices(the guard reads the running variant'sdevice_type, unlike availability-based guards), so CPU-only machines report explicit skips instead of the classes being invisible, while accelerator variants run unchanged. Same gating form as [Testcase Refactoring] Label test_fsdp_freezing_weights ACCELERATOR and switch to device-type instantiation #192712 (landed) and [Testcase Refactoring] Add hw_classification and split device-dependent test in test_multi_threaded_pg #191905.deviceparameter: addeddeviceto both class-1 methods and toSequentialModule.__init__, deleted the module-leveldevice_typeconstant and theget_devtypeimport.TestFSDPCheckpoint.SequentialModule(...)references withself.SequentialModule(...)—instantiate_device_type_testsremoves the original class name from scope, so module-level references raiseNameErrorat runtime (latent until [Testcase Refactoring] Make FSDP tests device-agnostic for out-of-tree backends #187650 fixed the backend-type lookup for PrivateUse1 / out-of-tree accelerator issue CrossEntropyLoss input dimension ERROR #3947, because workers previously exited atdist.barrier(device_ids=)first).self.device_type(type-only) for FSDPdevice_id(fsdp_kwargs),.to(...),torch.randn(device=...), andSequentialModule(device=...);SequentialModule.__init__receives the type-only device from its callers and uses it directly. Type-onlydevice_idkeeps_get_device_from_device_idresolving each rank to its own current device (no single-card degeneration).tools/linter/adapters/test_linter_allowlist.json: removed the singletest/distributed/fsdp/test_fsdp_checkpoint.pyentry — this PR migrates that file to the linter's requirements.Motivation
Both classes had no
hw_classification(silently dropped under--hw-classification ACCELERATORfiltering) and usedonly_for=("cuda","hpu","xpu"), excluding PrivateUse1-based out-of-tree accelerators. The module-leveldevice_typeconstant does not change across per-device variants, and an indexeddevicepassed bare to FSDPdevice_idsilently degenerates multi-rank tests to single-card.Test Plan
python -c "from torch.testing._internal.common_fsdp import DEVICE_TYPE, DISTRIBUTED_BACKEND, DEVICE_COUNT; print(...)"resolves to the verify backend's accelerator type, its native comm backend, and 8 on the verify host.common_distributed.pycarries the previously documented verification patches plus the worker-side method-level SkipTest pass-through that current main already has):Ran 17 tests, OK (0 errors); accelerator-variant behavior is unchanged between the two forms.lintrunnerclean; landed test linter: 0 violations.python3 tools/linter/adapters/test_linter.py tools/linter/adapters/test_linter_allowlist.json(the allowlist-as-argument form lintrunner triggers in CI) — rc=0, zero lint messages fortest/distributed/fsdp/test_fsdp_checkpoint.py.Notes
@onlyAcceleratorform (rather thanexcept_for=("cpu",)) keeps the CPU variant in collection so CPU-only hosts report explicit skips instead of the classes silently disappearing. This PR's base already translates a worker-sideunittest.SkipTestinto a skip result, and the trade-off — one extra class-level worker/PG lifecycle per generated CPU class on accelerator hosts, with no change in accelerator-variant execution — was accepted for collection visibility. Same form as [Testcase Refactoring] Label test_fsdp_freezing_weights ACCELERATOR and switch to device-type instantiation #192712 (landed) and [Testcase Refactoring] Add hw_classification and split device-dependent test in test_multi_threaded_pg #191905.