-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Improve input validation for NJT pointwise ops #138602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
[ghstack-poisoned]
🔗 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 FailuresAs of commit b99667a with merge base 046f02d ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this 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?
good point, it does reject it. I thought we'd hit the |
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]
|
Updated PR to do a dumber check for any nested ints before dispatching on pointwise ops. |
|
@pytorchbot merge |
Merge startedYour 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 |
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
Stack from ghstack (oldest at bottom):
Before this PR, NJT would dispatch e.g.
NJT * nested_inttomul.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 disallowsnt * 2, which (non-intuitively to me at least at first) dispatches via themul.Tensoroverload.