KEMBAR78
[non-strict export] uncovered cases of select and slice by avikchaudhuri · Pull Request #157821 · pytorch/pytorch · GitHub
Skip to content

Conversation

@avikchaudhuri
Copy link
Contributor

Summary:
None and Ellipsis in multi-dimensional indexing was previously not covered.

Moreover, we introduce a small optimization for slice(None) and a passthrough when symints do not appear in the indexing.

The remaining case is where indexing is by tensor, which is fairly complicated; we passthrough in that case.

Test Plan:
added tests

Rollback Plan:

Differential Revision: D77943929

@pytorch-bot
Copy link

pytorch-bot bot commented Jul 8, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit eae96ee with merge base 752f202 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D77943929

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D77943929

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D77943929

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Jul 8, 2025
Summary:
Pull Request resolved: pytorch#157821

`None` and `Ellipsis` in multi-dimensional indexing was previously not covered.

Moreover, we introduce a small optimization for `slice(None)` and a passthrough when symints do not appear in the indexing.

The remaining case is where indexing is by tensor, which is fairly complicated; we passthrough in that case.

Test Plan:
added tests

Rollback Plan:

Differential Revision: D77943929
if isinstance(item, slice):
if all(s is None for s in (item.start, item.stop, item.step)):
# no-op
return dim + 1, (lambda t: t, [])
Copy link
Contributor

@pianpwk pianpwk Jul 9, 2025

Choose a reason for hiding this comment

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

this case should be covered by #157528, but it's fine to have

nit: this passthrough also applies when item.step == 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add the step=1 case.

n_none_slices -= 1

# only rewrite when there are symints
if has_symint:
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like this logic should still apply without symints? Testing locally, removing this branch passes the test too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it should pass. Which is why I have the G_* modules which I used to test concrete inputs locally.

I just didn't want to perturb existing generated code too much. In a separate PR I had tried doing this for strict and had to update a gazillion tests.

t = _method(t, *_args)
return t

return run, [], {}
Copy link
Contributor

Choose a reason for hiding this comment

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

in general it seems really weird that we need to handle all this logic here, and there's not some centralized handling we can easily dispatch to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, agreed. Unfortunately handling this in strict would need duplicate logic since all checks would be in terms of isinstance of Dynamo variables.

As a separate pass I can pull up the individual handlers (e.g., distributed) to the top level.

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 9, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D77943929

Summary:
Pull Request resolved: pytorch#157821

`None` and `Ellipsis` in multi-dimensional indexing was previously not covered.

Moreover, we introduce a small optimization for `slice(None)` and a passthrough when symints do not appear in the indexing.

The remaining case is where indexing is by tensor, which is fairly complicated; we passthrough in that case.

Test Plan:
added tests

Rollback Plan:

Reviewed By: pianpwk

Differential Revision: D77943929
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D77943929

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants