Skip to content

[Testcase Refactoring] Decouple test_fsdp_checkpoint from hard-coded devices and label ACCELERATOR classes - #191419

Closed
twthighd wants to merge 3 commits into
pytorch:mainfrom
twthighd:test/decouple-test_fsdp_checkpoint
Closed

twthighd wants to merge 3 commits into
pytorch:mainfrom
twthighd:test/decouple-test_fsdp_checkpoint

Conversation

@twthighd

@twthighd twthighd commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

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 [Lint] Add TEST_LINTER linter for testcase linter checks #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 [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.
    • 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 [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 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

@pytorch-bot

pytorch-bot Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

🔗 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 Failures

As of commit f300a83 with merge base dadc7bd (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jul 29, 2026
@twthighd

Copy link
Copy Markdown
Contributor Author

@twthighd

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "module: tests/distributed"

@pytorch-bot pytorch-bot Bot added the module: tests/distributed This label covers all test cases within the Distributed sheet. label Jul 29, 2026
@twthighd twthighd changed the title [Testcase Refactoring] Decouple test_fsdp_checkpoint from hard-coded … [Testcase Refactoring] Decouple test_fsdp_checkpoint from hard-coded CUDA/HPU/XPU devices Jul 29, 2026
@drisspg drisspg added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 29, 2026
@drisspg
drisspg requested a review from fffrog July 29, 2026 04:40
@fffrog fffrog moved this to Backlog in PyTorch Test Refactoring Jul 29, 2026
@twthighd
twthighd marked this pull request as draft August 7, 2026 01:26
@twthighd twthighd changed the title [Testcase Refactoring] Decouple test_fsdp_checkpoint from hard-coded CUDA/HPU/XPU devices [Testcase Refactoring] Decouple test_fsdp_checkpoint from hard-coded devices and label ACCELERATOR classes Aug 12, 2026
@twthighd

Copy link
Copy Markdown
Contributor Author

@pytorchbot rebase

@pytorch-bot

pytorch-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

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.

@KarhouTam

Copy link
Copy Markdown
Collaborator

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased test/decouple-test_fsdp_checkpoint onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout test/decouple-test_fsdp_checkpoint && git pull --rebase)

kerer-ai pushed a commit to kerer-ai/pytorch-nv that referenced this pull request Aug 26, 2026
kerer-ai pushed a commit to kerer-ai/pytorch-nv that referenced this pull request Aug 26, 2026
kerer-ai pushed a commit to kerer-ai/pytorch-nv that referenced this pull request Sep 7, 2026
@can-gaa-hou

Copy link
Copy Markdown
Collaborator

please resolve the conflict

@twthighd
twthighd force-pushed the test/decouple-test_fsdp_checkpoint branch 2 times, most recently from c95d5fc to 45d048e Compare October 20, 2026 08:10
@twthighd

Copy link
Copy Markdown
Contributor Author

please resolve the conflict

Conflict resolved

@can-gaa-hou can-gaa-hou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@twthighd

Copy link
Copy Markdown
Contributor Author

Hi @d4l3k, please help to review this PR, thank you!

@twthighd
twthighd force-pushed the test/decouple-test_fsdp_checkpoint branch from 45d048e to ee55ed1 Compare October 30, 2026 07:45
@twthighd

Copy link
Copy Markdown
Contributor Author

@d4l3k gentle re-ping — the head has been updated (ee55ed1). The gating is now the same shape you approved in #191905: CPU variants are collected and skip via the @onlyAccelerator

@d4l3k d4l3k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

…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.
@twthighd
twthighd force-pushed the test/decouple-test_fsdp_checkpoint branch from 1c88687 to f300a83 Compare November 4, 2026 01:23
@twthighd

twthighd commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 4, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@KarhouTam

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

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
For more information see pytorch-bot wiki.

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@github-project-automation github-project-automation Bot moved this from Backlog to Done in PyTorch Test Refactoring Nov 4, 2026
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: tests/distributed This label covers all test cases within the Distributed sheet. open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants