-
Notifications
You must be signed in to change notification settings - Fork 117
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
Fix einsum bug #1185
Merged
Merged
Fix einsum bug #1185
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ricardoV94
added
bug
Something isn't working
NumPy compatibility
Op implementation
labels
Feb 3, 2025
ricardoV94
commented
Feb 3, 2025
@@ -546,8 +552,6 @@ def einsum(subscripts: str, *operands: "TensorLike", optimize=None) -> TensorVar | |||
"If you need this functionality open an issue in https://github.com/pymc-devs/pytensor/issues to let us know. " | |||
) | |||
|
|||
# TODO: Is this doing something clever about unknown shapes? |
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.
I checked, they are not doing anything clever, simply set unknown dims to 8 and use whatever comes out of it
ricardoV94
force-pushed
the
fix_bug_einsum
branch
2 times, most recently
from
February 3, 2025 11:13
902487b
to
43a0cc5
Compare
ricardoV94
force-pushed
the
fix_bug_einsum
branch
from
February 3, 2025 11:27
43a0cc5
to
ca4bc56
Compare
Nothing clever was going on, unknown dims were simply faked as having length 8 for JAX polymorphism export
A shortcut in the numpy implementation of einsum_path when there's nothing to optimize, creates a default path that can combine more than 2 operands. Our implementation only works with 2 or 1 operand operations at each step. https://github.com/numpy/numpy/blob/cc5851e654bfd82a23f2758be4bd224be84fc1c3/numpy/_core/einsumfunc.py#L945-L951
ricardoV94
force-pushed
the
fix_bug_einsum
branch
from
February 3, 2025 14:54
ca4bc56
to
5de2c22
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1185 +/- ##
=======================================
Coverage 82.29% 82.29%
=======================================
Files 186 186
Lines 48039 48045 +6
Branches 8632 8633 +1
=======================================
+ Hits 39533 39539 +6
Misses 6348 6348
Partials 2158 2158
|
jessegrabowski
approved these changes
Feb 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A shortcut in the numpy implementation of einsum_path when there's nothing to optimize, creates a default path that can combine more than 2 operands. Our implementation only works with 2 or 1 operand operations at each step.
https://github.com/numpy/numpy/blob/cc5851e654bfd82a23f2758be4bd224be84fc1c3/numpy/_core/einsumfunc.py#L945-L951
Closes #1184
📚 Documentation preview 📚: https://pytensor--1185.org.readthedocs.build/en/1185/