-
Notifications
You must be signed in to change notification settings - Fork 5
Pullbacks for Diagonal inputs
#156
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?
Conversation
|
FWIW there was some work done for this in the |
|
So you might be able to cannibalize part of that |
|
Ahh, thanks! let me first revisit that then :) |
|
Just grab whatever you need from there imo and I can rebase on top of this once it's merged |
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
de0c3b6 to
48fe1a9
Compare
48fe1a9 to
be7d543
Compare
| degeneracy_atol::Real = default_pullback_rank_atol(DV[1]), | ||
| gauge_atol::Real = default_pullback_gauge_atol(ΔDV[2]) | ||
| ) | ||
| ΔA_full = zero!(similar(ΔA, size(ΔA))) |
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.
Oof, this might become a lot of allocations for large diagonals... Is there no way for us to write a little more sophisticated rule that only computes the diagonal components of ΔA_full?
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.
Is A itself also Diagonal? In that case, I think we have ΔA = ΔD. The contribution from ΔV` should be completely off-diagonal.
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 think in these cases yes?
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.
So I had a better look at this, and I think I understand the point, i.e. since V is just a permutation matrix and we are assuming no degeneracies, we can't have level crossings and therefore the permutation matrix is constant.
However, actually using this information without allocating isn't that straightforward, since V isn't the identity and has to contain the permutation, but I don't necessarily have access to the permutation itself.
The main issue is that I have to compute V[:, ind]' \ ΔD * V' while keeping everything diagonal, and I'm not really sure how to do that. (maybe I can convert V into a permutation vector?)
If we end up allocating a new matrix and projecting back onto the diagonal afterwards, that doesn't help too much because that would be exactly the current implementation.
To be honest, I don't think we should be worrying all that much about performance here if we don't have to, since you could make the claim that if you want performance, maybe don't diagonalize a diagonal matrix?
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.
Yeah upon further reflection why don't we just merge this and if someone complains we can work on this more later
Ran into some issues in QuantumKitHub/TensorKit.jl#350, we are currently not testing pullbacks for$\Delta A$ , but we need an additional projection on the diagonal subspace.
Diagonalinputs, and apparently this is not working right now.The issue is that we want to in-place add to
I'm guessing similar issues would appear for other restricted input vector spaces, for now I'd be okay with this simple fix only for diagonal.
I'll try add a similar thing for the other pullbacks as well. In principle we can probably improve the performance a bit more but I'm not sure if this is worth the effort.