Add two-site DMRG for tree tensor networks#122
Open
mtfishman wants to merge 4 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #122 +/- ##
==========================================
+ Coverage 80.35% 81.45% +1.09%
==========================================
Files 13 17 +4
Lines 738 965 +227
==========================================
+ Hits 593 786 +193
- Misses 145 179 +34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds `dmrg`, a two-site DMRG ground-state solver for trees: the operator is a `TensorNetworkOperator`, the exact projected-Hamiltonian environments live in a `MessageCache` of `NamedDimsArrays` operators, and the driver follows the layered `AlgorithmsInterface` structure used by `beliefpropagation` and `apply_operators`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move `dmrg` to the top of `dmrg.jl` so the file reads entry-point first, matching `apply_operators.jl`. Split the generic pieces into their own files: `tensornetworkoperator.jl`, `quadraticformnetwork.jl`, `orthogonalize.jl`, and `nameddimsarrays_extensions.jl` (the temporary `VectorInterface` methods on `AbstractNamedDimsArray`). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The DMRG code predated the INN v0.7 upgrade. Move it onto the released stack: named arrays and operators now come from ITensorBase rather than NamedDimsArrays (state, operator, apply, lazy, dimnames, replacedimnames, uniquename), the QR and SVD factorizations go through MatrixAlgebraKit (qr_compact, svd_trunc), and the tensor network types are ITensorNetwork and AbstractITensorNetwork. The VectorInterface methods that KrylovKit needs were dropped here and moved into ITensorBase (ITensor/ITensorBase.jl#186), so the Aqua piracy check is back to the full default.
mtfishman
added a commit
to ITensor/ITensorBase.jl
that referenced
this pull request
Jun 25, 2026
## Summary Implements `VectorInterface` for `AbstractITensor` so an ITensor works directly as a vector in iterative solvers like `KrylovKit.eigsolve`, which drive their Krylov vectors through `VectorInterface` and whose generic `AbstractArray` fallbacks are not name-aware. This covers the full interface (`add`, `scale`, `zerovector`, their in-place `!` and maybe-in-place `!!` variants, `inner`, and `scalartype`), with the in-place methods implemented via broadcasting and `zerovector` going through a new in-place `TensorAlgebra.zero!` method for `AbstractITensor`. The tree-DMRG work in ITensor/ITensorNetworksNext.jl#122 had been carrying a partial set of these downstream as type piracy on the named-array type, so this moves them to where the type lives.
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.
Summary
Adds
dmrg, a two-site DMRG ground-state solver for tree tensor networks, built on the same layeredAlgorithmsInterfacestructure asbeliefpropagationandapply_operators. It works on any tree, gauges the state with isometric (QR) orthogonalization, and holds the projected-Hamiltonian environments in aMessageCache.The operator is passed as a
TensorNetworkOperator, a tensor network together with the map between its bra-side and ket-side physical names (the tensor-network analogue of an ITensor operator). AQuadraticFormNetworkwraps the lazy⟨ψ|H|ψ⟩and derives the bra layer from the ket, so it tracks updates to the state. On a tree the environments are exact: each per-edge message is the contraction of the⟨ψ|H|ψ⟩subtree on one side of the cut, carried as an ITensor operator whose codomain and domain record the bra-to-ket link correspondence, so the bra link names generated internally are queryable from the returned environment.The environment is built once per solve and kept current incrementally as the orthogonality center walks to each region, so a sweep stays linear in the number of sites. Truncation can vary across sweeps through a
truncfunction of the sweep index, andstopping_criteriontakes(; maxsweeps, tol)(a sweep cap and an energy-convergence tolerance) or an explicit criterion.The effective Hamiltonian is currently materialized into a single operator tensor rather than applied matrix-free. A matrix-free version is a planned follow-up.