Skip to content

[distributed] Reuse workers for DTensor embedding tests - #197648

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

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

Conversation

@d4l3k

@d4l3k d4l3k commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Stack from ghstack (oldest at bottom):

Reuse workers across embedding cases and use the matching continuous LocalTensor harness for generated local tests. Preserve NUM_DEVICES as the original rank-count cap and keep communication decorators and assertions unchanged.

Share a stateless device-selection helper between the instance property and class-level setup. Preserve CPU fallback without constructing a test object.

Test plan: CUDA build and lint pass. All ten tests, including five LocalTensor variants, pass in 7.833s versus 31.107s before. Reverse-order run passes in 7.606s; two-GPU run passes all ten in 6.338s. Full-file post-build rerun passes. Three device-selection unit tests pass, covering CPU fallback and agreement between instance and class setup at zero, one, four, and eight mocked accelerators. After rebuilding, all ten embedding tests pass with one, two, and four visible GPUs, and all seven checkpoint utility tests pass.

Additional validation: rebuilt CUDA, all ten embedding tests with four/two/one/zero visible GPUs, checkpoint utility tests, and common sharding-rule tests.

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

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

✅ No Failures

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

🟡 GREEN LIGHT - PR requires human review:

  • Skip guard weakened
    • DTensorContinuousTestBase._init_pg now gates the world_size > device_count skip behind _get_device_type(world_size) != "cpu", and _get_device_type already returns "cpu" whenever DEVICE_COUNT < world_size
    • DEVICE_COUNT is assigned torch.accelerator.device_count() at common_dtensor.py:78, the same value the inner check compares against, so the sys.exit(TEST_SKIPS[f"multi-device-{world_size}"]) branch is now unreachable
  • Behavior change reaches beyond embedding tests
    • backend_str switches from DEVICE_TYPE to _get_device_type(cls.world_size), so under-provisioned runs now report gloo instead of nccl, changing the NCCL_MULTI_RANK_GPU_ENABLE oversubscribe path at common_distributed.py:1936-1939
    • Roughly twenty existing subclasses share this harness, including MultiDimRedistributeTest, DistributeWithDeviceOrderTest and DistributeWithStridedShardTest at test_redistribute.py:1182,1270,1829 with world_size = 8, which previously skipped and would now run on CPU/gloo
  • Test coverage does not reach the changed path
    • The three new tests in test_dtensor_testbase.py only exercise _get_device_type and _init_pg against mocked DEVICE_COUNT, with MultiProcContinuousTest._init_pg patched out
    • The PR body's validation lists embedding, checkpoint and common-rules tests, none of which declare a world_size above NUM_DEVICES, so the newly-unskipped 8-rank classes are unvalidated
  • Scope versus stated intent
    • Title and body describe reusing workers for test_embedding_ops.py and "preserve CPU fallback", but the edit to _init_pg silently converts a device-shortage skip into a CPU run for every continuous DTensor test

reason: possible_regression
Reviewed commit: 320bb2b

Inference job

🐛 Report a wrong verdict

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

d4l3k added a commit that referenced this pull request Sep 19, 2026
Reuse workers across embedding cases and use the matching continuous LocalTensor harness for generated local tests. Preserve NUM_DEVICES as the original rank-count cap and keep communication decorators and assertions unchanged.

Resolve the test's CPU fallback before selecting the backend or binding accelerator devices so insufficient accelerator counts do not silently skip CPU coverage.

Test plan: CUDA build and lint pass. All ten tests, including five LocalTensor variants, pass in 7.833s versus 31.107s before. Reverse-order run passes in 7.606s; two-GPU run passes all ten in 6.338s. Full-file post-build rerun passes. Two CPU-fallback unit tests pass with and without visible GPUs. After rebuilding, all ten embedding tests pass with one, two, and four visible GPUs, and all seven checkpoint utility tests pass.

ghstack-source-id: 40cbd3b
Pull-Request: #197648
This was referenced Sep 19, 2026
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Reuse workers across eager convolution tests while keeping the compiler regression in a fresh-process class. Preserve rank count, LocalTensor skips and every test body.

Test plan: CUDA build and lint; 22 eager cases normally, in reverse order and after build (8 existing skips), plus 18 CPU cases. Baseline 58.18s; reused workers 15.77s before rebuild. AST comparison verifies all test bodies/decorators unchanged. The isolated compiler case was not run locally (Triton unavailable).
Pull Request resolved: #197692
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
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.
Pull Request resolved: #197693
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197692
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
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Use the continuous DTensor harness for the three subclass-dispatch tests, retaining the original device-count rank cap. Leave other DTensor classes unchanged.

Test plan: CUDA build and lint; all three cases in normal/reverse order and one-visible-GPU CPU fallback. Runtime falls from 16.3s to 5.2s.
Pull Request resolved: #197655
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648
pytorchmergebot pushed a commit that referenced this pull request Sep 19, 2026
Amortize process-group startup across core DTensor cases using the continuous harness. Preserve the rank cap, LocalTensor variant and skips, assertions, and separate serialization-import subprocesses.

Test plan: CUDA build and lint; all 58 real/LocalTensor cases in normal and reverse order, one-visible-GPU CPU fallback, and postbuild. Three existing LocalTensor skips preserved. Runtime improves from 170.2s to 13.4s.
Pull Request resolved: #197656
Approved by: https://github.com/pytorchgreenlight
ghstack dependencies: #197647, #197648, #197655
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
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 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/143/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

ciflow/dtensor Run DTensor specific tests Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants