Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #173 +/- ##
==========================================
- Coverage 88.47% 86.70% -1.78%
==========================================
Files 36 36
Lines 3965 3933 -32
==========================================
- Hits 3508 3410 -98
- Misses 457 523 +66 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
With
alg_rrule = GMRES()orBiCGStab(), thesvdsolveandeigsolvereverse rules solve one linear problem per kept vector on the whole space, projecting out only that vector (bordering on it, foreigsolve). The other kept vectors stay in the problem, where the operator has eigenvalues ±σⱼ - σᵢ (svdsolve) or λ̄ⱼ - λ̄ᵢ (eigsolve): small when kept values are close, and of both signs. For more than a few kept vectors, restarted GMRES then does not converge and the gradient is wrong (reproducers below).This PR takes the kept vectors out of the linear problem:
svdsolve: the linear problem is posed on the orthogonal complement of all kept singular vectors, where its spectrum σᵢ ± sⱼ is positive for discarded sⱼ < σᵢ, and the components along the other kept vectors follow in closed form from their 2 × 2 blocks (withsafe_invfor degenerate σⱼ, as in theArnoldirule).eigsolve: the orthogonal complement of the kept eigenvectors V is invariant under fᴴ, also for non-Hermitian f, with only the discarded eigenvalues there. Writing w = V a + y with y ⊥ V, the kept block (V's Gram matrix, as in theArnoldirule) follows in closed form and only y needs a linear solve, which no longer needs the border. This coversLanczosandArnoldialike.The gauge and convergence warnings are unchanged;
eigsolve's "returns unexpected result" check is removed, since the border multiplier is now zero by construction. In fivesvdsolvetests atSTARTSTOP_LEVELthe cotangents lie in the span of the kept vectors, so the linear problem on the complement is trivial and GMRES logs one message per vector instead of two; their expected log patterns are updated.test/ad/svdsolve.jl(220) andtest/ad/eigsolve.jl(618) pass.The reproducers below (N = 400, 10 kept vectors, GMRES at
tol = 1e-10) compare the gradient of a gauge-invariant loss with the one through the densesvd/eigen:mastersvdsolveeigsolve, Hermitian (Lanczos)eigsolve, non-Hermitian (Arnoldi)On
mastereach case also warns that some of the cotangent linear problems did not converge (shown once each below; the scripts evaluate the gradient twice).svdsolve
On
master:With this PR:
eigsolve, Hermitian
On
master:With this PR:
eigsolve, non-Hermitian
On
master:With this PR: