Skip to content

[WIP] Add two-site DMRG for tree tensor networks#122

Draft
mtfishman wants to merge 2 commits into
mainfrom
mf/tree-dmrg
Draft

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

Conversation

@mtfishman

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 a NamedDimsArrays 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 a NamedDimsArrays 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.

TODO

  • Move the VectorInterface methods on AbstractNamedDimsArray (needed by KrylovKit.eigsolve) into NamedDimsArrays, then drop the broken marker on the Aqua piracy check.

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>
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.71041% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.97%. Comparing base (e312bd5) to head (c0217eb).

Files with missing lines Patch % Lines
src/dmrg.jl 87.07% 19 Missing ⚠️
src/orthogonalize.jl 69.56% 7 Missing ⚠️
src/tensornetworkoperator.jl 54.54% 5 Missing ⚠️
src/quadraticformnetwork.jl 90.62% 3 Missing ⚠️
src/nameddimsarrays_extensions.jl 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #122      +/-   ##
==========================================
+ Coverage   74.79%   74.97%   +0.18%     
==========================================
  Files          24       26       +2     
  Lines        1079     1247     +168     
==========================================
+ Hits          807      935     +128     
- Misses        272      312      +40     
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.

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>
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