Skip to content

Operand-driven diagonal algebra for the graded path - #264

Merged
mtfishman merged 14 commits into
mainfrom
mf/diagonal-algebra
Aug 21, 2026
Merged

Operand-driven diagonal algebra for the graded path#264
mtfishman merged 14 commits into
mainfrom
mf/diagonal-algebra

Conversation

@mtfishman

@mtfishman mtfishman commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Make diagonal algebra operand-driven on the graded path: keep a FusedGradedDiagonal when the result is diagonal, densify otherwise. Companion to ITensor/TensorAlgebra.jl#224.

Preserve the FusedGradedDiagonal type through the operations whose result is genuinely diagonal, and densify only where the result is not representable as a diagonal.
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.96%. Comparing base (2323d1b) to head (29ef458).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/fusedgradedmatrix.jl 83.33% 2 Missing ⚠️
src/fusedgradeddiagonal.jl 88.88% 1 Missing ⚠️
src/gradedarray.jl 88.88% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (2323d1b) and HEAD (29ef458). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (2323d1b) HEAD (29ef458)
docs 2 1
6 3
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #264      +/-   ##
==========================================
- Coverage   82.02%   76.96%   -5.07%     
==========================================
  Files          38       37       -1     
  Lines        2504     2527      +23     
==========================================
- Hits         2054     1945     -109     
- Misses        450      582     +132     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

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.

Generalizes `pow_diag_safe!` to `AbstractFusedGradedMatrix`, delegating to the generic per-block kernel, so the `isdiag` fast path in `sqrth_invsqrth_safe` powers a dense-typed but runtime-diagonal graded matrix directly, not only a `FusedGradedDiagonal`.
Forwards in-place scaling through `matricize` to the fused level, so scaling a graded-backed array no longer falls to LinearAlgebra's element-wise fallback, which the scalar-indexing guard rejects.
Guards `diag` with a new `checksquare`, so a rectangular-block matrix errors instead of silently returning per-block diagonals on a mismatched axis. Also renames `isblockdiagonal` to `isblockdiag` to match `LinearAlgebra.isdiag`.
`FusedGradedMatrix{T,S,V}(undef, cod, dom)` allocates the buffer as `V(undef, total)`, so a caller can keep its own block backend instead of defaulting to `Vector{T}`.
Replace the `densematrix` helper with a `FusedGradedMatrix(d::FusedGradedDiagonal)` constructor that forwards the diagonal's block backend. A non-`{1,1}` matricize bends a leg fused storage cannot represent, so it now errors.
Factorizations return spectra at the matrix level and nothing wraps one into a `GradedArray`, so this was speculative. Wrapped diagonal spectra now contract through the generic dense allocation.
Eigendecomposition and hermitian projection require the graded-square precondition, not just matching dimensions. Also tightens the diagonal matricize error path and fills test gaps from review.
mtfishman added a commit to ITensor/TensorAlgebra.jl that referenced this pull request Aug 21, 2026
## Summary

Make diagonal algebra operand-driven: `Diagonal` is kept when the result
is genuinely diagonal and densified otherwise. Also renames
`[co]domain_axes` to `axes_[co]domain`. Companion to
ITensor/GradedArrays.jl#264.
TensorAlgebra accumulates unregistered on main at 0.20.0-DEV, so the pin stays until the release PRs drop it.
@mtfishman mtfishman changed the title [WIP] Operand-driven diagonal algebra for the graded path Operand-driven diagonal algebra for the graded path Aug 21, 2026
@mtfishman
mtfishman marked this pull request as ready for review August 21, 2026 16:53
@mtfishman
mtfishman merged commit 0639b83 into main Aug 21, 2026
18 of 27 checks passed
@mtfishman
mtfishman deleted the mf/diagonal-algebra branch August 21, 2026 16:56
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