Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #178 +/- ##
==========================================
+ Coverage 86.63% 88.29% +1.66%
==========================================
Files 36 36
Lines 3920 3989 +69
==========================================
+ Hits 3396 3522 +126
+ Misses 524 467 -57 ☔ 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.
Note
Work in progress. This draft has not been reviewed in full yet and may still change. It is opened early to run CI.
This adds deflated restarting, GMRES-DR(m, k) (R. B. Morgan, SIAM J. Sci. Comput. 24, 20 (2002)), to
GMRESas a new optionndeflate(Morgan'sk). The defaultndeflate = 0keeps the current behavior.Restarted GMRES(m) discards the whole Krylov subspace at every restart. When the linear map has a few eigenvalues close to zero, every cycle has to rediscover them, and the residual can stagnate for thousands of applications. GMRES-DR keeps the
kharmonic Ritz vectors of smallest harmonic Ritz value across the restart, together with the residual. Their span is again a Krylov subspace, so the next cycle continues from an Arnoldi factorization of lengthk. This needs no extra application of the map and the samem + 1stored vectors.Motivation
PEPSKit's implicit CTMRG gradients solve a real linear problem with
GMRES(; krylovdim = 30), which stagnates at critical states. The table gives applications of the map to a relative residual of 1e-6 / 1e-8 for the operator of the critical Ising partition function, assembled densely (n = 1280 at χ = 16, n = 5120 at χ = 32). † means no convergence within 5000 applications.GMRES(; krylovdim = 30)GMRES(; krylovdim = 30, ndeflate = 10)Solves that converge within the first cycle are unchanged.
Demonstration
A 1000 × 1000 matrix with four eigenvalues of order 1e-3 and the rest in [1, 10]. Restarted GMRES(30) does not converge in 100 cycles, while GMRES-DR(30, 10) converges in 80 applications.
Script
Interface
0 <= ndeflate < krylovdim, checked in the keyword constructor. The docstring suggestsdiv(krylovdim, 3).maxiterstill counts cycles. Withndeflate > 0, every cycle after the first applies the mapkrylovdim - ndeflatetimes.a₀, a₁form,reallinsolveand everyOrthogonalizer. Since it is still aGMRES, it is also accepted asalg_rruleby theeigsolveandsvdsolvepullbacks (not tested withndeflate > 0). Log messages read "GMRES-DR" whenndeflate > 0.BlasFloatscalar type.ndeflateis appended as the last field. The five-argument positional constructorsGMRES(orth, maxiter, krylovdim, tol, verbosity)andGMRES{O, S}(...)are kept and setndeflate = 0, and the type parameters are unchanged. The only incompatibility is withGMRESobjects serialized by an older version.Implementation
The algorithm changes are in
src/linsolve/gmres.jl. The new field, constructors and docstring are insrc/algorithms.jl, andndeflateis passed through the keyword interface insrc/linsolve/linsolve.jl. Within a cycle the code is that ofGMRES, with the update of a column ofRmoved into a helper,_gmres_hessenbergcolumn!. The cycle can now start from a factorization of lengthkwith a general residual vector instead ofβ e₁. Whenndeflate > 0, a full and nonsingular cycle ends in_gmresdr_deflate!, and otherwise the restart is the one ofGMRES. WithG = a₀ + a₁ Handg = a₁ h_{m+1,m}:G + |g|² G⁻ᴴ eₘ eₘᵀ. Its Schur form (hschur!, reordered withpartitionschur!) gives an orthonormal basis for thendeflatevalues of smallest modulus. In real arithmetic, complex conjugate pairs are kept together.[-conj(g) G⁻ᴴ eₘ; 1], orthogonalized against that basis. It spans the orthogonal complement of the range of the (m+1) × m Hessenberg matrix, so it contains the GMRES residual._restorearnoldiform!, as in the Krylov–Schureigsolve. The basis is updated withbasistransform!and the factorization withshrink!.No dependency is added. The restart falls back to the one of
GMRESifGis singular or no vector can be kept, and if the implicit residual reachestolbut the recomputed one does not.Tests
New testsets in
test/linsolve.jl:reallinsolveand thea₀, a₁form. Without a restart the result andnumopsequal those withndeflate = 0.reallinsolve(including a real-linear map withconj).🤖 Generated with Claude Code