Skip to content

Add name-aware VectorInterface methods for ITensors#186

Merged
mtfishman merged 3 commits into
mainfrom
mf/vectorinterface-itensor
Jun 25, 2026
Merged

Add name-aware VectorInterface methods for ITensors#186
mtfishman merged 3 commits into
mainfrom
mf/vectorinterface-itensor

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 25, 2026

Copy link
Copy Markdown
Member

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.

Adds zerovector, scale, scale!!, add!! and inner for AbstractITensor,
alongside the existing scalartype, so an ITensor can be used directly as a
vector in iterative solvers like KrylovKit.eigsolve that drive their Krylov
vectors through VectorInterface. The generic AbstractArray fallbacks are not
name-aware.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.22%. Comparing base (fb19c64) to head (9c4e250).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #186      +/-   ##
==========================================
+ Coverage   71.60%   72.22%   +0.62%     
==========================================
  Files          28       28              
  Lines        1451     1480      +29     
==========================================
+ Hits         1039     1069      +30     
+ Misses        412      411       -1     
Flag Coverage Δ
docs 15.67% <0.00%> (-0.33%) ⬇️

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.

Cover the complete interface (add/scale/zerovector and their in-place ! and
maybe-in-place !! variants, inner, scalartype) rather than only the methods
KrylovKit.eigsolve happens to call. The in-place methods use broadcasting. Each
!! method stays in place when the result fits the destination element type and
otherwise allocates. zerovector goes through a new in-place TensorAlgebra.zero!
method for AbstractITensor.
mtfishman added a commit to ITensor/ITensorNetworksNext.jl that referenced this pull request Jun 25, 2026
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 mtfishman enabled auto-merge (squash) June 25, 2026 13:42
@mtfishman mtfishman merged commit b8749e6 into main Jun 25, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/vectorinterface-itensor branch June 25, 2026 13:46
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