-
Notifications
You must be signed in to change notification settings - Fork 6
Error fixes for #81 #82
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
src/compressor.jl
Outdated
| try | ||
| all(j -> iszero(K[first(irange), j]), jrange) && | ||
| all(i -> iszero(K[i, first(jrange)]), irange) || | ||
| @warn "aca possibly failed on $irange × $jrange" | ||
| catch | ||
| @warn "aca possibly failed on $irange × $jrange" | ||
| end |
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 would rather not have a try/catch block in this performance critical part of the code. Why is it needed? Is there a way to handle the exceptional case without running into the exception (I don't remember what the exception was).
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.
Hey @maltezfaria---this is bullet point 1 above. Both of those all statements will throw an error when you are doing a low-rank approximation of a MulLinearOp. This seems to come up when you are factorizing a matrix and you are re-compressing a matrix product/sum where one of the blocks is basically all zeros.
Maybe an alternative fix would be to have a type-level check? Like, something that does the all(...) checks when K isa KernelMatrix and doesn't attempt to do so when K isa MulLinearOp or something?
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.
Just pushed up a commit to change to that if-else check.
Another thing to consider here, though, is what to do about those warnings. If you run the example I have above with the identity matrix, you get a warning for every single admissible block. I'm not really familiar with ways that the ACA can fail in the sense of failing to select a pivot when the approximation isn't machine-precision accurate, so maybe that is possible. But maybe some less noisy way of communicating that would be good.
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.
Would adding maxlog=1 to @warn resolve the "communication issue"? At some point I should look closer into the problem to understand the proper way to handle it, but since I won't have time right now perhaps we can settle for this hacky alternative?
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.
Good idea! Done.
|
Ah, and one other comment here---would you mind merging #81 and tagging a release? At the moment, as I tinker with this in various codebases I am having issues with the |
maltezfaria
left a comment
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.
LGTM, thanks!
Minor suggestions in case you want to fix it before the PR is merged (feel free to ignore them as well):
- minor version bump
- add
maxlogto the@warn
src/compressor.jl
Outdated
| if K isa KernelMatrix | ||
| all(j -> iszero(K[first(irange), j]), jrange) && | ||
| all(i -> iszero(K[i, first(jrange)]), irange) || | ||
| @warn "aca possibly failed on $irange × $jrange" |
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.
Do you want to append maxlog=1 here to avoid the message appearing multiple times? Maybe modify the message to say that further instances of this issue will be silenced?
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.
Done, thanks!
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #82 +/- ##
==========================================
- Coverage 76.54% 76.43% -0.11%
==========================================
Files 14 14
Lines 1475 1477 +2
==========================================
Hits 1129 1129
- Misses 346 348 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@maltezfaria, thanks again! One other comment here for potential future stuff. I wonder if an elegant way around all of these warnings would be to have a struct like struct RankZeroMatrix
n::Int
m::Int
endand then define a few special methods for Maybe I'm not entirely understanding the problem, but that's the first idea that comes to mind for me! |
I need to understand the issue better, but why not simply have an |
Hey @maltezfaria---
I got around to taking a look at what's going on here. The following code was hitting two edge cases:
getindexin the check to decide whether to throw a warning. But since thatgetindexthrows an error, that wasn't working. For the moment I've just wrapped it in a try-catch, but I assume you'll have a more thoughtful suggestion about how to do that check._mul_dense!routine was missing routines for adjoints, so I just added that to the branches onAdata. Maybe this one is actually a decent solution? But like above, very happy to do something else if you think it is more suitable.Thanks again for the great package!