Skip to content

[distributed] Reuse workers for checkpoint state-dict utility tests - #197647

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

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

Conversation

@d4l3k

@d4l3k d4l3k commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Stack from ghstack (oldest at bottom):

Use DTensorContinuousTestBase for seven state-dict utility cases with test-local tensors and buffers. Preserve the original rank-count expression as a class attribute so the continuous harness can resolve its device type before spawning workers. Keep the existing assertions and communication decorators.

Test plan: CUDA build and lint pass. Seven four-GPU cases pass in 6.117s versus 37.399s before; reversed order passes in 6.045s. Two-GPU run passes with three expected four-GPU skips. Post-build full-file rerun passes.

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

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

⏳ No Failures, 2 Pending

As of commit 05f6500 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
    • Sole change is test/distributed/checkpoint/test_state_dict_utils.py swapping TestStateDictUtils from DTensorTestBase to DTensorContinuousTestBase; no product code touched.
    • No workflow files in the diff, so the pull.yml/trunk.yml new-job rule does not apply.
  • Harness correctness
    • The world_size property becomes a class attribute because _ensure_processes_spawned resolves device_type via fget(cls) at class level (common_distributed.py:2096-2100), which needs world_size to be an int, not a property.
    • _get_world_size (common_distributed.py:2051-2058) accepts a plain class attribute, and the preserved min(4, torch.accelerator.device_count()) yields the same value the old property returned.
  • Preserved behavior
    • with_comms hits its hasattr(self, "init_pg") passthrough (common_dtensor.py:892-894) since neither MultiProcContinuousTest nor DTensorTestMixin defines init_pg, so the decorator stays inert rather than double-initializing.
    • skip_if_lt_x_gpu's sys.exit(exit_code) (common_distributed.py:317-319) is caught by _worker_loop's SystemExit branch (common_distributed.py:1978-1992) and converted to unittest.SkipTest, so the 4-GPU cases still skip on 2-GPU hosts.
    • Worker-side self.rank/self.world_size are reassigned per test in _run_test_given_id (common_distributed.py:1912-1913), so bodies like scale_factor = self.world_size read the real rank count.
  • Precedent
    • Same class X(DTensorContinuousTestBase) plus class-level world_size pattern is already in test/distributed/tensor/test_redistribute.py:72-73, test_tensor_ops.py:40-41, and test/distributed/fsdp/test_fsdp_dtensor_state_dict.py:63.
    • Each test in the file builds its own tensors and buffers locally (test_state_dict_utils.py:37-299), so no class state carries across the now-reused workers.

reason: clean
Reviewed commit: 05f6500

Inference job

🐛 Report a wrong verdict

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

This was referenced Sep 19, 2026
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse test workers across strict-export tensor-parallel transformations. Preserve the original rank cap and all numerical and graph-operation assertions; remove redundant parent setup.

Test plan: CUDA build and lint; all three tests in normal and reverse order, CPU-only and two-GPU runs. Four-GPU runtime drops from 21.251s to 7.820s (reverse 7.612s).
Pull Request resolved: #197703
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Move ordering and overwrite checks unchanged into a continuous-worker class. Keep compiler, asynchronous checkpoint and uninitialized-distributed tests on the existing harness. Preserve rank limits and the combined CPU/accelerator backend.

Test plan: CUDA build and lint; ordering/overwrite tests in normal and reverse order, expected CPU/two-GPU skips, plus original no-distributed, stateful loading, backend rejection and initialization regressions. Two-test runtime drops from 11.433s to 5.631s.
Pull Request resolved: #197704
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197703
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse workers for FLEX and SDPA input-argument tests, preserving two ranks and all mock, layout, and value assertions. Keep attention execution and sharding-registration tests on their existing fixtures.

Test plan: CUDA build and lint; eight tests in normal/reverse order and CPU/single-visible-GPU fallback. Runtime drops from 38.086s to 9.019s; reverse 8.716s.
Pull Request resolved: #197705
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197703, #197704
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
LocalMap correctness tests repeatedly spawn identical two-rank workers. Reuse the continuous DTensor fixture while preserving rank count and leaving SPMD/fake-process-group tests unchanged.

Test plan:
CUDA build and lint pass. Six LocalMap tests: 27.365s before, 5.274s after; reversed order 4.997s. CPU fallback and two-GPU postbuild runs pass with one existing four-GPU-gated skip each.
Pull Request resolved: #197675
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse the continuous FSDP fixture for two replicate gradient accumulation tests. Preserve world size, test bodies, and all other classes.

Test plan: CUDA build and lint pass; two four-GPU tests improve from 12.912s to 6.645s, reverse order 6.647s, two GPUs 5.373s, postbuild 6.384s. Zero-GPU run preserves two skips.
Pull Request resolved: #197676
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197675
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
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.
Pull Request resolved: #197650
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647
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 19, 2026
Keep the two distributed workers alive across slice, Bernoulli, and loss tests. Preserve the rank count and LocalTensor variant, including its existing send/recv skip.

Test plan: CUDA build and lint; all six cases in normal and reversed order, CPU fallback, and two GPUs after build. Runtime falls from 13.95s to 5.68s with one unchanged skip.
Pull Request resolved: #197687
Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
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.
Pull Request resolved: #197688
Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
ghstack dependencies: #197647, #197648, #197687
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
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Avoid per-test process startup for shape and offset utility coverage. Preserve eight ranks and the LocalTensor variant; other test classes remain unchanged.

Test plan: CUDA build and lint; all 20 utility tests in normal and reverse order, with no visible GPUs, and after rebuilding. Runtime fell from 38.5s to 6.4s.
Pull Request resolved: #197664
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
…7665)

Amortize process-group startup across checkpoint save/load and meta-device loading tests. Preserve rank counts and per-test temporary-directory cleanup.

Test plan: CUDA build and lint; both tests in normal and reverse order, with two visible GPUs, and after rebuilding. Runtime fell from 13.5s to 6.3s.
Pull Request resolved: #197665
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197664
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Use the continuous DTensor harness for the two real-process-group decomposition cache tests, preserving the original rank count. Leave the fake-process-group tests unchanged.

Test plan: CUDA build and lint; all seven file tests in normal/reverse order and one-visible-GPU CPU fallback. Postbuild runtime 5.8s versus 12.2s baseline.
Pull Request resolved: #197652
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse process groups within DTensor initialization and constructor classes. Preserve rank counts, the LocalTensor variant, and all constructor/layout assertions.

Test plan: CUDA build and lint; all 18 file tests in normal and reverse order, plus one-visible-GPU CPU fallback. Existing LocalTensor submesh skip preserved. Runtime falls from 56.6s to 14.0s.
Pull Request resolved: #197653
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197652
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse workers within the three resharding test classes. Preserve rank counts, placements, checkpoint formats and per-test temporary-directory cleanup.

Test plan: CUDA build and lint; all ten cases in normal and reverse order, two-GPU coverage, and all ten after rebuilding. Runtime fell from 105.7s to 62.0s.
Pull Request resolved: #197666
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse workers across the four checkpoint cases while preserving rank counts, per-test directories, and the combined CPU/accelerator backend. Use Gloo for CPU fallback when GPU-gated cases skip.

Test plan: CUDA build and lint; four cases in normal and reverse order, expected skips with two and zero visible GPUs, and four cases after rebuilding. Runtime fell from 28.4s to 12.2s.
Pull Request resolved: #197667
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197666
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse workers across DTensor API cases and use the matching continuous LocalTensor harness for generated variants. Preserve four ranks for 2D mesh coverage, the existing LocalTensor skip, and all assertions.

Test plan: CUDA build and lint pass. All 20 cases pass with one existing skip: 62.112s before versus 10.946s after. Reverse-order run passes in 11.382s; one-visible-GPU CPU fallback passes in 6.894s. Post-build full-file run passes in 11.018s with the same skip.
Pull Request resolved: #197649
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse workers for model-local parallel style tests. Keep sequence-parallel RNG initialization in a fresh-process class, including its LocalTensor variant, to preserve isolation.

Test plan: CUDA build and lint; all 22 cases normally and in reverse order, CPU fallback, two GPUs, and after build. Four-GPU runtime falls from 66.42s to 14.97s before rebuild.
Pull Request resolved: #197691
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
)

Reuse workers across optimizer checkpoint cases while preserving the combined CPU/accelerator backend, rank count and scoped subgroup cleanup.

Test plan: CUDA build and lint; three cases in normal and reverse order, with two GPUs, expected zero-GPU skips, and after rebuilding. Runtime fell from 17.4s to 6.6s.
Pull Request resolved: #197670
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
Reuse continuous DTensor workers across placement-change and mesh-change checkpoint tests. Preserve rank counts, temporary-directory cleanup, assertions, and the single-test consolidation fixture.

Test plan: CUDA build and lint pass; five four-GPU cases improve from 73.563s to 57.569s, reversed order 54.946s, postbuild 57.005s. Two-GPU and CPU-fallback runs preserve two and five expected skips.
Pull Request resolved: #197677
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
Reuse four distributed workers across optimizer tests that already disable RPC. Preserve the backend selection and per-rank device binding without changing the shared RPC harness.

Test plan: CUDA build and lint; both tests normally, in reverse order and after build; two expected skips on two GPUs and CPU. Baseline 11.18s; reused workers 5.77s before rebuild.
Pull Request resolved: #197696
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
Reuse four workers across rowwise and columnwise embedding tests that already disable RPC. Preserve the complete sharding, padding and renormalization matrix.

Test plan: CUDA build and lint; both tests normally, in reverse order and after build; two expected skips on two GPUs and CPU. Baseline 13.28s; reused workers 6.91s before rebuild.
Pull Request resolved: #197697
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197696
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
Reuse distributed workers across tensor-parallel API cases instead of spawning and initializing a process group per test. Preserve the rank-count rule and LocalTensor coverage.

Test plan: CUDA build and lint; all 32 tests in normal and reverse order and CPU fallback, with the same existing LocalTensor skip. Normal runtime fell from 96.2s to 10.4s.
Pull Request resolved: #197658
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
Use continuous workers for strided sharding, local-shard offsets, optimizer updates, and replication tests. Preserve four ranks, the LocalTensor variants, and all assertions. The 21 cases took 112.8s across baseline runs and 50.4s in the combined continuous run.

Test plan: CUDA build and lint; all 21 cases in normal and reversed order, on CPU, and after rebuilding.
Pull Request resolved: #197674
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197664
pytorchmergebot pushed a commit that referenced this pull request Sep 21, 2026
Reuse the continuous FSDP fixture for five mixed precision training tests, preserving rank counts, scoped collective patches, and all test bodies. Leave single-test JVP and threaded cast fixtures unchanged.

Test plan: CUDA build and lint pass; five four-GPU tests improve from 62.716s to 34.871s, reversed order 34.825s, postbuild 33.498s. Two GPUs pass in 12.796s; one and zero GPUs preserve five skips.
Pull Request resolved: #197678
Approved by: https://github.com/pytorchgreenlight, https://github.com/Skylion007
ghstack dependencies: #197647, #197648, #197677
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
pytorchmergebot pushed a commit that referenced this pull request Sep 22, 2026
…197657)

Share workers and the process group across the four initialization-info cases. Preserve the original rank cap and scoped environment patches; leave checkpoint process lifecycle tests unchanged.

Test plan: CUDA build and lint; four cases in normal/reverse order and one-visible-GPU CPU fallback; full six-test file postbuild. Four-case runtime improves from 22.2s to 5.7s.
Pull Request resolved: #197657
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197655, #197656
@github-actions
github-actions Bot deleted the gh/d4l3k/142/head branch November 23, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants