Skip to content

[distributed] Reuse workers for FSDP original-parameter tests - #197650

Closed
d4l3k wants to merge 3 commits into
gh/d4l3k/145/basefrom
gh/d4l3k/145/head
Closed

d4l3k wants to merge 3 commits into
gh/d4l3k/145/basefrom
gh/d4l3k/145/head

Conversation

@d4l3k

@d4l3k d4l3k commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Stack from ghstack (oldest at bottom):

Reuse workers within the writeback and unshard/reshard classes instead of starting a process group per case. Scope the mixed-precision environment override to its test so it cannot leak between cases. Keep rank counts and assertions unchanged.

Test plan: CUDA build and lint; all nine affected cases in normal and reverse order, plus postbuild with two visible GPUs. Runtime falls from 51.4s to 13.8s.

@pytorch-bot

pytorch-bot Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/197650

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

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

🟢 GREEN LIGHT - PR approved to be merged without human review:

  • Scope
    • Four hunks in test/distributed/fsdp/test_fsdp_use_orig_params.py only: a patch import, the FSDPTestContinuous import, two base-class swaps, and one decorator.
    • No production code, CI workflow, or docs touched; the other six classes in the file stay on FSDPTest.
  • Base class swap
    • FSDPTestContinuous (common_fsdp.py:1605) supplies the same helpers via FSDPTestMixin plus setUp/tearDown barriers, set_rng_seed(), and torch._dynamo.reset(), matching what FSDPTest._run did.
    • Both converted classes keep their world_size property returning 2, which MultiProcContinuousTest._get_world_size handles explicitly at common_distributed.py:2051.
    • Neither class references FSDPTest-only state (no init_method, file_name, destroy_pg_upon_exit, or run_test uses), and self.process_group resolves via FSDPTestContinuous.process_group at common_fsdp.py:1656.
  • Environment leak fix
    • _test_no_reshard_and_mixed_precision sets _FSDP_USE_FULL_PREC_IN_EVAL (line 1130) and never unsets it, which would persist across tests once workers are reused; @patch.dict(os.environ) at line 1114 restores it.
  • Established pattern
    • TestFSDPMiscMultiProcess (test_fsdp_misc.py:81) already pairs FSDPTestContinuous with a world_size property, @parametrize, and instantiate_parametrized_tests, the same combination used here at lines 634 and 1420.
    • Rank counts, subtest configs, and assertions are unchanged in the diff, so coverage is preserved rather than reduced.

reason: clean
Reviewed commit: 9a2d79e

Inference job

🐛 Report a wrong verdict

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 Sep 19, 2026
This was referenced Sep 19, 2026
@d4l3k
d4l3k marked this pull request as ready for review September 19, 2026 04:20
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #197707

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #197654

pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Avoid process and process-group startup for each submodule-precision case by using the continuous FSDP harness. Keep two ranks and all six cases unchanged; leave other mixed-precision classes isolated.

Test plan: CUDA build and lint; six cases in normal and reverse order and postbuild with two visible GPUs. Runtime drops from 32.1s to 4.4s.
Pull Request resolved: #197651
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197650
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
…197654)

Reuse workers for the distributed checkpoint wrapper cases instead of recreating the process group per test. Preserve the device-count rank cap and object-collective assertions; leave local utility tests unchanged.

Test plan: CUDA build and lint; five distributed cases in normal/reverse order, full file with two visible GPUs (three expected skips), and full-file postbuild. Distributed cases improve from 32.5s to 11.9s.
Pull Request resolved: #197654
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197650, #197651
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse workers across the two original-parameter no_sync tests. Preserve two ranks, all sharding-strategy subtests, gradients and precision assertions.

Test plan: CUDA build and lint pass. Both tests pass normally and in reverse order: 10.621s before versus 5.059s after. Two-GPU run and post-build rerun pass; one-GPU and CPU runs preserve the two expected skips.
Pull Request resolved: #197707
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197650
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
Avoid spawning workers and initializing process groups for each state-dict test. Keep rank counts, model-local state checks and the threaded test class unchanged.

Test plan: CUDA build and lint; six four-GPU cases in normal and reverse order (48.0s to 16.2s), two-GPU coverage with the expected skip, and the full file after rebuilding.
Pull Request resolved: #197660
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197650, #197651, #197654
@github-actions
github-actions Bot deleted the gh/d4l3k/145/head branch November 23, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants