Skip to content

Conversation

jbschlosser
Copy link
Contributor

@jbschlosser jbschlosser commented Oct 22, 2024

Stack from ghstack (oldest at bottom):

Before this PR, NJT would dispatch e.g. NJT * nested_int to mul.Tensor, wrongly interpreting the SymInt as a tensor and outputting garbage. This PR verifies that there are no nested ints in the list of args before dispatching for pointwise ops.

I originally tried checking that the number of passed tensor args == the number of func schema tensor args, but this wrongly disallows nt * 2, which (non-intuitively to me at least at first) dispatches via the mul.Tensor overload.

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 22, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit b99667a with merge base 046f02d (image):
💚 Looks good so far! There are no failures yet. 💚

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

Copy link
Contributor

@davidberard98 davidberard98 left a comment

Choose a reason for hiding this comment

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

will this also reject nt * 2 or will that pass?

@jbschlosser
Copy link
Contributor Author

will this also reject nt * 2 or will that pass?

good point, it does reject it. I thought we'd hit the mul.Scalar overload but no luck

Before this PR, we were using the number of passed tensor args to determine whether to dispatch to unary / binary pointwise impls. This had the unintended consequence of allowing e.g. `NJT * nested_int`, wrongly interpreting the SymInt as a tensor and outputting garbage. We should check the func schema itself to be more accurate.

[ghstack-poisoned]
jbschlosser added a commit that referenced this pull request Oct 22, 2024
ghstack-source-id: 138d908
Pull Request resolved: #138602
@jbschlosser
Copy link
Contributor Author

Updated PR to do a dumber check for any nested ints before dispatching on pointwise ops.

@jbschlosser
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 22, 2024
@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

SamGinzburg pushed a commit that referenced this pull request Oct 28, 2024
Before this PR, NJT would dispatch e.g. `NJT * nested_int` to `mul.Tensor`, wrongly interpreting the SymInt as a tensor and outputting garbage. This PR verifies that there are no nested ints in the list of args before dispatching for pointwise ops.

I originally tried checking that `the number of passed tensor args == the number of func schema tensor args`, but this wrongly disallows `nt * 2`, which (non-intuitively to me at least at first) dispatches via the `mul.Tensor` overload.
Pull Request resolved: #138602
Approved by: https://github.com/soulitzer
@github-actions github-actions bot deleted the gh/jbschlosser/193/head branch November 22, 2024 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants