Skip to content

Apply the conjugation op to destination axes in bipermutedimsopadd!#184

Merged
mtfishman merged 4 commits into
mainfrom
mf/conj-dualizes-axes
Jun 27, 2026
Merged

Apply the conjugation op to destination axes in bipermutedimsopadd!#184
mtfishman merged 4 commits into
mainfrom
mf/conj-dualizes-axes

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

bipermutedimsopadd! and permutedimsop now apply their element-wise op to the destination axes, so a conjugating permutation (op = conj) dualizes graded axes and keeps axes and data in sync. op acts as a conjugation flag, either identity or conj: on a graded axis conj dualizes, and on a dense axis it is a no-op, so dense arrays are unaffected. check_input rejects any other op with an informative error. Transposition is carried by the permutation arguments rather than by op.

This is breaking: check_input(::typeof(bipermutedimsopadd!), dest, op, src, perm_codomain, perm_domain) now takes op as a positional argument, so packages that call or specialize it must pass op. GradedArrays is updated to match in ITensor/GradedArrays.jl#185.

This also adds linearbroadcasted(*, ::Number, ::ConjBroadcasted), so scaling a conjugated broadcast operand such as conj.(a) ./ β lowers correctly instead of erroring.

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.98%. Comparing base (f558047) to head (58cc0e5).

Files with missing lines Patch % Lines
src/linearbroadcasted.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   79.37%   78.98%   -0.39%     
==========================================
  Files          20       20              
  Lines         669      671       +2     
==========================================
- Hits          531      530       -1     
- Misses        138      141       +3     
Flag Coverage Δ
docs 30.37% <83.33%> (+0.17%) ⬆️

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 added a commit to ITensor/GradedArrays.jl that referenced this pull request Jun 26, 2026
## Summary

Makes `conj` dualize graded axes consistently across GradedArrays, matching `Base.conj(::AbelianGradedArray)`. The materialization path (`bipermutedimsopadd!` on an `AbstractSectorArray` with `op = conj`) now routes through `Base.conj`, which dualizes the sectors and carries the fermionic reversal phase that a bare block-data conjugation drops. The `SectorStyle` broadcast picks up the same behavior: `broadcasted_sector` is op-aware, so `conj.(x)` dualizes the result axes, and a broadcast that conjugates only some operands such as `conj.(s) .- t` now errors as a sector mismatch rather than silently keeping the original axes. `Base.conj` on the structural factors `AbelianSectorDelta` and `SectorIdentity` dualizes their axes.

Builds on ITensor/TensorAlgebra.jl#184, which makes the `bipermutedimsopadd!` and `permutedimsop` `op` apply to the destination axes.

## TODO

- [ ] Drop the `[sources]` pin on TensorAlgebra and confirm the `0.11.2` compat floor once ITensor/TensorAlgebra.jl#184 merges and registers.
@mtfishman
mtfishman force-pushed the mf/conj-dualizes-axes branch from 239efed to a0fc687 Compare June 26, 2026 19:45
@mtfishman
mtfishman enabled auto-merge (squash) June 26, 2026 19:45
## Summary

`bipermutedimsopadd!` and `permutedimsop` now apply their element-wise `op` to the destination axes, so a conjugating permutation (`op = conj`) dualizes graded axes and keeps axes and data in sync. `op` acts as a conjugation flag, either `identity` or `conj`: on a graded axis `conj` dualizes, and on a dense axis it is a no-op, so dense arrays are unaffected. Transposition is carried by the permutation arguments rather than by `op`.

This also adds `linearbroadcasted(*, ::Number, ::ConjBroadcasted)`, so scaling a conjugated broadcast operand such as `conj.(a) ./ β` lowers correctly instead of erroring.
`bipermutedimsopadd!`'s `op` is a conjugation flag, either `identity` or `conj`. `check_input` now rejects any other function with an `ArgumentError`, so an unsupported `op` fails with a clear message at the boundary rather than later as a `MethodError` from applying it to an axis.
@mtfishman
mtfishman force-pushed the mf/conj-dualizes-axes branch from a0fc687 to 9b0c83f Compare June 26, 2026 19:53
@mtfishman
mtfishman disabled auto-merge June 27, 2026 14:58
@mtfishman
mtfishman force-pushed the mf/conj-dualizes-axes branch from cb40f44 to 4aa2954 Compare June 27, 2026 15:00
mtfishman added a commit to ITensor/GradedArrays.jl that referenced this pull request Jun 27, 2026
The new check_input signature lands in the breaking TensorAlgebra 0.12 release (ITensor/TensorAlgebra.jl#184).
@mtfishman
mtfishman enabled auto-merge (squash) June 27, 2026 15:22
@mtfishman
mtfishman merged commit de805f3 into main Jun 27, 2026
25 of 26 checks passed
@mtfishman
mtfishman deleted the mf/conj-dualizes-axes branch June 27, 2026 15:42
mtfishman added a commit to ITensor/SparseArraysBase.jl that referenced this pull request Jun 27, 2026
## Summary

Widens the TensorAlgebra compat bound to admit the breaking 0.12 release
(ITensor/TensorAlgebra.jl#184). The
TensorAlgebra extension uses `matricize`, `unmatricize`, and
`FusionStyle`, none of which changed, so this is a compat-only update.
mtfishman added a commit to ITensor/ITensorBase.jl that referenced this pull request Jun 27, 2026
## Summary

Widens the TensorAlgebra compat bound to admit the breaking 0.12 release
(ITensor/TensorAlgebra.jl#184). ITensorBase's
code is unaffected, so this is a compat-only update.
mtfishman added a commit to ITensor/GradedArrays.jl that referenced this pull request Jun 27, 2026
## Summary

Adapts to the breaking TensorAlgebra 0.12 release
(ITensor/TensorAlgebra.jl#184), whose
`check_input(bipermutedimsopadd!, ...)` now takes `op`. Passes `op`
through in the `AbstractSectorArray` and `AbstractGradedArray`
materialization paths and raises the TensorAlgebra compat bound to
`0.12`. This is the minimal change that unblocks downstream packages on
TensorAlgebra 0.12.

Conjugating broadcasts (`conj.`) must dualize the result axes to satisfy
the new `op`-aware `check_input`. That support is left to a follow-up,
so `conj.` on graded and sector arrays is unsupported for now (marked
with a broken test). Direct `conj` is unaffected.

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