Flatten lazy product operands into leaves for contraction ordering - #159
Draft
mtfishman wants to merge 1 commit into
Draft
Flatten lazy product operands into leaves for contraction ordering#159mtfishman wants to merge 1 commit into
mtfishman wants to merge 1 commit into
Conversation
`contract_network` lowered each operand to a single symbol carrying its outer axes, so a lazy product operand stayed opaque to the contraction-order optimizer. A `NormNetwork`'s doubled vertex is such a product, `lazy(ket) * lazy(conj(bra))`, and collapsing it hid the physical index shared between the ket and bra. The optimizer could not interleave the other operands between the two layers, so it formed the doubled `ket * conj(bra)` tensor first, scaling as χ^(2·degree) rather than the χ^(degree+1) a good order reaches. A belief-propagation message update on a degree-3 vertex paid that cost on every sweep. For a computed order, `contract_network` now expands each operand into its contraction leaves before ordering, so `lazy(ket) * lazy(conj(bra))` reaches the optimizer as two leaves that share the physical index. The optimizer orders the full leaf set and interleaves the messages between the layers. The expansion runs on the operand after promotion to the network's common type (building on #158), so the operator and state semantics are preserved, and it recurses through nested products. An explicit `order` is honored over the operands as given, so it is not flattened. The Greedy optimizer and the rest of the order machinery are unchanged. A regression test asserts the computed order's peak intermediate stays at the χ^(degree+1) path rather than forming the χ^(2·degree) doubled tensor.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #159 +/- ##
==========================================
- Coverage 84.81% 78.80% -6.01%
==========================================
Files 15 13 -2
Lines 685 689 +4
==========================================
- Hits 581 543 -38
- Misses 104 146 +42
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:
|
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
contract_networklowered each operand to a single symbol carrying its outer axes, so a lazy product operand stayed opaque to the contraction-order optimizer. ANormNetwork's doubled vertex is such a product,lazy(ket) * lazy(conj(bra)), and collapsing it hid the physical index shared between the ket and bra. The optimizer could not interleave the other operands between the two layers, so it formed the doubledket * conj(bra)tensor first, scaling as χ^(2·degree) rather than the χ^(degree+1) a good order reaches. A belief-propagation message update on a degree-3 vertex paid that cost on every sweep.For a computed order,
contract_networknow expands each operand into its contraction leaves before ordering, solazy(ket) * lazy(conj(bra))reaches the optimizer as two leaves that share the physical index. The optimizer orders the full leaf set and interleaves the messages between the layers. The expansion runs on the operand after promotion to the network's common type (building on #158), so the operator and state semantics are preserved, and it recurses through nested products. An explicitorderis honored over the operands as given, so it is not flattened. The Greedy optimizer and the rest of the order machinery are unchanged.A regression test asserts the computed order's peak intermediate stays at the χ^(degree+1) path rather than forming the χ^(2·degree) doubled tensor.