Support broadcasting on operators and dot on graded named arrays#233
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #233 +/- ##
==========================================
+ Coverage 72.97% 73.38% +0.40%
==========================================
Files 20 20
Lines 1051 1052 +1
==========================================
+ Hits 767 772 +5
+ Misses 284 280 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d0d1f0d to
a69afbd
Compare
a69afbd to
ec4e417
Compare
Lets operator-backed and graded-backed named arrays go through linear algebra without
falling into the generic `AbstractArray` paths, which assume a statically known
`ndims` or use scalar indexing.
`Base.broadcastable` on `AbstractNamedDimsOperator` peels an operator to its `state`,
so broadcasting and the array operations that lower to it (`+`, `-`, scalar
multiplication) run on the underlying state. Without it they threw `TypeError:
expected Int64, got Type{Any}` when the operator's parent is dynamically ranked, as it
is when backed by an `ITensor`. The result is a bare state, dropping the operator
wrapper, matching `*`.
`dot` becomes the full contraction `(conj(a1) * a2)[]`, which aligns the legs by name
and reduces through the contraction backend. The generic definition scalar-indexes,
which graded arrays reject.
Together these let ITensorNetworksNext run belief propagation with operator-valued
messages, where message normalization and the convergence check exercise both paths.
ec4e417 to
de6890b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets operator-backed and graded-backed named arrays go through linear algebra without falling into the generic
AbstractArraypaths, which assume a statically knownndimsor use scalar indexing.Base.broadcastableonAbstractNamedDimsOperatorpeels an operator to itsstate, so broadcasting and the array operations that lower to it (+,-, scalar multiplication) run on the underlying state. Without it they threwTypeError: expected Int64, got Type{Any}when the operator's parent is dynamically ranked, as it is when backed by anITensor. The result is a bare state, dropping the operator wrapper, matching*.dotbecomes the full contraction(conj(a1) * a2)[], which aligns the legs by name and reduces through the contraction backend. The generic definition scalar-indexes, which graded arrays reject.Together these let ITensorNetworksNext run belief propagation with operator-valued messages, where message normalization and the convergence check exercise both paths.