Skip to content

[dtensor] Add single_dim_strategy functions for reduction-with-indices ops - #179200

Closed
anshul-si wants to merge 16 commits into
gh/anshul-si/125/basefrom
gh/anshul-si/125/head
Closed

anshul-si wants to merge 16 commits into
gh/anshul-si/125/basefrom
gh/anshul-si/125/head

Conversation

@anshul-si

@anshul-si anshul-si commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

…s ops

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Apr 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (5 Unrelated Failures)

As of commit a754411 with merge base c54d05a (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
@anshul-si
anshul-si requested review from pianpwk, wconstab and zpcore April 3, 2026 02:05
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
Comment on lines +433 to +437
# @register_single_dim_strategy(
# list(ARGMAX_ARGMIN_OPS.keys()),
# schema_info=RuntimeSchemaInfo(1),
# allow_uneven_sharding=True,
# )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why don't we remove existing argmax_argmin_strategy and enable this strategy registration for those ops? This happens to others PRs in the stack also.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a PR at the end for enablement of new strategies and deleting existing strategies. The reason I do it this way is so that if there are issues with logic, there's only one pr reverted, making it cleaner for me and others who are also working on this file

@zpcore zpcore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic LGTM comparing with the existing strategy.

@anshul-si

Copy link
Copy Markdown
Contributor Author

@pytorchbot review this pr

@pytorch-bot

pytorch-bot Bot commented Apr 14, 2026

Copy link
Copy Markdown

❌ 🤖 pytorchbot command failed:

@pytorchbot: error: argument command: invalid choice: 'review' (choose from 'merge', 'revert', 'rebase', 'label', 'drci', 'lint', 'fix-lint', 'apply-lint', 'cherry-pick')

usage: @pytorchbot [-h]
                   
                   {merge,revert,rebase,label,drci,lint,fix-lint,apply-lint,cherry-pick}
                   ...

Try @pytorchbot --help for more info.

@anshul-si anshul-si added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 14, 2026
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
…with-indices ops"

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).

[ghstack-poisoned]
@anshul-si

Copy link
Copy Markdown
Contributor Author

@pytorchbot 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

jemitche1 pushed a commit to jemitche1/pytorch that referenced this pull request Jun 13, 2026
…s ops (pytorch#179200)

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).
Pull Request resolved: pytorch#179200
Approved by: https://github.com/zpcore
ghstack dependencies: pytorch#179068
pytorchmergebot pushed a commit that referenced this pull request Jun 15, 2026
Add single_dim_strategy implementations for:
- Category C: Linear reductions (sum, mean, amax, amin, nansum, prod)
- Category C: Bool reductions (all, any) - fixes incorrect S(dim)->P rules
- Category D: Non-linear reductions (std, var, var_mean, logsumexp)
- Category E: Norm reductions (vector_norm, norm.Scalar, powsum) - fixes incorrect S(dim)->NormP rules
- Category J: Global median (median.default, nanmedian.default)

New registrations are commented out; old register_op_strategy kept active.
Pull Request resolved: #179201
Approved by: https://github.com/zpcore, https://github.com/pianpwk
ghstack dependencies: #179068, #179200
pytorchmergebot pushed a commit that referenced this pull request Jun 16, 2026
…ly, and histc ops (#179202)

Add single_dim_strategy implementations for:
- Category G: Pooling ops (batch/channel dim sharding, partial for avg pools)
- Category H: Replicate-only ops (SVD, QR, diagonal, tril, triu, upsample, etc.)
- Category L: Histc (partial output when min/max specified)

New registrations are commented out; old register_op_strategy kept active.
Pull Request resolved: #179202
Approved by: https://github.com/pianpwk
ghstack dependencies: #179068, #179200, #179201
@github-actions
github-actions Bot deleted the gh/anshul-si/125/head branch July 12, 2026 02:25
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…s ops (pytorch#179200)

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).
Pull Request resolved: pytorch#179200
Approved by: https://github.com/zpcore
ghstack dependencies: pytorch#179068
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…h#179201)

Add single_dim_strategy implementations for:
- Category C: Linear reductions (sum, mean, amax, amin, nansum, prod)
- Category C: Bool reductions (all, any) - fixes incorrect S(dim)->P rules
- Category D: Non-linear reductions (std, var, var_mean, logsumexp)
- Category E: Norm reductions (vector_norm, norm.Scalar, powsum) - fixes incorrect S(dim)->NormP rules
- Category J: Global median (median.default, nanmedian.default)

New registrations are commented out; old register_op_strategy kept active.
Pull Request resolved: pytorch#179201
Approved by: https://github.com/zpcore, https://github.com/pianpwk
ghstack dependencies: pytorch#179068, pytorch#179200
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ly, and histc ops (pytorch#179202)

Add single_dim_strategy implementations for:
- Category G: Pooling ops (batch/channel dim sharding, partial for avg pools)
- Category H: Replicate-only ops (SVD, QR, diagonal, tril, triu, upsample, etc.)
- Category L: Histc (partial output when min/max specified)

New registrations are commented out; old register_op_strategy kept active.
Pull Request resolved: pytorch#179202
Approved by: https://github.com/pianpwk
ghstack dependencies: pytorch#179068, pytorch#179200, pytorch#179201
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…s ops (pytorch#179200)

Refactor max.dim, min.dim, median.dim, nanmedian.dim, mode, kthvalue to
use the shared _shard_non_reduction_dim helper. Add new single_dim_strategy
for argmax/argmin (decorator commented out, old register_op_strategy kept).
Pull Request resolved: pytorch#179200
Approved by: https://github.com/zpcore
ghstack dependencies: pytorch#179068
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…h#179201)

Add single_dim_strategy implementations for:
- Category C: Linear reductions (sum, mean, amax, amin, nansum, prod)
- Category C: Bool reductions (all, any) - fixes incorrect S(dim)->P rules
- Category D: Non-linear reductions (std, var, var_mean, logsumexp)
- Category E: Norm reductions (vector_norm, norm.Scalar, powsum) - fixes incorrect S(dim)->NormP rules
- Category J: Global median (median.default, nanmedian.default)

New registrations are commented out; old register_op_strategy kept active.
Pull Request resolved: pytorch#179201
Approved by: https://github.com/zpcore, https://github.com/pianpwk
ghstack dependencies: pytorch#179068, pytorch#179200
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ly, and histc ops (pytorch#179202)

Add single_dim_strategy implementations for:
- Category G: Pooling ops (batch/channel dim sharding, partial for avg pools)
- Category H: Replicate-only ops (SVD, QR, diagonal, tril, triu, upsample, etc.)
- Category L: Histc (partial output when min/max specified)

New registrations are commented out; old register_op_strategy kept active.
Pull Request resolved: pytorch#179202
Approved by: https://github.com/pianpwk
ghstack dependencies: pytorch#179068, pytorch#179200, pytorch#179201
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/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: distributed (dtensor) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants