Skip to content

Replace contract_network with prod_tensors and an explicit ContractionTree - #203

Merged
mtfishman merged 5 commits into
mainfrom
mf/contraction-tree
Oct 7, 2026
Merged

mtfishman merged 5 commits into
mainfrom
mf/contraction-tree

Conversation

@mtfishman

@mtfishman mtfishman commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Contraction orders become an explicit ContractionTree over the network's keys, and prod_tensors is the single way to contract, taking either a tree or an algorithm that finds one. This removes contract_network. Order finding moves here from ITensorBase (ITensor/ITensorBase.jl#270), its only consumer, so the lazy layer there could be removed.

Contraction orders become an explicit binary tree over the network's keys,
contracted by `prod_tensors(tensors, tree)`, in place of the symbolic
expressions built out of ITensorBase's lazy layer. Order finding moves here,
its only consumer. A `NormNetwork` is contracted through `flatten_network`,
which gives each layer its own vertex so the site index they share is visible
to the optimizer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.50649% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.65%. Comparing base (e9d0a65) to head (0ff4190).

Files with missing lines Patch % Lines
src/contraction_tree.jl 88.00% 3 Missing ⚠️
src/prod_tensors.jl 93.10% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #203      +/-   ##
==========================================
+ Coverage   88.34%   88.65%   +0.30%     
==========================================
  Files          16       17       +1     
  Lines         678      714      +36     
==========================================
+ Hits          599      633      +34     
- Misses         79       81       +2     
Flag Coverage Δ
docs 0.00% <0.00%> (ø)

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.

`prod_tensors` now takes either a `ContractionTree` or an algorithm that
finds one, so `contract_network` and its `Exact` wrapper are no longer
needed. A branch's children get their own `Branch` type, which keeps a leaf
distinguishable from a branch even when a vertex label is itself a 2-tuple.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman changed the title [WIP] Represent contraction orders as a ContractionTree [WIP] Replace contract_network with prod_tensors and an explicit ContractionTree Oct 6, 2026
`ContractionTree` wrapped its two-arm union with `WrappedUnions` but only ever
called `unwrap`, so a plain struct does the same job without the dependency. The
greedy search now reads `inds`, the name this stack uses for a tensor's indices,
rather than going through `axes`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
mtfishman added a commit to ITensor/ITensorBase.jl that referenced this pull request Oct 6, 2026
…name` (#270)

## Summary

Removes `LazyNamedTensor`, `SymbolicNamedTensor` and the
contraction-order finding built on them, along with five dependencies.
Order finding moves up to ITensorNetworksNext
(ITensor/ITensorNetworksNext.jl#203), its only
consumer. Also renames `dim` to `findname`, since it returns a position
rather than a size.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
mtfishman and others added 2 commits October 6, 2026 20:43
ITensorBase 0.16.0 is registered, so the branch pin that let CI resolve the
unreleased dependency is no longer needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Matches the greedy search, which already reads `inds` rather than going through
`axes`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mtfishman mtfishman changed the title [WIP] Replace contract_network with prod_tensors and an explicit ContractionTree Replace contract_network with prod_tensors and an explicit ContractionTree Oct 7, 2026
@mtfishman
mtfishman marked this pull request as ready for review October 7, 2026 01:16
@mtfishman
mtfishman enabled auto-merge (squash) October 7, 2026 01:16
@mtfishman
mtfishman merged commit df101c4 into main Oct 7, 2026
28 checks passed
@mtfishman
mtfishman deleted the mf/contraction-tree branch October 7, 2026 01:44
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