Skip to content

Lower linear broadcasting through bipermutedimsopadd!#232

Merged
mtfishman merged 3 commits into
mainfrom
mf/drop-functionimplementations
Jun 17, 2026
Merged

Lower linear broadcasting through bipermutedimsopadd!#232
mtfishman merged 3 commits into
mainfrom
mf/drop-functionimplementations

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

Routes linear broadcasting of AbstractNamedDimsArrays through TensorAlgebra's bipermutedimsopadd!. copyto! and copy now run the denamed broadcast through tryflattenlinear, and the linear case lowers to permutedimsopadd! on the name-aligned operands, where each operand's PermutedDimsArray alignment is unwrapped down to the backend's own bipermutedimsopadd! (the unwrap added in ITensor/TensorAlgebra.jl#178). Nonlinear broadcasts fall back to the existing denamed Base broadcast. For a graded or block-sparse backing, a permuted broadcast now reaches the block-wise primitive and the result keeps its backend type rather than densifying.

Out-of-place results allocate from a bare operand prototype with the broadcast result axes, since similar of a permuted wrapper drops the backend.

Drops the FunctionImplementations dependency: aligneddims now gets its lazy permute through TensorAlgebra.permuteddims, and the now-dead ImplementationStyle trait that routed it is removed.

copyto! and copy now run the denamed broadcast through tryflattenlinear,
and the linear case lowers to permutedimsopadd! on the name-aligned
operands, where each operand's PermutedDimsArray alignment is unwrapped
down to the backend's own bipermutedimsopadd!. Nonlinear broadcasts fall
back to the existing denamed Base broadcast.

aligneddims now aligns through the overloadable TensorAlgebra.permuteddims
hook, and the FunctionImplementations dependency is dropped (the dead
ImplementationStyle trait that routed the old lazy permute is removed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.97%. Comparing base (32fc0ed) to head (aeb0e5f).

Files with missing lines Patch % Lines
src/broadcast.jl 71.42% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #232      +/-   ##
==========================================
+ Coverage   72.96%   72.97%   +0.01%     
==========================================
  Files          20       20              
  Lines        1043     1051       +8     
==========================================
+ Hits          761      767       +6     
- Misses        282      284       +2     
Flag Coverage Δ
docs 26.31% <73.33%> (+1.18%) ⬆️

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 2 commits June 17, 2026 18:03
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mtfishman mtfishman changed the title [WIP] Lower linear broadcasting through bipermutedimsopadd! Lower linear broadcasting through bipermutedimsopadd! Jun 17, 2026
@mtfishman mtfishman marked this pull request as ready for review June 17, 2026 22:53
@mtfishman mtfishman enabled auto-merge (squash) June 17, 2026 22:53
@mtfishman mtfishman merged commit 5da084a into main Jun 17, 2026
29 of 32 checks passed
@mtfishman mtfishman deleted the mf/drop-functionimplementations branch June 17, 2026 23:15
mtfishman added a commit to ITensor/GradedArrays.jl that referenced this pull request Jun 17, 2026
…h bipermutedimsopadd! (#177)

## Summary

Removes the eager `FunctionImplementations.permuteddims` overloads on
`AbstractGradedArray`, `AbstractSectorArray`, and `AbstractSectorDelta`.
These existed only to align graded operands during `NamedDimsArrays`
broadcasting by materializing a permuted copy. `NamedDimsArrays` now
aligns lazily and lowers linear broadcasts through `bipermutedimsopadd!`
(ITensor/TensorAlgebra.jl#178,
ITensor/NamedDimsArrays.jl#232), so a permuted
graded operand reaches the block-wise `bipermutedimsopadd!` without the
eager copy.

Bumps the `TensorAlgebra` and `NamedDimsArrays` compat floors to the
versions that introduce that path.

---------

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