Repository navigation
Perf Optimize spectral operations and backend dispatch - #42
Merged
Merged
Conversation
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
bruAristimunha
approved these changes
Oct 15, 2026
bruAristimunha
left a comment
Contributor
There was a problem hiding this comment.
Small details, and all good
bruAristimunha
left a comment
Contributor
There was a problem hiding this comment.
Thanks a lot @lucas-heck, really nice work, and the benchmark numbers in the description help a lot.
I did a second full pass before merging:
- Full test suite on all four open PRs merged together (#42 → #43 → #44 → #45): 825 passed, 147 skipped, plus the docs code blocks.
- The non-CPU
torch.wherebranch inmodeig_backwardonly runs on accelerators, so CI does not cover it (that explains most of the codecov gap). I ran it on Apple MPS with a batch that includes repeated eigenvalues:matrix_loggradients match CPU to 6e-8. LogEig/ExpEig: afterload_state_dictfrom a checkpoint with a differentautogradflag, the cached backend is correctly picked up.gradcheckon batched float64matrix_logpasses.
Small, non-blocking notes:
get_loewner_thresholdconflicts with #45, which makes the threshold per matrix. I'll keep #45's version, since it is a superset of this one (tensor, on-device, per matrix).- The
CHANGELOG.mddiff also reformats the old model/metric tables (whitespace only). That's harmless, just noise in the diff. - The
_use_autogradcache only updates on__init__andload_state_dict. If someone changesautograd_in place, it goes stale. That's fine as long as the buffer is treated as read-only.
Merging. Thanks again!
This file contains hidden or 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
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.
This PR reduces intermediate allocations, mainly by using PyTorch optimized operations, and backend dispatch overhead in a couple of layers:
It also skips matrix-log clamping warnings for CUDA inputs requiring gradient, which might be a maintainer decision but this way it avoids synchronization during training (I don't mind changing back).
Validation: