Skip to content

[BE][Test] Trim mode OpInfo sample inputs - #203277

Closed
jbschlosser wants to merge 16 commits into
gh/jbschlosser/292/basefrom
gh/jbschlosser/292/head
Closed

jbschlosser wants to merge 16 commits into
gh/jbschlosser/292/basefrom
gh/jbschlosser/292/head

Conversation

@jbschlosser

@jbschlosser jbschlosser commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Removes a duplicate sample and shrinks the large-slice sample for the
mode OpInfo entry.

Authored with an AI assistant (Metamate).

Removed duplication:

  • the no-arg 0-d sample: on a 0-d tensor the default dim=-1 wraps to 0, so it is identical to the dim=0 sample (the dim=0, keepdim=True one stays, since forward AD and the vmap batch rule branch on keepdim)

Dropped coverage: none. (3000,), which exists to hit the non-fused CUDA kernel (slice size > 2 * MAX_BLOCK_SIZE: 2048 on CUDA, 512 on ROCm), shrinks to (2052,), the smallest size above 2048 that the 4-rank DTensor op-db tests can still Shard(0).

Test-config cleanup: the stale numbers in the test_compare_cpu skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start.

Samples per dtype, unique in parentheses:

OpInfo before after
mode 7 (6) 6

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - Ready for human review:

The PR trims the `mode` OpInfo sample inputs: it removes the duplicate 0-d
sample that took no arguments, shrinks the sample that exercises the non-fused
CUDA kernel from (3000,) to (2052,), and corrects the test_compare_cpu skip
comment. The review found no issues. Recommendation: Approve.

Reviewed commit: 972c68f

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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

✅ You can merge normally! (4 Unrelated Failures)

As of commit 972c68f with merge base 51f0eeb (image):

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Triviality
    • Edits sample_inputs_mode in torch/testing/_internal/common_methods_invocations.py, a shared OpInfo helper that Explained test changes excludes
    • Removing the ((), ()) sample and shrinking (3000,) to (2052,) changes coverage for every test that consumes the mode OpInfo, so no trivial class fits
  • Reviewer questions
    • The (2052,) size is justified by sharding in the DTensor op-db, but test/distributed/tensor/test_dtensor_ops.py has xfail("mode"), so a human should confirm that rationale
    • The kernel threshold matches: TensorModeKernel.cpp takes the fused path only when slice_size <= 2 * MAX_BLOCK_SIZE (1024 on CUDA), and 2052 is above that

reason: not_trivial
Reviewed commit: 0ee9095 (NOT the current head 972c68f)

Inference job

🐛 Report a wrong verdict

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

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

@pytorch-bot pytorch-bot Bot added the release notes: python_frontend python frontend release notes category label Nov 3, 2026
@pytorchgreenlight pytorchgreenlight Bot added the GL/human GreenLight marked as needing human review label Nov 3, 2026
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 3, 2026
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
github-actions[bot]

This comment was marked as outdated.

@jbschlosser jbschlosser added topic: not user facing topic category and removed release notes: python_frontend python frontend release notes category labels Nov 5, 2026
[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> The no-arg 0-d sample is dropped: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the existing `dim=0` sample. The `dim=0, keepdim=True` 0-d sample is kept because forward AD (`gather_with_keepdimed_indices`) and the vmap batch rule branch on keepdim.
>
> The `(3000,)` sample exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`, which is 1024 on CUDA and 256 on ROCm), so it is shrunk to 2049, the smallest size that still takes that path on CUDA (ROCm takes it from 513). It still runs on every device, so XPU and the CPU comparison keep a long slice. The stale numbers in the `test_compare_cpu` skip comment came from the old sample and are replaced with the actual cause: that test only runs on ROCm, and when the mode value occurs more than once, CPU (unstable sort) and CUDA can return different occurrence indices. The comment on the 2049 sample now names the `MAX_BLOCK_SIZE` it depends on (`TensorModeKernel.cpp`).
>
> Samples per dtype: 7 -> 6.

ghstack-source-id: 0466d2a
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed stale reviews from themself November 5, 2026 16:48

Withdrawn: the automated review of aaf04ee found nothing blocking.

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> The no-arg 0-d sample is dropped: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the existing `dim=0` sample. The `dim=0, keepdim=True` 0-d sample is kept because forward AD (`gather_with_keepdimed_indices`) and the vmap batch rule branch on keepdim.
>
> The `(3000,)` sample exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`, which is 1024 on CUDA and 256 on ROCm), so it is shrunk to 2049, the smallest size that still takes that path on CUDA (ROCm takes it from 513). It still runs on every device, so XPU and the CPU comparison keep a long slice. The stale numbers in the `test_compare_cpu` skip comment came from the old sample and are replaced with the actual cause: that test only runs on ROCm, and when the mode value occurs more than once, CPU (unstable sort) and CUDA can return different occurrence indices. The comment on the 2049 sample now names the `MAX_BLOCK_SIZE` it depends on (`TensorModeKernel.cpp`).
>
> Samples per dtype: 7 -> 6.

ghstack-source-id: a09bf79
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> The no-arg 0-d sample is dropped: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the existing `dim=0` sample. The `dim=0, keepdim=True` 0-d sample is kept because forward AD (`gather_with_keepdimed_indices`) and the vmap batch rule branch on keepdim.
>
> The `(3000,)` sample exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`, which is 1024 on CUDA and 256 on ROCm), so it is shrunk to 2049, the smallest size that still takes that path on CUDA (ROCm takes it from 513). It still runs on every device, so XPU and the CPU comparison keep a long slice. The stale numbers in the `test_compare_cpu` skip comment came from the old sample and are replaced with the actual cause: that test only runs on ROCm, and when the mode value occurs more than once, CPU (unstable sort) and CUDA can return different occurrence indices. The comment on the 2049 sample now names the `MAX_BLOCK_SIZE` it depends on (`TensorModeKernel.cpp`).
>
> Samples per dtype: 7 -> 6.

ghstack-source-id: b07229c
Pull-Request: #203277
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> The no-arg 0-d sample is dropped: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the existing `dim=0` sample. The `dim=0, keepdim=True` 0-d sample is kept because forward AD (`gather_with_keepdimed_indices`) and the vmap batch rule branch on keepdim.
>
> The `(3000,)` sample exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`, which is 1024 on CUDA and 256 on ROCm), so it is shrunk to 2049, the smallest size that still takes that path on CUDA (ROCm takes it from 513). It still runs on every device, so XPU and the CPU comparison keep a long slice. The stale numbers in the `test_compare_cpu` skip comment came from the old sample and are replaced with the actual cause: that test only runs on ROCm, and when the mode value occurs more than once, CPU (unstable sort) and CUDA can return different occurrence indices. The comment on the 2049 sample now names the `MAX_BLOCK_SIZE` it depends on (`TensorModeKernel.cpp`).
>
> Samples per dtype: 7 -> 6.

ghstack-source-id: b07229c
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> The no-arg 0-d sample is dropped: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the existing `dim=0` sample. The `dim=0, keepdim=True` 0-d sample is kept because forward AD (`gather_with_keepdimed_indices`) and the vmap batch rule branch on keepdim.
>
> The `(3000,)` sample exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`, which is 1024 on CUDA and 256 on ROCm), so it is shrunk to 2049, the smallest size that still takes that path on CUDA (ROCm takes it from 513). It still runs on every device, so XPU and the CPU comparison keep a long slice. The stale numbers in the `test_compare_cpu` skip comment came from the old sample and are replaced with the actual cause: that test only runs on ROCm, and when the mode value occurs more than once, CPU (unstable sort) and CUDA can return different occurrence indices. The comment on the 2049 sample now names the `MAX_BLOCK_SIZE` it depends on (`TensorModeKernel.cpp`).
>
> Samples per dtype: 7 -> 6.

ghstack-source-id: 96aebc1
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> Removed duplication:
> - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim)
>
> Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`.
>
> Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start.
>
> Samples per dtype, unique in parentheses:
>
> | OpInfo | before | after |
> |---|---|---|
> | mode | 7 (6) | 6 |

ghstack-source-id: ffd4498
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed their stale review November 5, 2026 19:43

Withdrawn: the automated review of b2bbfce found nothing blocking.

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> Removed duplication:
> - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim)
>
> Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`.
>
> Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start.
>
> Samples per dtype, unique in parentheses:
>
> | OpInfo | before | after |
> |---|---|---|
> | mode | 7 (6) | 6 |

ghstack-source-id: a0885ed
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> Removed duplication:
> - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim)
>
> Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`.
>
> Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start.
>
> Samples per dtype, unique in parentheses:
>
> | OpInfo | before | after |
> |---|---|---|
> | mode | 7 (6) | 6 |

ghstack-source-id: 69cd925
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> Removed duplication:
> - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim)
>
> Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`.
>
> Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start.
>
> Samples per dtype, unique in parentheses:
>
> | OpInfo | before | after |
> |---|---|---|
> | mode | 7 (6) | 6 |

ghstack-source-id: 463df15
Pull-Request: #203277
github-actions[bot]

This comment was marked as outdated.

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice!

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Nov 5, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> Removed duplication:
> - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim)
>
> Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`.
>
> Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start.
>
> Samples per dtype, unique in parentheses:
>
> | OpInfo | before | after |
> |---|---|---|
> | mode | 7 (6) | 6 |

ghstack-source-id: 1b3ccfa
Pull-Request: #203277
@pytorchgreenlight pytorchgreenlight Bot added GL/superseded GreenLight review is superseded by changes and removed GL/human GreenLight marked as needing human review labels Nov 5, 2026

@github-actions github-actions Bot 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.

Automated review of 972c68f: nothing blocking; ready for human review.

The PR trims the mode OpInfo sample inputs: it removes the duplicate 0-d sample that took no arguments, shrinks the sample that exercises the non-fused CUDA kernel from (3000,) to (2052,), and corrects the test_compare_cpu skip comment. The review found no issues. Recommendation: Approve.

This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 6, 2026
@jbschlosser

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added ciflow/trunk Trigger trunk jobs on your pull request ciflow/periodic-strict labels Nov 6, 2026
@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

dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
Removes a duplicate sample and shrinks the large-slice sample for the
`mode` OpInfo entry.

> Authored with an AI assistant (Metamate).
>
> Removed duplication:
> - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim)
>
> Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`.
>
> Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start.
>
> Samples per dtype, unique in parentheses:
>
> | OpInfo | before | after |
> |---|---|---|
> | mode | 7 (6) | 6 |
Pull Request resolved: pytorch#203277
Approved by: https://github.com/albanD
ghstack dependencies: pytorch#203270, pytorch#203278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/periodic-strict ciflow/trunk Trigger trunk jobs on your pull request GL/superseded GreenLight review is superseded by changes Merged ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants