Skip to content

v0.2.2: correction vectors, MINRES, RPA column solve; residual checks and a size-aware get_green_krylov cutoff - #84

Merged
TiagoAntao2 merged 13 commits into
mainfrom
fixes
Nov 21, 2026
Merged

TiagoAntao2 merged 13 commits into
mainfrom
fixes

Conversation

@mousanouar

Copy link
Copy Markdown
Member

New solvers and self-checking linear solves, prepared as v0.2.2: Project.toml is bumped and the CHANGELOG section is dated, so merging this PR is the release, which is then registered from the merge commit. The v0.2 API is unchanged. Two entries change numbers, both in get_green_krylov; each is under Changed results in CHANGELOG.md with the keyword that restores the old behaviour. The residual checks are on by default: they add a warning, and some time, to solves that ran silently before.

Changed results

  • get_green_krylov starts from a random state (keywords start, rng).
    • The old start, |I⟩⟩ with a 2-vector Krylov expansion, stalled on a short-ranged G: the two-site sweeps keep the rank their start spans. At default settings open chains were off by 6–20 % whenever ω lay outside the band (from 2^6 sites with an impurity), with nothing to show it.
    • The start is now |I⟩⟩ + 0.1·(a random MPS of bond dimension 8) with an 8-vector expansion, from a Xoshiro(1) created at each call, so results do not depend on the global RNG. start = :identity restores the old one.
    • Cost: the first sweep runs at the bond dimension of the start, up to 30× longer where G has a small one.
    • The bubble with GF_method = :krylov, and every RPA driver on it, moved too; krylov_start = :identity restores the old start there.
    • Regenerated: 3 Krylov cases of test/data/dynamics_golden.jl (by ~1e-14) and 5 of test/data/rpa_golden.jl (forwarding cases at deliberately unconverged settings).
  • get_green_krylov: the default cutoff scales with the system beyond 2^10 sites (cutoff = nothing: 1e-8 up to 2^10 sites, 1e-8·2^10/D beyond for D sites, never below 1e-14).
    • The cutoff is relative to ‖|G⟩⟩‖², which grows as D, so a fixed 1e-8 truncated away what sets one row of G apart from the others: an impurity site was 2.6 % off from 2^14 sites, and from 2^20 the end rows of a clean open chain came back as bulk rows (G₁₁ 50 % off).
    • With the new default, open chains of 2^14–2^30 sites, clean and with an impurity, give the chain ends, the middle bond and the impurity site to 4e-6 or better, in and outside the band.
    • Results up to 2^10 sites are unchanged and no golden case moves. cutoff = 1e-8 restores the old behaviour at any size.

Changed

  • get_green_krylov and the RPA Dyson solve check their residual, on by default (residual_warn, rpa_residual_warn, krylov_residual_warn; Inf skips the check and its cost). return_info = true returns the residuals with the result.
    • For G the warning is on ‖G(z − H) − 1‖_F (threshold 0.1), which bounds every row. The residual relative to ‖|I⟩⟩‖ = √D is a root mean square over the rows and cannot show a wrong row on a large system: it was 8e-4 for the 2^20-site chain above.
    • For the Dyson solve the threshold is 1e-2 on the relative residual. Near the RPA instability the default cutoff = 1e-8 limits χ to about κ·1e-5 (κ the condition number of I − Π₀V), and the check now says so. The default cutoff is unchanged.
    • The residuals come from inner products, with ⟨Ax|Ax⟩ contracted one tensor at a time. The value is an upper bound that includes its own rounding floor, and it is evaluated exactly where that floor would decide the comparison. A check that would hold more than 2^27 numbers skips itself with one @info.
  • Dependencies: ITensorMPS 0.3.26 to 0.3.44 (was 0.3.16). The new solvers pass their own local solver to linsolve; the suite was run at both ends.

Added

  • MINRES as the local solver of get_green_krylov (solver = :minres, Hermitian H): the same G in fewer products, several times fewer at small η.
  • Correction vectors (src/solvers/CorrectionVector.jl, a new section of the Solvers page): the resolvent of one probe, x = (ω + iη − H)⁻¹|b⟩, at a resolution set by η instead of a number of KPM moments.
    • get_correction_vector, with a Krylov seed, a residual check and residual-expansion rounds.
    • get_ldos_cv and get_exciton_ldos_cv: the LDOS of a site or of the exciton contact probe along a frequency grid, per unit physical energy.
    • refine_bound_state: energy and weight of an isolated level by Rayleigh-quotient iteration. converged requires a weight that does not change with η, which a continuum cannot give.
  • get_rpa_susceptibility_column: one column χ|j⟩ on the L sites of Π₀ instead of the whole χ on the 2L-site register. On a 256-site chain up to U = 0.999 U_c: χ_jj to 1e-7 or better in 1–4 s, against minutes.
  • The Wynn-accelerated RPA warns near the instability, from an estimate of the spectral radius of VΠ₀. The returned values are unchanged.

Known limits

  • get_green_krylov resolves single rows up to about 2^38 sites. Beyond, a row is below double precision next to ‖|G⟩⟩‖² and the chain ends are lost again; the check warns. Local quantities at that size are for the correction vectors.
  • At default settings the rows of G with the largest error are off by a few 1e-3 of their norm, while diagonal elements are right to 1e-5 or better. solver = :minres or a tighter cutoff lowers it.
  • get_bubble_mpo(GF_method = :krylov) keeps its fixed krylov_cutoff = 1e-8, on a register of D² states. krylov_cutoff = nothing opts into the size-aware default; the default there was not measured and is left alone.
  • get_green_krylov still needs qubit sites (a kagome or Lieb sublattice index throws, as in v0.2.1).

Testing

The feature commits were reviewed twice before this PR; the five commits before the release commit are the fixes, with tests that pin them.

  • Full suite with the golden suites and GPU tests (Julia 1.12.3, Windows, RTX 4060): all 19,568 tests pass, including the 4,127 golden tests, unchanged by the fixes.
  • CI reproduction, Pkg.test() with CI=true (golden suites and GPU tests skipped, --check-bounds=yes): Julia 1.10.13, 15,401 pass; Julia 1.12.3 with ITensorMPS pinned at 0.3.26, 15,401 pass.
  • Docs build (makedocs, no warnings): passes.
  • Not run locally: Julia 1.11 and pre.

After merging

Register v0.2.2 from the merge commit, as for v0.2.1: the Registrator bot command as a comment on that commit, not on this PR, with the release notes in the same comment. TagBot then tags the release. The CHANGELOG section is dated 2026-11-18, the day the release commit was made.

🤖 Generated with Claude Code

mousanouar and others added 13 commits November 16, 2026 18:58
KrylovKit has no MINRES, so every local problem of the linsolve sweeps was
solved by restarted GMRES. For Hermitian H each local problem (z - H_eff)x = b
is a complex shift of a Hermitian matrix: MINRES solves it by a three-term
recurrence without restarts, giving the same G in fewer products at small eta.

Opt-in keyword `solver` (default :gmres, unchanged). With :minres the operator
is I (x) H^T and z goes into linsolve's coefficients; a non-Hermitian H throws
an ArgumentError (from |H - H^dag|/|H|). Tested against exact inverses in
test/krylov_minres.jl; golden_dynamics.jl (GMRES path) passes unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The start was |I>> with a 2-vector global Krylov expansion, and the two-site
sweeps keep the rank their start spans: on a short-ranged G (omega outside the
band, or eta = 0.1 on 2^10+ sites) open chains came out 6-20 % off, the G of the
bulk without the end or impurity corrections, with nothing to show it.

The default start is now |I>> + 0.1 * (random MPS, chi 8) with an 8-vector
expansion (keywords `start`, `rng`; `start=:identity` restores the old one;
the RNG is a Xoshiro(1) created per call). The same cases reach 1e-11 (clean
chain) or the floor of the cutoff (impurity chain). After the sweeps the
relative residual is computed from exact inner products; above `residual_warn`
(1e-2) a warning says G is not converged, and `return_info=true` returns it.

Changed results: dynamics golden cases krylov_green_raw, _tbhamiltonian,
_ishermitian_flag (~1e-14) and the five Krylov cases of the RPA golden file,
which pin keyword forwarding at unconverged settings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rpa_from_bubble_diag computes the relative residual ||(I - Pi0 V)chi - Pi0|| /
||Pi0|| of its solve from exact inner products and warns above `residual_warn`
(1e-2); `return_info=true` returns (; chi, residual, maxlinkdim).
get_rpa_susceptibility and get_magnon_susceptibility pass `rpa_residual_warn`
and `return_info` through. Near the instability the default cutoff limits chi
to about kappa * 1e-5: at U = 0.999 U_c on a 32-site chain (kappa = 1e3) chi is
off by 5e-3 with a residual of 5e-2, which now warns; rpa_cutoff = 1e-12 gives
1e-7. The default cutoff and every returned value are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on_ldos_cv, refine_bound_state

The resolvent of one probe state, x = (omega + i eta - H)^-1 |b>, by
ITensorMPS.linsolve with the safeguards worked out in the resolvent and
inversion studies: a Krylov seed b + sum_k H^k b (the plain probe start can stall
on two-particle registers), sweeps until G = <b|x> stops moving, the residual
from exact inner products, and up to `rounds` residual expansions when it is
above `rtol`. Warm starts (`x0`), continuation in eta (`eta_path`) and the MINRES
updater are available.

get_ldos_cv / get_exciton_ldos_cv scan a frequency grid with warm starts and
return the LDOS per unit physical energy with a residual per point;
refine_bound_state gives the energy and probe weight of an isolated level by
Rayleigh-quotient iteration (to ~eta^2 of its last step).

Tested against dense resolvents (impurity chain, exciton contact probe), a
forced failure that must be flagged, and the impurity bound level. The probe-start
stall needs registers too large for CI (1D, L = 20 in the study), so it is not
reproduced in the test. Docs: a "Correction Vectors" section on the Solvers page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ility

get_rpa_susceptibility_column(H, MPOV, omega, j) solves (I - Pi0 V)x = Pi0|j> on
the L sites of Pi0 for one column of chi, with the bubble keywords and defaults
of get_rpa_susceptibility and tighter solve defaults (40 sweeps, cutoff 1e-12),
plus the residual check of the Dyson solve. In the inversion study one column
gave chi_jj to 1e-7 - 2e-6 at condition number 1e3 in about a second, against
minutes for the whole chi.

The Wynn drivers estimate the spectral radius of V Pi0 from the norms of the
Neumann terms and warn above 0.9, where the K_max = 6 estimate was 1-90 % off.
Returned values are unchanged (RPA goldens pass as they are).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stay

The relative cutoff is size-blind and sets the accuracy floor of G (and of
the RPA χ near the instability); the residual checks report it. A comment
at each default says so, to keep it from being "fixed" silently.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The MINRES solver and the correction vectors pass their own local solver to
ITensorMPS's linsolve, and random_mps(rng, ...) seeds the new start. The
suite passes at 0.3.26 (CI mode, Julia 1.12) and 0.3.44; nothing below was
tested. The cap below 0.3.45 stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n, size guard

The residual behind the checks of get_green_krylov, the correction vectors and the
RPA Dyson solves came from inner products whose terms cancel to ~sqrt(eps) of the
largest, with the result clipped at zero. That floor grows with |x| (as 1/eta for a
resolvent, with an energy offset, with the condition number of a Dyson solve), so a
wrong vector could read as residual 0 and the exact one as 0.04 (0.2.2 review:
numerics 2, API F7).

_linsolve_residual now returns (; residual, floor, method):
- the residual is an upper bound that includes the rounding floor of the
  evaluation, sqrt(32 eps S), S = (|a0| + |a1| sigma)^2 |x|^2 + |b|^2 with sigma the
  rms singular value of A (measured: at most 5.8 eps S over correction vectors at
  eta = 1e-2..1e-8, Green's functions and Dyson systems up to condition number 1e5);
- where the floor leaves the comparison with the threshold open, the residual is
  read off the orthogonality centre of the direct sum of its terms (exact to ~eps);
- <Ax|Ax> is contracted one tensor at a time, chi^3 w^2 + chi^2 w^3 per site instead
  of the chi^3 w^3 of inner(A, x, A, x) (API F1), and the check is skipped with one
  @info when it would hold more than 2^27 numbers.
The return_info tuples and get_correction_vector's result gain residual_floor.

Also: comparisons that a NaN residual cannot pass silently (numerics 7); a zero
right-hand side of the Dyson solves returns zero with residual 0 instead of NaN or a
false warning (API F12); the Krylov seed of the correction vectors stops when
H^k b = 0 instead of dividing by zero, and the expansion rounds no longer overflow
at maxdim = typemax(Int) (numerics 5).

CHANGELOG: the two residual checks move from Added to Changed (they are on by
default and have a cost), with the measured residual 3e-2 of the U = 0.999 U_c case.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…residual

The cutoff of the sweeps is relative to the squared norm of vec(G), which grows as
the number of sites D, so the fixed default 1e-8 weighed D times more next to one
row of G and truncated away what sets that row apart: an impurity site 2.6 % off
from 2^14 sites, and from 2^20 the end rows of a clean open chain returned as bulk
rows (G_11 50 % off). The residual check added in this release could not see it: it
was relative to the norm of vec(1) = sqrt(D), so one wrong row cost it 1/sqrt(D),
8e-4 at 2^20 sites against a threshold of 1e-2 (0.2.2 review, numerics 1).

- cutoff defaults to nothing: 1e-8 up to 2^10 sites (unchanged), 1e-8 2^10/D beyond,
  never below 1e-14 (under which the expansion of the start truncates nothing and
  its memory grows without bound, seen at 2^36 sites).
- The warning is on the absolute residual |G(z - H) - 1|_F, which bounds every
  row's, with residual_warn = 0.1; return_info adds residual_abs. Against dense
  inverses at 2^10 and 2^12 sites it was 1-8 times the relative error of the worst
  row. Beyond ~2^32 sites, where the rounding floor of the inner products nears the
  threshold, the residual is evaluated exactly.
- The random part of the start keeps its absolute weight 0.1 (a tenth of one row at
  every size). Scaling it with sqrt(D), as the review suggested, was tried and made
  the chain ends bulk rows from 2^20 sites: it outweighs the rows it is there for.
  What the review saw (the part dropped by the truncated sum beyond ~2^33 sites) is
  fixed by a direct sum beyond 2^30 sites; the start is unchanged below.

Measured at the default settings on open chains, clean and with an impurity, at four
(omega, eta) in and outside the band, against analytic elements: chain ends, middle
bond and impurity site to 4e-6 or better from 2^14 to 2^30 sites, no warning; to
1e-4 at 2^34-2^36 (0.3-2 % at a band edge, with the warning); chain ends lost at
2^40, with the warning (single rows are below double precision there). Scripts and
logs: examples/nontracked/fixes_checks/green_krylov_sizeaware_cutoff*.

The dynamics and RPA golden suites are unchanged (718 tests). New test at 2^20
sites; docstring: x0_mpo gets no basis expansion (numerics 5), the Hermiticity test
of solver=:minres is size-blind (numerics 6).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…s, stray keywords

From the 0.2.2 review (numerics 3; API F4, F8, F9, F10, F14), before the names
become permanent:

- refine_bound_state: `converged` was the residual flag of the last linear solve
  only, so a start in a continuum returned converged = true on an energy still
  moving by 4e-3 per step. It now also asks that the last move of the energy
  (returned as energy_step) be within the eta before the last, which holds once
  the level is resolved at that eta. A stray `eta` keyword, which overrode every
  step of eta_steps while the history reported the scheduled values, is an
  ArgumentError, and so is an empty eta_steps (it was a BoundsError). The docstring
  no longer claims that the history shows an unresolved pair of levels: it does
  not; the result is their mean energy and summed weight.
- get_ldos_cv, get_exciton_ldos_cv: the per-frequency bond dimensions are
  `maxlinkdims`, the package's name for such a vector; a single frequency
  omega::Real returns scalars (it returned 1-element vectors, where the KPM
  siblings return a scalar); `x0`, which replaced the warm start at every
  frequency, is an ArgumentError.
- Docstrings: the conversion to the KPM units holds for the default kernel
  (1/H.scale with :hodc); why maxiter is 30 here and 600 in get_green_krylov;
  mpsexciton lives in core/Utils.jl.

Tests: the continuum case, the refused keywords, the scalar methods, the sum rules
of the CV and KPM LDOS on one grid (units), and get_ldos_cv on a spinful chain.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ames, Wynn estimate

From the 0.2.2 review (API F2, F3, F5, F10, F11):

- get_bubble_mpo, get_rpa_susceptibility and get_rpa_susceptibility_wynn take
  krylov_start and krylov_residual_warn and pass them to get_green_krylov. Every
  driver on the Krylov bubble had changed results with the new start and gained
  the residual check of that solve, with no keyword to restore the first or
  silence the second. krylov_cutoff also accepts nothing (the size-aware default
  of get_green_krylov); its default stays 1e-8.
- get_rpa_susceptibility_column builds the operator at min(rpa_cutoff, 1e-14), as a
  direct sum: at the solve cutoff it was off by sqrt(cutoff), which set the accuracy
  of the column. On a 256-site chain up to U = 0.999 U_c: chi_jj to 1e-7 or better,
  the column to 1e-6 (examples/nontracked/fixes_checks/rpa_column_accuracy.jl).
  The new function takes the ASCII names `eta` and `fermi` (the Greek names of the
  bubble are accepted too, not both), checks the column index before computing the
  bubble, and its docstring says that the bubble is recomputed at each call.
- Wynn series: the estimate sqrt(|T_K|/|T_{K-2}|) of the spectral radius is from
  below (1-6 % low at K = 6, 25-40 % at K = 2), so K_max = 2 and 3 could not warn
  at all. The thresholds are 0.85 for K_max >= 4 and 0.6 below, and the message
  calls it a lower bound. The returned values are unchanged.

Tests: a non-symmetric V, so that a column is told from a row (with the diagonal V
of the old test a transposed solve passed); j as an MPS, return_info, the ASCII
keywords, K_max = 1 and 2, the two Krylov-bubble keywords. The column tolerance is
1e-9 where it was 1e-5.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…r scale, Wynn thresholds

A second review, of the four fix commits (e633d20..e41090d), found that three of
them did not do what they claimed. Report and scripts:
examples/nontracked/fixes_checks/review_022/rereview/.

- refine_bound_state: for x = (w + i eta - H)^-1 b the Rayleigh quotient gives
  E - w = eta Re G / Im G exactly, about eta in a continuum whatever w, so the new
  rule "the last energy step is within the eta before the last" passed at any
  start: converged = true at 2^20 sites in the middle of the band. `converged` now
  also asks for a stationary weight over the last step: it is independent of eta on
  a level and proportional to eta in a continuum, and the measured change must be
  within a tenth of the continuum's. A single step, or two equal eta at the end,
  is never reported as converged.
- Rounding floor of the residual: its scale used the rms singular value of A, which
  averages a strong local term away (one bond of 1e3-1e5 on a chain: rounding up to
  2e4 eps S against the 32 assumed; an upper bound 15 % low; a converged vector
  reported at 2.5e-2). The scale is now the larger of the rms value and a
  power-iteration estimate of the norm of A (6-8 products on a bond-16 MPS, fixed
  seed), and a negative sum of the inner products beyond the floor raises the floor
  to it. The reviewer's cases now all resolve (b1_after_fix.log).
- The exact evaluation had a hard bond limit of 2000 and no memory bound (13 GB for
  a 60-site register near it). It is now bounded by the same 2^27 numbers as the
  inner-product check, and the docstrings state the condition.
- Wynn warning: the thresholds were calibrated at K = 2 and 6 on 2^5-2^9 sites; on
  1024-4096 sites the estimate reads lower, and K_max = 4 warned only from
  rho = 0.99. One threshold per K_max (0.55, 0.70, 0.77, 0.81, then 0.83), from the
  large-system ratios, with the calibration range stated.
- Column solve: a bubble that annihilates |j> leaves a right-hand side of ~1e-15,
  not exactly zero, and still gave residual 0.2 and a warning. The test is now
  relative to |Pi| |b|. A Bool column index is refused, and a spinless H in the
  magnetic channel is refused as such before the index is checked.
- get_ldos_cv, get_exciton_ldos_cv take any collection of frequencies again (the
  AbstractVector annotation refused tuples); the scalar method stays. The warning
  of get_green_krylov names the krylov_* keywords of the RPA drivers.

Tests that pin these: refine_bound_state in a continuum of 2^16 sites; the exact
path on the vectorized operator (asserted, where the old test only said so); the
norm estimate on one strong site among 2^20; a default get_green_krylov at 2^36
sites (direct-sum start, exact residual); the column at 128 sites, where the old
operator gave 4e-7 (the 32-site case passed on the old code); a bubble that
annihilates |j>; K_max = 2..5; krylov_cutoff = nothing.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
@TiagoAntao2
TiagoAntao2 merged commit 27880d3 into main Nov 21, 2026
3 of 4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants