Skip to content

Wrap a TensorKit TensorMap directly as an ITensor#206

Merged
mtfishman merged 7 commits into
mainfrom
mf/tensorkit-space-index
Jul 2, 2026
Merged

Wrap a TensorKit TensorMap directly as an ITensor#206
mtfishman merged 7 commits into
mainfrom
mf/tensorkit-space-index

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Lets a native TensorKit space be an Index, so an ITensor wraps a TensorKit TensorMap directly as its parent with no AbstractArray in between. NamedTensor and NamedUnitRange/Index are loosened to hold a TensorMap and a native space, and the generic named-tensor machinery (nameddims, named getindex, and the copy/zero helper) is loosened to accept any parent a NamedTensor can wrap rather than only an AbstractArray, so a TensorMap flows through with no backend-specific path. Cold-start construction (randn/rand/zeros over index spaces) and linear-combination broadcasting (a .+ b, 2 .* a) build on the map-shaped construction and broadcast hooks in ITensor/TensorAlgebra.jl#200, which dispatch on the axis type, so the TensorKit extension is left holding just the space-backed Index adapters. Element-wise broadcasting on a symmetric tensor has no meaning and errors cleanly. Contraction and factorization work through the TensorAlgebra TensorKit backend (ITensor/TensorAlgebra.jl#197) with no additional code.

This is the direct route to non-abelian symmetries such as SU(2) through the ITensorBase to TensorAlgebra to TensorKit path.

Loosen `NamedTensor` and `NamedUnitRange`/`Index` to hold a native
TensorKit space and a `TensorMap`, and add `ITensorBaseTensorKitExt`
for construction, wrapping under names, and linear-combination
broadcasting. Contraction and factorization work through the
TensorAlgebra TensorKit backend with no additional code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.35%. Comparing base (74c60a0) to head (8c18d96).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
+ Coverage   74.03%   74.35%   +0.31%     
==========================================
  Files          28       29       +1     
  Lines        1502     1505       +3     
==========================================
+ Hits         1112     1119       +7     
+ Misses        390      386       -4     
Flag Coverage Δ
docs 24.30% <54.54%> (-0.09%) ⬇️

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.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman changed the title [WIP] Wrap a TensorKit TensorMap directly as an ITensor Wrap a TensorKit TensorMap directly as an ITensor Jul 2, 2026
@mtfishman mtfishman marked this pull request as ready for review July 2, 2026 15:19
…adcast hooks

Routes cold-start `rand`/`randn`/`zeros` over index spaces through TensorAlgebra's map-shaped construction hooks (ITensor/TensorAlgebra.jl#200), which dispatch on the axis type to build a dense `Array`, a block-sparse array, or a `TensorMap`, so ITensorBase no longer carries backend-specific construction. The generic named-tensor machinery (`nameddims`, named `getindex`, and the `copy`/`zero` helper) is loosened to accept any parent a `NamedTensor` can wrap rather than only an `AbstractArray`, and the linear-combination broadcasting now lives in TensorAlgebra, so the TensorKit extension is left holding just the space-backed `Index` adapters.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman changed the title Wrap a TensorKit TensorMap directly as an ITensor [WIP] Wrap a TensorKit TensorMap directly as an ITensor Jul 2, 2026
@mtfishman mtfishman marked this pull request as draft July 2, 2026 17:16
mtfishman and others added 2 commits July 2, 2026 13:51
A comment between a docstring and the definition it documents detaches the docstring, so Documenter reported no docs found for `NamedTensor` and `NamedUnitRange`. Move the field-rationale comments into the struct bodies, onto the fields they explain, leaving each docstring directly above its `struct`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman changed the title [WIP] Wrap a TensorKit TensorMap directly as an ITensor Wrap a TensorKit TensorMap directly as an ITensor Jul 2, 2026
@mtfishman mtfishman marked this pull request as ready for review July 2, 2026 18:33
@mtfishman mtfishman enabled auto-merge (squash) July 2, 2026 18:33
mtfishman and others added 2 commits July 2, 2026 14:36
The TensorKit test dependency added here caps VectorInterface at 0.5, so the 0.6 bucket the test compat claimed is unreachable in the test environment. The main package keeps VectorInterface at "0.5, 0.6" since TensorKit is only a weak dependency there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The TensorKit extension needs TensorKit 0.17, which requires VectorInterface at most 0.5, and no released TensorKit supports VectorInterface 0.6. The 0.6 bucket the compat claimed is therefore unreachable for any consumer using the extension, so drop it to match what the package can resolve to.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman merged commit 7e82c77 into main Jul 2, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/tensorkit-space-index branch July 2, 2026 19:04
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