Skip to content

Reuse workers for checkpoint replication staging tests - #197693

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

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

Conversation

@d4l3k

@d4l3k d4l3k commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Stack from ghstack (oldest at bottom):

Reuse workers with the same rank count and combined Gloo/NCCL backend. Apply the existing four-device requirement before worker initialization and destroy the extra Gloo group after its last use.

Test plan: CUDA build and lint; all four cases normally, in reverse order and after build; four expected skips with two or zero GPUs. Baseline 22.65s; reused workers 4.66s before rebuild.

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

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

✅ No Failures

As of commit 3dac392 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
    • Single test file test/distributed/checkpoint/test_state_dict_stager.py; only TestReplicationStager changes, no product or CI/workflow files touched.
    • unittest and the new DTensorContinuousTestBase/NUM_DEVICES names all resolve: unittest at line 6, the other two at common_dtensor.py:700 and :87.
  • Base-class contract
    • world_size = NUM_DEVICES is a plain int, so MultiProcContinuousTest._get_world_size takes the non-property branch at common_distributed.py:2051-2058.
    • backend_str as a classmethod matches the base signature at common_distributed.py:1861, and is_backend_available splits the composite cpu:gloo,cuda:nccl at distributed_c10d.py:2020-2026.
    • with_comms becomes a passthrough because the continuous base defines _init_pg, not init_pg (common_dtensor.py:894), so the worker-owned default PG is reused rather than re-initialized.
  • Skip and cleanup correctness
    • Class-level skipIf(device_count() < 4) runs before setUp, so _ensure_processes_spawned (common_distributed.py:2078) never spawns workers on under-provisioned hosts.
    • dist.destroy_process_group(pg) is newly required since _ReplicationStager.close() is a no-op (staging.py:465-468) and the reused worker would otherwise leak the extra Gloo group.
    • Retained skip_if_lt_x_gpu(4) stays safe under reuse: _worker_loop converts its sys.exit into a SkipTest at common_distributed.py:1978-1992.
  • Testing
    • The four existing cases in this class are the coverage; the diff changes only their harness, not the _ReplicationStager assertions they make.

reason: clean
Reviewed commit: 3dac392

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 #197694

pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse distributed workers for checkpoint consolidation while keeping no-process-group tests in a separate fresh-process class. Preserve all test bodies and the existing rank count.

Test plan: CUDA build and lint; all seven cases normally, in reverse order, on two GPUs and CPU, and after build. Baseline 33.43s; reused workers 15.32s before rebuild. AST comparison verifies every method body unchanged.
Pull Request resolved: #197694
Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
ghstack dependencies: #197647, #197648, #197692, #197693
@github-actions
github-actions Bot deleted the gh/d4l3k/183/head branch November 24, 2026 01:44
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