Add lazy and symbolic ITensors with contraction-order optimization#182
Merged
Conversation
## 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 previously lived in ITensorNetworksNext's `LazyITensors` submodule. 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` stores `name`, `denamed_axes`, and `dimnames`, mirroring how a plain `ITensor` splits into `denamed` and `dimnames`. The symbolic leaf has no array, so it keeps the underlying axes directly. It is parameterized by the dimension-name type and the name type, the latter matching how the tensor network types parameterize by vertex type.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #182 +/- ##
==========================================
- Coverage 74.75% 71.05% -3.70%
==========================================
Files 20 28 +8
Lines 1105 1451 +346
==========================================
+ Hits 826 1031 +205
- Misses 279 420 +141
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:
|
A symbolic tensor is substituted with a real tensor before contraction,
so it only needs the index sizes for contraction-order selection. Store
`size::Vector{Int}` alongside `dimnames` and reconstruct `inds` as plain
ranges of those sizes.
mtfishman
added a commit
to ITensor/ITensorNetworksNext.jl
that referenced
this pull request
Jun 22, 2026
## Summary Switches ITensorNetworksNext to use the lazy and symbolic ITensor layer from ITensorBase instead of its own copy. The `LazyITensors` submodule is removed, and its lazy and symbolic types and contraction-order machinery are imported directly from ITensorBase, where the implementation moved in ITensor/ITensorBase.jl#182. Also drops the now-redundant `ITensorNetworksNextTensorOperationsExt` (the `Optimal` order via `TensorOperations.optimaltree` is provided by ITensorBase's own extension) and the `AbstractTrees`, `TermInterface`, and `WrappedUnions` dependencies that only the local copy used.
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
Adds the lazy and symbolic tensor types and the contraction-order machinery to ITensorBase, in the top-level namespace:
LazyITensorandSymbolicITensorexpression leaves,lazy/Mul/symnameddims/substitutefor building lazy contraction expressions, andoptimize_evaluation_orderwith theGreedyandOptimalorder algorithms. This code was moved from ITensorNetworksNext'sLazyITensorssubmodule, 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 theITensortype it builds on, and a follow-up will switch ITensorNetworksNext to consume it instead of carrying its own copy.AbstractTreesbecomes a regular dependency rather than a weakdep: the lazy and symbolicshowand tree rendering use it throughout, and theprintnode(::AbstractITensor)method that was inITensorBaseAbstractTreesExtmoves into the package.TermInterface,WrappedUnions, andCombinatoricsare new dependencies. TheOptimalorder, which usesTensorOperations.optimaltree, is provided by a newTensorOperationsextension.SymbolicITensoris a placeholder that gets substituted with a real tensor before contraction, so it stores only what contraction-order selection needs:name, the indexsizes, anddimnames, withindsreconstructed 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.