Skip to content

Iterator-based sweep solvers - #537

Draft
lkdvos wants to merge 10 commits into
mainfrom
ld-dmrg-iterators
Draft

lkdvos wants to merge 10 commits into
mainfrom
ld-dmrg-iterators

Conversation

@lkdvos

@lkdvos lkdvos commented Oct 9, 2026

Copy link
Copy Markdown
Member

Description

Restructures MPSKit's sweep-based solvers as iterators with a common shape. This is a pure refactor: results, logging and returned values are unchanged.

Every converted solver now has a state struct, and Base.iterate runs sweep!(it, state, Val(:right), iter) followed by sweep!(it, state, Val(:left), iter), then any finalize or error step. Finite sweeps take their sites from _sweep_ranges. Converted:

  • finite find_groundstate with DMRG/DMRG2 (DMRGState, sweep_converged)
  • finite approximate! with DMRG/DMRG2
  • propagator with DynamicalDMRG (NaiveInvert, Jeckelmann)
  • multiline approximate! and leading_boundary with IDMRG/IDMRG2
  • time_evolve/time_evolve!: one iteration is one time step plus finalize

Finite TDVP/TDVP2 timestep! is now a per-site local_update! plus a plain sweep, following BUG.

Smaller cleanups:

  • IterLog(::Algorithm) names logs after the algorithm type.
  • The redundant = it.state defaults on Base.iterate are removed; iterativesolvers.jl already provides the one-argument method.
  • state arguments are now typed, which avoids method ambiguities with the generic time_evolve iterator.

This gives the finite environment cache from ld-envs per-site hook points in DMRG, TDVP/TDVP2, BUG and dynamical DMRG. ld-envs will be rebased onto this branch; the rebase applies cleanly. It is also a step towards migrating these solvers to AlgorithmsInterface.jl, which will be a separate PR.

Verification

  • Equivalence against main: equivalence scripts ran the same cases on main and on this branch with fixed seeds, comparing with isequal. Compared: the raw MPS tensors, AlgorithmInfo fields, energies and returned values, every iteration log record and warning, and the arguments of finalize calls. All 168 cases are identical: 28 DMRG/approximate, 8 dynamical DMRG, 18 IDMRG and 114 TDVP/BUG/time_evolve.
    • Coverage includes converging and maxiter-limited runs, maxiter = 0, CBE and DMRG3S, nearest-neighbour and long-range models, real-valued initial states, time-dependent operators, and empty or single-point t_span.
    • The only differences were TensorKit cache-miss debug messages, which depend on whichever Julia session ran first, not on this change.
  • Tests: the groundstate, approximate, dynamical DMRG, statmech, timeevolution/*, states/*, fidelity susceptibility and anyonic braiding test files pass.
  • Ambiguities: Test.detect_ambiguities(MPSKit) is unchanged from main (135).

Checklist

  • Tests pass locally (relevant subset, see above)
  • Documentation updated, if this PR changes public API: no public API change
  • Runic formatter is run
  • Changelog entry added under [Unreleased] in docs/src/changelog.md

🤖 Generated with Claude Code

lkdvos and others added 10 commits October 8, 2026 17:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All sweep-based iterators now share DMRG's shape: `Base.iterate` runs
`sweep!(it, state, Val(:right), iter)` and `sweep!(it, state, Val(:left), iter)`,
with finite sweeps taking their sites from `_sweep_ranges`. The IDMRG
convergence measure is shared as `_center_change`. `IterLog(::Algorithm)`
names logs after the algorithm, and the redundant `= it.state` defaults
on `Base.iterate` are dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`bond_change` replaces the three copies of the center-bond convergence measure
(groundstate, multiline approximation and leading boundary IDMRG/IDMRG2). It
compares bond tensors of different dimension on their common subspace through
block views instead of isometry products, and sums the changes over the rows
of a multiline MPS, as IDMRG2 already did. The multiline approximation and
leading boundary searches now use the groundstate `IDMRGState`, dispatching
on its MPS and operator types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant