Skip to content

Controlled Bond Expansion: randomized SVD approach#438

Merged
lkdvos merged 20 commits into
mainfrom
ld-cbe
Jul 1, 2026
Merged

Controlled Bond Expansion: randomized SVD approach#438
lkdvos merged 20 commits into
mainfrom
ld-cbe

Conversation

@lkdvos

@lkdvos lkdvos commented Jun 19, 2026

Copy link
Copy Markdown
Member

This is a WIP implementation of a CBE-like expansion scheme based on randomized SVD.
The long story short is that instead of a full twosite (OptimalExpand) -based approach, we can sketch out this update to select the expansion directions.
Mainly I'm still struggling slightly with committing to an interface, and checking what goes where.
I'm somewhat convinced that the changebond! (as opposed to changebonds!) abstraction for doing a single expansion on a bond is probably good, but still struggling a bit to see if I want to default this into DMRG (and TDVP), or get a dedicated CBE_DMRG algorithm for it.
Interestingly, I think I've set it up in such a way that the various expansion schemes can be used interchangibly, so it is quite modular.

The main source of complexity/messiness is mostly that the FiniteMPS structs and environments are very untransparant about what they do, so trying to reuse functionality involves a lot of assumptions on which tensors exactly are where and which ones are used.
It would be nice to revisit that at some point, but I also just don't have the time to actually go ahead and do this...

Still to do:

  • Implement for TDVP
  • Clean up DMRG implementation
  • Verify interaction with symmetries and block selection / oversampling
  • Check this works for density matrices
  • correctly rebase with timeroutputs

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Your PR no longer requires formatting changes. Thank you for your contribution!

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.28571% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/changebonds/randexpand.jl 50.00% 18 Missing ⚠️
src/algorithms/groundstate/dmrg.jl 69.56% 7 Missing ⚠️
src/states/orthoview.jl 87.50% 3 Missing ⚠️
src/algorithms/changebonds/changebonds.jl 80.00% 2 Missing ⚠️
src/algorithms/changebonds/optimalexpand.jl 97.43% 1 Missing ⚠️
src/algorithms/changebonds/sketchedexpand.jl 98.43% 1 Missing ⚠️
src/algorithms/timestep/tdvp.jl 90.90% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/MPSKit.jl 100.00% <ø> (ø)
src/algorithms/toolbox.jl 96.39% <100.00%> (-0.02%) ⬇️
src/utility/utility.jl 59.76% <100.00%> (+0.48%) ⬆️
src/algorithms/changebonds/optimalexpand.jl 98.73% <97.43%> (-1.27%) ⬇️
src/algorithms/changebonds/sketchedexpand.jl 98.43% <98.43%> (ø)
src/algorithms/timestep/tdvp.jl 83.15% <90.90%> (+0.39%) ⬆️
src/algorithms/changebonds/changebonds.jl 91.30% <80.00%> (-8.70%) ⬇️
src/states/orthoview.jl 88.88% <87.50%> (+0.79%) ⬆️
src/algorithms/groundstate/dmrg.jl 91.96% <69.56%> (-4.88%) ⬇️
src/algorithms/changebonds/randexpand.jl 64.38% <50.00%> (-18.95%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos
lkdvos marked this pull request as ready for review June 30, 2026 15:51
lkdvos and others added 20 commits June 30, 2026 16:17
Reconcile CBE with main after rebase:
- migrate CBEDMRG/SketchedExpand to the 3-arg environments(ψ, H, ψ) API
  (#436 removed the defaulted operator-environments form)
- instrument CBEDMRG/cbe_sweep! with TimerOutputs (expand / AC_eigsolve /
  svd_trunc / sweep / finalize), matching the #431 DMRG/DMRG2 style

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Restore the `isnothing(alg.alg_expand)` guard around `changebond!` in the
finite TDVP sweep. It was dropped together with the verbosity `withlevel`
wrapper during cleanup, so `TDVP()` (default `alg_expand = nothing`) called
`changebond!(..., nothing, ...)` — which has no method — erroring for any
`AbstractFiniteMPS` (e.g. WindowMPS evolution with an InfiniteMPOHamiltonian).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lkdvos
lkdvos enabled auto-merge (squash) July 1, 2026 00:00
@lkdvos
lkdvos merged commit 5206b74 into main Jul 1, 2026
30 checks passed
@lkdvos
lkdvos deleted the ld-cbe branch July 1, 2026 09:36

@leburgel leburgel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too slow to review before this was merged, but I'm giving it anyway just in case there's some things we want to change after the fact.

Everything looks great, but I was wondering: why not do this for infinite MPS right away as well? Is there some obstruction to this?

Comment thread src/algorithms/changebonds/changebonds.jl
Comment thread src/algorithms/changebonds/changebonds.jl
Comment thread src/algorithms/changebonds/optimalexpand.jl

# select the dominant directions in the complement of the current state
g2 = adjoint(NL) * AC2 * adjoint(NR)
_, _, Vᴴ = svd_trunc!(normalize!(g2); trunc = alg.trscheme, alg = alg.alg_svd)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a reminder, should we add a rename trscheme -> trunc to the set of breaking changes for the next breaking MPSKit release?

Comment thread src/algorithms/changebonds/optimalexpand.jl
Comment thread src/algorithms/changebonds/randexpand.jl
Comment thread src/algorithms/changebonds/sketchedexpand.jl
Comment thread src/algorithms/timestep/tdvp.jl
@lkdvos

lkdvos commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

I'll open a follow-up PR to adress your comments.

  • I think the one about transposed/permuted tensors is not really viable since there is some fundamental asymmetry in how our MPS tensors are structured, and I really do want to avoid every single unnecessary transpose, since this unfortunately all shows up in non-abelian symmetric cases.
  • Considering the language, happy to change.
  • For the trscheme -> trunc, I agree, but would want to evaluate slightly more in-depth: it might actually be reasonable to just have a single field for the decomposition algorithm + truncation scheme together, since that is anyways how they are used and allows algorithms that can't easily be split like that. I want to keep the option of having these as keyword arguments for sure, for convenience and clarity, but then internally store them differently.

@lkdvos

lkdvos commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

Before I forget: the reason why I can't do this for the infinite case directly is that I'm not sure it really works out so easily: it gives the same kind of issues as we have on the boundaries for IDMRG2, which I'm not sure I want to introduce in general (although we should probably investigate if it is possible). The issue for VUMPS is that adding zero-directions creates a state that is hard to gauge (I think), so the canonicalization step might fail.
TLDR - needs a bit more investigation, and I definitely already wanted to get this in.

lkdvos added a commit that referenced this pull request Jul 11, 2026
Incorporate post-merge review feedback (docstring/wording only):
- changebond docstring: drop inaccurate "in place", "enriched" -> "expanded"
- OptimalExpand: reword "does not alter the state" -> "state-preserving"
  to avoid implying out-of-place operation
- TDVP: "enriches" -> "expands" the bond

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

3 participants