Skip to content

Add two-site DMRG for tree tensor networks#122

Open
mtfishman wants to merge 4 commits into
mainfrom
mf/tree-dmrg
Open

Add two-site DMRG for tree tensor networks#122
mtfishman wants to merge 4 commits into
mainfrom
mf/tree-dmrg

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary

Adds dmrg, a two-site DMRG ground-state solver for tree tensor networks, built on the same layered AlgorithmsInterface structure as beliefpropagation and apply_operators. It works on any tree, gauges the state with isometric (QR) orthogonalization, and holds the projected-Hamiltonian environments in a MessageCache.

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). A QuadraticFormNetwork wraps 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 trunc function of the sweep index, and stopping_criterion takes (; 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.

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.02203% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.45%. Comparing base (469dad6) to head (f17e10c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/dmrg.jl 87.58% 19 Missing ⚠️
src/orthogonalize.jl 69.56% 7 Missing ⚠️
src/tensornetworkoperator.jl 64.28% 5 Missing ⚠️
src/quadraticformnetwork.jl 91.89% 3 Missing ⚠️
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     
Flag Coverage Δ
docs ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

mtfishman and others added 3 commits June 24, 2026 22:34
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.
@mtfishman mtfishman changed the title [WIP] Add two-site DMRG for tree tensor networks Add two-site DMRG for tree tensor networks Jun 25, 2026
@mtfishman mtfishman marked this pull request as ready for review June 25, 2026 18:35
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