Skip to content
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

svdsolve rrule error when not all values are converged #110

Open
lkdvos opened this issue Dec 10, 2024 · 5 comments
Open

svdsolve rrule error when not all values are converged #110

lkdvos opened this issue Dec 10, 2024 · 5 comments

Comments

@lkdvos
Copy link
Collaborator

lkdvos commented Dec 10, 2024

In one of the PEPSKit testruns, we are running into an issue where the within the rrule for svdsolve, the eigensolver is failing to converge all requested values. In this case, the output vals and vecs are not of the expected length, leading to an out of bounds error.

The stacktrace is found here
The offending line is this line .
There is already a warning being thrown, but I guess we have to limit n to the size of the computed vals and vecs.

@Jutho
Copy link
Owner

Jutho commented Dec 10, 2024

I am confused, vals and vecs should always have length at least the requested length n, unless an invariant subspace is encountered, in which case KrylovKit has no way to further grow the Krylov subspace.

@lkdvos
Copy link
Collaborator Author

lkdvos commented Dec 10, 2024

Yeah, that's exactly what it's hitting. The log is a bit cryptic (blame Zygote), but this is relevant:

[ Info: CTMRG conv 4:	obj = +9.192864957180e-01	err = 4.1934293618e-11	time = 0.75 sec
┌ Warning: Invariant subspace of dimension 7 (up to requested tolerance `tol = 1.0e-8`), which is smaller than the number of requested eigenvalues (i.e. `howmany == 14`); setting `howmany = 7`.
└ @ KrylovKit ~/.julia/packages/KrylovKit/xccMN/src/eigsolve/arnoldi.jl:350
┌ Warning: `svdsolve` cotangent linear problem (7) returns unexpected result
└ @ KrylovKitChainRulesCoreExt ~/.julia/packages/KrylovKit/xccMN/ext/KrylovKitChainRulesCoreExt/svdsolve.jl:240
┌ Warning: `svdsolve` cotangent linear problem (14) returns unexpected result
└ @ KrylovKitChainRulesCoreExt ~/.julia/packages/KrylovKit/xccMN/ext/KrylovKitChainRulesCoreExt/svdsolve.jl:240

@Jutho
Copy link
Owner

Jutho commented Dec 10, 2024

Ok that is very weird. The different eigenvectors of the linear operator are supposed to be of the form

$$((\lambda_i - A)^{-1}\Delta_i , e_i)$$

with $e_i$ the length $n$ unit vector in the $i$ direction, and this for $i=1,...,n$. The initial vector is given by $(0, e_1 + e_2 + ... + e_n)$. That should have support in each of the eigenspaces.

I will try to reproduce this locally and investigate.

@lkdvos
Copy link
Collaborator Author

lkdvos commented Dec 10, 2024

Apologies that I dont have a MWE, I am not sure how to construct something for which the forward algorithm passes but the reverse fails. In any case, my guess wasn't that there necessarily is something wrong with KrylovKit, I think our tolerances were just not configured properly, but I would expect KrylovKit to throw a warning and move on, rather than throwing a boundserror

@Jutho
Copy link
Owner

Jutho commented Dec 10, 2024

These are the singular values of the forward calculation:

[0.5827127960663261, 0.013616701381118779, 0.013616700815086135, 0.00031674568674968046, 7.429999268923436e-6, 7.4299980267290364e-6, 2.0722724010027094e-7, 2.0722722219200433e-7, 2.0722720896899213e-7, 2.0540682979946611e-7, 5.767011119369518e-9, 5.767010235714964e-9, 4.053212060637025e-9, 4.053210898281218e-9]

Clearly, there are degeneracies here, likely due to the SU2 symmetry of the Heisenberg model. As always, Krylov method cannot guarantee to find this; I think it is pretty amazing that it can find these degenerate values so well. But this is why the reverse algorithm chokes; there the degeneracies do cause the issue of the smaller invariant subspace.

I will need to think a bit about this. The fact that you don't get a "gauge dependence" warning, probably means that the adjoint variables associated with the singular vectors of degenerate singular values are all linearly dependent, so that maybe you can just replace it with having to solve a single linear system, and thus in the auxiliary eigenvalue problem that you build, you could throw out the degenerate copies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants