Replace BackendSelection with dedicated contraction algorithm types#123
Merged
Conversation
## Summary Replaces the string-based `BackendSelection.Algorithm"..."` selection for tensor-network contraction with dedicated algorithm types, and drops `BackendSelection`, `TypeParameterAccessors`, and `FunctionImplementations` as dependencies. Contraction order is now chosen with types instead of `Algorithm` strings: `Greedy` and `Optimal` (the `optimize_contraction_order` strategies, with `Optimal` provided by the TensorOperations extension), `Flat` and `LeftAssociative` (the `contraction_order` strategies), and `Exact` (the `contract_network` algorithm, carrying its `order`/`order_alg` as fields rather than as `Algorithm` parameters). `Greedy` replaces the old `"eager"` name, the standard term for the cost-minimizing pairwise heuristic. `TypeParameterAccessors` was unused. The lone `FunctionImplementations.zero!` call becomes `fill!(a, zero(eltype(a)))`. The structure-aware `zero!` it relied on is worth keeping as a shared overloadable primitive, but where that should live is a separate question, and the dense path `delta` actually uses is unaffected. Also un-breaks the `show`/`printnode`/`print_tree` tests for the lazy and symbolic tensors: the rendered output was already correct, the expected strings just predated ITensorBase's index-name display. This sets up moving the `LazyITensors` submodule into ITensorBase, which its `BackendSelection` use had stood in the way of.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #123 +/- ##
==========================================
- Coverage 74.33% 74.30% -0.03%
==========================================
Files 23 23
Lines 1087 1082 -5
==========================================
- Hits 808 804 -4
+ Misses 279 278 -1
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:
|
mtfishman
added a commit
to ITensor/ITensorBase.jl
that referenced
this pull request
Jun 22, 2026
) ## Summary Adds the lazy and symbolic tensor types and the contraction-order machinery to ITensorBase, in the top-level namespace: `LazyITensor` and `SymbolicITensor` expression leaves, `lazy` / `Mul` / `symnameddims` / `substitute` for building lazy contraction expressions, and `optimize_evaluation_order` with the `Greedy` and `Optimal` order algorithms. This code was moved from ITensorNetworksNext's `LazyITensors` submodule, most recently reworked in ITensor/ITensorNetworksNext.jl#123 to use dedicated contraction-order algorithm types and fewer dependencies. It moves down to ITensorBase so it sits alongside the `ITensor` type it builds on, and a follow-up will switch ITensorNetworksNext to consume it instead of carrying its own copy. `AbstractTrees` becomes a regular dependency rather than a weakdep: the lazy and symbolic `show` and tree rendering use it throughout, and the `printnode(::AbstractITensor)` method that was in `ITensorBaseAbstractTreesExt` moves into the package. `TermInterface`, `WrappedUnions`, and `Combinatorics` are new dependencies. The `Optimal` order, which uses `TensorOperations.optimaltree`, is provided by a new `TensorOperations` extension. `SymbolicITensor` is a placeholder that gets substituted with a real tensor before contraction, so it stores only what contraction-order selection needs: `name`, the index `size`s, and `dimnames`, with `inds` reconstructed as plain ranges of those sizes. It is parameterized by the dimension-name type and the name type, the latter matching how the tensor network types parameterize by vertex type.
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
Replaces the string-based
BackendSelection.Algorithm"..."selection for tensor-network contraction with dedicated algorithm types, and dropsBackendSelection,TypeParameterAccessors, andFunctionImplementationsas dependencies.Contraction order is now chosen with types instead of
Algorithmstrings:GreedyandOptimal(theoptimize_contraction_orderstrategies, withOptimalprovided by the TensorOperations extension),FlatandLeftAssociative(thecontraction_orderstrategies), andExact(thecontract_networkalgorithm, carrying itsorder/order_algas fields rather than asAlgorithmparameters).Greedyreplaces the old"eager"name, the standard term for the cost-minimizing pairwise heuristic.TypeParameterAccessorswas unused. The loneFunctionImplementations.zero!call becomesfill!(a, zero(eltype(a))). The structure-awarezero!it relied on is worth keeping as a shared overloadable primitive, but where that should live is a separate question, and the dense pathdeltaactually uses is unaffected.Also un-breaks the
show/printnode/print_treetests for the lazy and symbolic tensors: the rendered output was already correct, the expected strings just predated ITensorBase's index-name display.This sets up moving the
LazyITensorssubmodule into ITensorBase, which itsBackendSelectionuse had stood in the way of.