Repository navigation
[Testcase Refactoring][FSDP] Pass harness device to optimizer-state API tests - #195961
danieldale2026 wants to merge 3 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195961
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below:
|
cf30802 to
0ffb902
Compare
|
@pytorchbot label "topic: not user facing" |
|
@pytorchbot label "module: tests/distributed" |
| FSDPInitMode.RECURSIVE if wrap else FSDPInitMode.NO_FSDP, | ||
| DEVICEInitMode.DEVICE_BEFORE, | ||
| # Initialize on CPU, then move to the current rank's accelerator. | ||
| DEVICEInitMode.DEVICE_NEVER, |
There was a problem hiding this comment.
DEVICEInitMode.DEVICE_NEVER, refer to:#194204
There was a problem hiding this comment.
I have reviewed the code changes and the accompanying explanations. The changes are reasonable, and I have no further comments.
AI-assisted reply on DEVICEInitMode
Thanks! I re-checked #194204: the parent moved init from the earlier DEVICEInitMode.DEVICE_NEVER usage to DEVICEInitMode.DEVICE_BEFORE, and that correction is what this revision retains — the child does not reintroduce DEVICE_NEVER.
Layering in this revision:
- Parent layer (replay of [Testcase Refactoring][FSDP] Decouple optimizer state tests from accelerator selection #194204, commit b3b3301): keeps
DEVICE_BEFORE, theFSDPTestContinuousimport/base from the reviewed main baseline 67d293e, and bothhalve_world_sizesubgroup cleanups;test_fsdp_optim_state.py+145/-47. - Child layer (this PR's own increment, commit c501b06, own diff b3b3301...c501b06): exactly the four tail API tests —
test_interface_arguments,test_state_dict_with_none_tensor_state,test_with_no_shard,test_no_grad— takingdeviceand derivingdevice_type = torch.device(device).type(+8/-8). All 24 methods, assertions, skips, and@skip_if_lt_x_gpu(2)gates are preserved.
Static/AST checks and scoped lint PASS on this head; multi-accelerator runtime and collection were not performed in local validation (the optimizer-state tests generally need 2 devices), so no runtime pass is claimed. No CI result is claimed in this update; see the PR checks for CI status.
Local replay of pytorch#191919 at 925b73c on pinned main 67d293e. Preserve the accepted flat capability contract: missing declarations fail, unsupported capabilities skip, and out-of-tree providers own their declarations. This local dependency freeze does not update pytorch#191919. Prepared with an AI assistant (Codex); human publication review is pending. Test Plan ```bash /usr/bin/python3 -B agent_space/comment-closure/validate.py dependency-r2 torch/testing/_internal/common_device_type.py test/test_testing.py test/cpp_extensions/open_registration_extension/torch_openreg/tests/test_testing.py git diff --check ``` In-memory compilation and 12 applicable cached lint/file checks passed; three manifest exclusions. Exact accepted patch and strict-missing AST checks passed. Runtime and collection NOT_RUN; scoped static checks only.
Replay the pytorch#194204 consumer topic from 31cee02 on the local pytorch#191919 dependency. Retain current main's FSDPTestContinuous base and both subgroup cleanups. Preserve the parent's DEVICE_BEFORE initialization correction, device plumbing, open accelerator admission and all 24 test methods. This local replay does not update pytorch#194204; the four tail API signatures remain a separate child increment. Prepared with an AI assistant (Codex); human publication review is pending. Test Plan ```bash /usr/bin/python3 -B /home/daniel/workspace/pytorch-dev/worktrees/pytorch/pr193067-comment-closure-20260922/agent_space/comment-closure/validate.py parent test/distributed/fsdp/test_fsdp_optim_state.py /usr/bin/python3 -B /home/daniel/workspace/pytorch-dev/worktrees/pytorch/pr193067-comment-closure-20260922/agent_space/comment-closure/semantics.py B git diff --check ``` In-memory compilation, five cached lint checks and static AST preservation passed. Exact parent content plus the three main drift behaviors verified. Two accepted parent assertions require CPU instead of excluding CUDA/XPU. Runtime and collection NOT_RUN; canonical fixed-commit review pending.
Replay only the accepted pytorch#195961 +8/-8 increment on the local pytorch#194204 parent layer. The four remaining tail API tests receive the injected device and derive its type instead of reading self.device_type. Preserve the parent DEVICE_BEFORE correction, accelerator admission, continuous harness and subgroup cleanup behavior without adding child behavior. Prepared with an AI assistant (Codex); human publication review is pending. Test Plan ```bash /usr/bin/python3 -B /home/daniel/workspace/pytorch-dev/worktrees/pytorch/pr193067-comment-closure-20260922/agent_space/comment-closure/validate.py child-applied test/distributed/fsdp/test_fsdp_optim_state.py /usr/bin/python3 -B /home/daniel/workspace/pytorch-dev/worktrees/pytorch/pr193067-comment-closure-20260922/agent_space/comment-closure/semantics.py B git diff --check ``` In-memory compilation, five cached lint checks, 24-method AST preservation, and exact four-API added/removed lines passed. All AST outside the four signatures and device assignments is identical to the local parent. Runtime and collection NOT_RUN; canonical fixed-commit review pending.
76dbffb to
c501b06
Compare
|
I have reviewed the code changes and the accompanying explanations. The changes are reasonable, and I have no further comments. AI-assisted re-review request@wjlFlyer Could you please take another look at this revision when you have time? Head: c501b06.
|
I have reviewed the code changes and the accompanying explanations. The changes are reasonable, and I have no further comments.
AI-assisted PR body
Issue
Part of #185590. This references the tracking issue only and does not close it.
Summary
Refine #194204 by passing the explicit device-test harness device to the four remaining optimizer-state API tests:
test_interface_arguments,test_state_dict_with_none_tensor_state,test_with_no_shard, andtest_no_grad.Stack layout and scope
This branch has two declared, unmerged ancestry layers:
DEVICEInitMode.DEVICE_BEFOREbehavior, theFSDPTestContinuousimport/base from the reviewed main baseline 67d293e, and bothhalve_world_sizesubgroup cleanups.This PR's own increment relative to the parent is exactly the four tail API signature/device changes in
test/distributed/fsdp/test_fsdp_optim_state.py(+8/-8):Because both ancestry layers are unmerged, the cumulative GitHub diff against
mainshows four files (+500/-139); only the +8/-8 child delta is newly proposed here.Changes
deviceparameter to the four tail API tests and derivedevice_type = torch.device(device).type.@skip_if_lt_x_gpu(2)gates; all 24TestFSDPOptimStatemethods are retained.DEVICE_BEFOREcorrection from [Testcase Refactoring][FSDP] Decouple optimizer state tests from accelerator selection #194204;DEVICE_NEVERis not reintroduced.Motivation
These tests exercise accelerator-generic FSDP optimizer-state behavior. Passing the harness-selected device removes implicit accelerator selection without changing the tested semantics.
Test Plan
Checks actually run on this revision's head (
c501b06):PYFMTontest/test_testing.py;TEST_HAS_MAIN/TEST_DEVICE_BIASontorch/testing/_internal/common_device_type.py). This is scoped lint, not full-repo lint or CI.git diff --check: PASS.Not run, and not claimed:
BC-breaking?
No. This changes test device plumbing only.