Optimized arithmetic methods for strided triangular matrices#52571
Merged
Optimized arithmetic methods for strided triangular matrices#52571
Conversation
jishnub
added a commit
that referenced
this pull request
Dec 25, 2023
Since the values stored in the parent corresponding to the structural zeros of a tridiagonal matrix aren't well-defined, using it in `ldiv!` is a footgun that may lead to heisenbugs (one seen in https://buildkite.com/julialang/julia-master/builds/31285#018c7cc7-6c77-41ac-a01b-1c7d14cb1b15). This PR changes it to using the tridiagonal matrix directly in `ldiv!`, which should lead to predictable results, and be bug-free. The failing tests for #52571 pass locally with this change.
Member
Author
|
Although this PR improves performance and resolves several issues, I don't really like the hacky nature of the new methods that are specifically working around bugs with using a partly initialized |
Member
|
Ready to go? I still like it. 😉 |
Member
Author
|
Looks good to me. Perhaps we should update the branch to ensure that the tests are passing? Unfortunately my computer has broken down, so progress has stalled |
Member
Author
|
Test failures appear unrelated, so should be good |
KristofferC
pushed a commit
that referenced
this pull request
Jan 5, 2024
Since the values stored in the parent corresponding to the structural zeros of a tridiagonal matrix aren't well-defined, using it in `ldiv!` is a footgun that may lead to heisenbugs (one seen in https://buildkite.com/julialang/julia-master/builds/31285#018c7cc7-6c77-41ac-a01b-1c7d14cb1b15). This PR changes it to using the tridiagonal matrix directly in `ldiv!`, which should lead to predictable results, and be bug-free. The failing tests for #52571 pass locally with this change. (cherry picked from commit ef549ae)
KristofferC
pushed a commit
that referenced
this pull request
Jan 5, 2024
Since the values stored in the parent corresponding to the structural zeros of a tridiagonal matrix aren't well-defined, using it in `ldiv!` is a footgun that may lead to heisenbugs (one seen in https://buildkite.com/julialang/julia-master/builds/31285#018c7cc7-6c77-41ac-a01b-1c7d14cb1b15). This PR changes it to using the tridiagonal matrix directly in `ldiv!`, which should lead to predictable results, and be bug-free. The failing tests for #52571 pass locally with this change. (cherry picked from commit ef549ae)
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 uses broadcasting for operations like
A::UpperTriangular + B::UpperTriangularin case the parents areStridedMatrixes. Looping only over the triangular part is usually faster for large matrices, where presumably memory is the bottleneck.Some performance comparisons, using
-U1.011 ms (3 allocations: 7.63 MiB)559.680 μs (3 allocations: 7.63 MiB)U + U/U - U971.740 μs (3 allocations: 7.63 MiB)560.063 μs (3 allocations: 7.63 MiB)U + U1/U - U13.014 ms (9 allocations: 22.89 MiB)944.772 μs (3 allocations: 7.63 MiB)U1 + U14.509 ms (12 allocations: 30.52 MiB)1.687 ms (3 allocations: 7.63 MiB)U1 - U13.357 ms (9 allocations: 22.89 MiB)1.763 ms (3 allocations: 7.63 MiB)I've retained the existing methods as fallback, in case there's current code that works without broadcasting.