Skip to content

Forward VectorInterface in-place ops to name-aware TensorAlgebra methods#217

Merged
mtfishman merged 2 commits into
mainfrom
mf/vectorinterface-forward-ta
Jul 11, 2026
Merged

Forward VectorInterface in-place ops to name-aware TensorAlgebra methods#217
mtfishman merged 2 commits into
mainfrom
mf/vectorinterface-forward-ta

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

Implements the full VectorInterface for named tensors and routes its in-place operations through name-aware TensorAlgebra methods instead of self-aliasing broadcasts. scale!/add! forward to TensorAlgebra.scale!/TensorAlgebra.add!, which unname and align the operands by name (reusing the unnamed(x, dimnames(y)) view, which carries a tuple permutation) before dispatching to the backend array's block-wise in-place method. This fixes silent corruption when a block-sparse backend drives an iterative solver: the previous @. y = y*β + x*α put the destination on the right-hand side, and a graded copyto! ran the y*β term as a self-aliased permute-add that zeroed y before reading it. The out-of-place and !! variants allocate the promoted scalar type, so scaling a real tensor by a complex coefficient widens to a complex result.

inner forwards to LinearAlgebra.dot (previously a duplicate of the same (conj(x)*y)[]), and _permuteddims_to drops its AbstractArray restriction so the by-name alignment view also works for a TensorMap backend.

The methods are defined as qualified VectorInterface. overloads, so ITensorBase no longer imports the VectorInterface function names into its namespace or re-exports them.

Builds on ITensor/TensorAlgebra.jl#207, which adds the TensorMap TensorAlgebra.scale!/add!/zero! methods this forwarding lands on.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.10%. Comparing base (4b6e859) to head (cd6fa99).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   76.00%   76.10%   +0.09%     
==========================================
  Files          30       30              
  Lines        1684     1691       +7     
==========================================
+ Hits         1280     1287       +7     
  Misses        404      404              
Flag Coverage Δ
docs 26.06% <0.00%> (-0.12%) ⬇️

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 mtfishman force-pushed the mf/vectorinterface-forward-ta branch from d2cff1a to 021486b Compare July 11, 2026 16:38
@mtfishman mtfishman changed the title [WIP] Forward VectorInterface in-place ops to name-aware TensorAlgebra methods Forward VectorInterface in-place ops to name-aware TensorAlgebra methods Jul 11, 2026
@mtfishman mtfishman marked this pull request as ready for review July 11, 2026 17:06
@mtfishman mtfishman enabled auto-merge (squash) July 11, 2026 17:06
@mtfishman mtfishman merged commit 1066a99 into main Jul 11, 2026
26 of 28 checks passed
@mtfishman mtfishman deleted the mf/vectorinterface-forward-ta branch July 11, 2026 17:27
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