Skip to content

Reuse workers for FSDP model checkpoint tests - #197688

Closed
d4l3k wants to merge 1 commit into
gh/d4l3k/179/basefrom
gh/d4l3k/179/head
Closed

d4l3k wants to merge 1 commit into
gh/d4l3k/179/basefrom
gh/d4l3k/179/head

Conversation

@d4l3k

@d4l3k d4l3k commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Stack from ghstack (oldest at bottom):

Reuse distributed workers across model-state checkpoint tests, preserving the rank count and combined Gloo/accelerator backend. Release each rank’s resharding subgroup after its last use.

Test plan: CUDA build and lint; both four-GPU cases in normal and reversed order, two-GPU and CPU skip paths, and both cases after build. Runtime falls from 11.74s to 6.57s.

@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/197688

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

✅ No Failures

As of commit 46bfc05 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
    • Test-only change to test/distributed/checkpoint/test_fsdp_model_state.py; no production code is touched and the diff is confined to one file
    • _test_fsdp_model_state body, its assertions, and the skip_if_lt_x_gpu(2)/skip_if_lt_x_gpu(4) guards are all unchanged, so coverage is preserved
  • Harness migration
    • DTensorContinuousTestBase is an established base for this pattern, already used by test_state_dict_utils.py and test_fsdp_dtensor_state_dict.py with with_comms
    • world_size = NUM_DEVICES matches the old DTensorTestBase.world_size property at common_dtensor.py:791, so rank count is preserved
    • with_comms is a passthrough here since neither DTensorTestMixin nor MultiProcContinuousTest defines init_pg, so the worker-loop bootstrap PG is used instead of a per-test one
  • Backend override
    • The backend_str classmethod reproduces the old compound cpu:gloo,{device}:{curr_backend} string, which is_backend_available handles via its composite branch at distributed_c10d.py:2020
    • The new cpu branch returning "gloo" is reachable because _ensure_processes_spawned validates the backend before the per-test GPU skips run
  • Subgroup cleanup
    • dist.destroy_process_group(process_group) releases only that rank's own group; non-member ranks get NON_GROUP_MEMBER from new_group and hit the early return at distributed_c10d.py:3137
    • Cleanup matters now that workers are shared across tests, and the default PG stays alive for with_temp_dir's trailing dist.barrier()

reason: clean
Reviewed commit: 46bfc05

Inference job

🐛 Report a wrong verdict

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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #197690

pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse distributed workers across the four uneven-stride allocation tests while preserving the existing rank count and assertions.

Test plan: CUDA build and lint; four cases in normal and reversed order, CPU fallback and two-GPU runs. Four-GPU runtime drops from 22.39s to 5.53s after build.
Pull Request resolved: #197690
Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
ghstack dependencies: #197647, #197648, #197687, #197688
@github-actions
github-actions Bot deleted the gh/d4l3k/179/head branch November 23, 2026 01:50
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.

3 participants