Skip to content

[DTensor] Add unflatten tests for multi-mesh sharding in view ops#176151

Closed
weifengpy wants to merge 56 commits intogh/weifengpy/82/basefrom
gh/weifengpy/82/head
Closed

[DTensor] Add unflatten tests for multi-mesh sharding in view ops#176151
weifengpy wants to merge 56 commits intogh/weifengpy/82/basefrom
gh/weifengpy/82/head

Conversation

@weifengpy
Copy link
Copy Markdown
Contributor

@weifengpy weifengpy commented Mar 2, 2026

Stack from ghstack (oldest at bottom):

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes. Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Mar 2, 2026

🔗 Helpful Links

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

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

✅ No Failures

As of commit 8c515d4 with merge base 3edbad8 (image):
💚 Looks good so far! There are no failures yet. 💚

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 Mar 2, 2026
weifengpy added a commit that referenced this pull request Mar 2, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: c83ff36
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 2, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: d331820
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 2, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 1f38a72
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 6516a32
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: baff1df
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 609226e
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 3d09172
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 2609eb0
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: eaf2e8e
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 3f1df1f
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 2ec6bc4
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 66a6185
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 3, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 748277b
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 25, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 3df005f
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 25, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: c9fd678
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 25, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 8991e8d
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 25, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 99c6e12
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 25, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: c7f11df
Pull Request resolved: #176151
…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
weifengpy added a commit that referenced this pull request Mar 25, 2026
Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

ghstack-source-id: 8306adb
Pull Request resolved: #176151
@weifengpy
Copy link
Copy Markdown
Contributor Author

is there any way you could greatly reduce LOC of this test by generating the test combinations from some list of cases? that would help readability and maintainability

totally. Just did a refactor and reduced 663 LOC.

from claude

Replaced separate 1D/2D/3D test methods with one test_dtensor_flatten_multi_mesh and one test_dtensor_unflatten_multi_mesh that loop over mesh shapes, so the same    
  test logic covers all dimensionalities without per-dimension copy-paste. 

…iew ops"

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.

[ghstack-poisoned]
@weifengpy weifengpy added ciflow/trunk Trigger trunk jobs on your pull request ciflow/torchtitan Run TorchTitan integration tests labels Mar 26, 2026
@weifengpy
Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Copilot AI pushed a commit that referenced this pull request Mar 27, 2026
…76151)

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.
Pull Request resolved: #176151
Approved by: https://github.com/wconstab
ghstack dependencies: #166483

Co-authored-by: Xia-Weiwen <12522207+Xia-Weiwen@users.noreply.github.com>
AaronWang04 pushed a commit to AaronWang04/pytorch that referenced this pull request Mar 31, 2026
…torch#176151)

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.
Pull Request resolved: pytorch#176151
Approved by: https://github.com/wconstab
ghstack dependencies: pytorch#166483
pytorch-bot Bot pushed a commit that referenced this pull request Apr 2, 2026
…76151)

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.
Pull Request resolved: #176151
Approved by: https://github.com/wconstab
ghstack dependencies: #166483
nklshy-aws pushed a commit to nklshy-aws/pytorch that referenced this pull request Apr 7, 2026
…torch#176151)

Add comprehensive tests for unflatten (view) operations with _StridedShard
placements on 1D, 2D, and 3D meshes.  Tests cover all factorizations of
dimension sizes, (SS,SS), (R,SS), (R,R,SS) placement patterns, uneven
sharding error cases, and flatten-unflatten round-trips with reversed
mesh shapes.
Pull Request resolved: pytorch#176151
Approved by: https://github.com/wconstab
ghstack dependencies: pytorch#166483
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 ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants