-
Notifications
You must be signed in to change notification settings - Fork 146
Reorganize the sparse module
#1674
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
base: main
Are you sure you want to change the base?
Reorganize the sparse module
#1674
Conversation
|
I think it was a mistake to inherit from TensorVariable in the first place. They are way too distinct objects |
|
I believe we should revert aesara-devs/aesara#142, in fact the example given of Subtensor just further proves the point. Indexing in sparsevariables has nothing to do with in indexing in tensorvariables, starting with the fact there are no sparse vectors, only matrices |
|
mypy is failing because of that inheritance for what its worth |
I agree. The current mixins don't make any sense at all. We have e.g. |
3d78e1e to
2e2211c
Compare
tests/sparse/test_math.py
Outdated
| else: | ||
| return pytensor.sparse.matrix(format, name, dtype=dtype) | ||
|
|
||
| params = product( |
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.
This leads to 2,304 test cases, which seems slightly excessive.
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.
only?
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.
It was marked as a slow test, which isn't super shocking. But it actually runs in <1s on my local machine after all your recent compile speedups. Pretty impressive!
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.
Could be a caching thing. Our CI doesn't have that luxury, so it may be slow in the CI still (we can check)
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.
it takes 60s without cache on my machine, and 30s on the second run. I don't know how you get <1s, that seems wild, perhaps you're just seeing the time of "skipping"?
2e2211c to
a823f30
Compare
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (81.99%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1674 +/- ##
==========================================
- Coverage 81.70% 81.69% -0.02%
==========================================
Files 246 249 +3
Lines 53632 53824 +192
Branches 9438 9436 -2
==========================================
+ Hits 43820 43971 +151
- Misses 7330 7372 +42
+ Partials 2482 2481 -1
🚀 New features to boost your workflow:
|
a823f30 to
659fec8
Compare
|
@ricardoV94 look at this one too since you're on a mergeathon |
|
I'm more comfortable letting @Armavica review this one. He somehow has an eye for walls of linediffs :) |
659fec8 to
c904d24
Compare
|
How confident are you that you only did a refactor and nothing was lost. Also is this a major change, or nothing changes in user facing API (like import locations, Op names)? Need to know for the PR labels |
|
It seems like you changed somethings. |
Description
Reorganize the existing sparse code to be a bit more logical. In particular, the sparse module now mirrors the tensor module:
sparse/basic.pyhas constructors and utilitiessparse/math.pyhas math stuffsparse/variable.pyhas base classessparse/linalg.pyhas linear algebraOther stuff was mostly untouched. My motivation here is to lay the groundwork to get people to come look at and work on sparse. Things were pretty messy before. There was a lot of magic I didn't like. For example, the
_sparse_py_operatorsinherited from_tensor_py_operators, and did some wrapper magic to dispatch a huge list of methods to sparse. I made this a lot more verbose, and putNotImplementedeverywhere, so it's obvious to potential helpers what needs to be implemented.Related Issue
Checklist
Type of change
📚 Documentation preview 📚: https://pytensor--1674.org.readthedocs.build/en/1674/