Skip to content

Conversation

@JoeyT1994
Copy link
Contributor

Description

This PR removes the internal optimal_contraction_sequence(As) functions in ITensors.jl and outsources to the optimal tree function from TensorOperations.jl. Therefore optimal_contraction_sequence requires TensorOperations to be loaded, which is now a weak dependency of ITensors.jl.

Contraction sequence finding is now much faster, with orders of magnitude speedups manifesting for even relatively small vectors of Tensors.

How Has This Been Tested?

The tests from test/lib//ContractionSequenceOptimization/test_itensor_contract.jl have moved to test/ext/ITensorsTensorOperationsExt/runtests.jl and reflect the changes made to the optimal_contraction_sequence function.

@mtfishman
Copy link
Member

Can you update the docs (https://github.com/ITensor/ITensors.jl/blob/main/docs/src/ContractionSequenceOptimization.md) as well?

@JoeyT1994
Copy link
Contributor Author

I updated the docs. I also updated the version to 0.8.10 (not sure if this constitutes a sufficiently breaking change to change to 0.9)

@mtfishman
Copy link
Member

I updated the docs. I also updated the version to 0.8.10 (not sure if this constitutes a sufficiently breaking change to change to 0.9)

I think we should update to v0.9, since it is technically a breaking change. Could you add a NEWS item about that here: https://github.com/ITensor/ITensors.jl/blob/main/README.md#news?

@JoeyT1994
Copy link
Contributor Author

Sure, I went to 0.9.0 and added a news item. Not sure why the documentation check is failing though...

@mtfishman
Copy link
Member

mtfishman commented Mar 26, 2025

Sure, I went to 0.9.0 and added a news item. Not sure why the documentation check is failing though...

It's a bit annoying, but when we make breaking releases we also have to bump that compat entry in docs/Project.toml:

ITensors = "0.8.4"
.

@mtfishman
Copy link
Member

Huh not sure what's going on with the docs... Maybe it is better to just remove the compat entry for ITensors from docs/Project.toml for now and we can look into that later.

@mtfishman
Copy link
Member

Hmm, the docs build is erroring saying it can't find the docstring for ITensors.optimal_contraction_sequence, not sure what's going on there.

@mtfishman
Copy link
Member

I see, maybe the issue is that the docstring is defined in the package extension, probably it should be defined on the version of the function in src/tensor_operations/tensor_algebra.jl.

@mtfishman mtfishman changed the title Remove optimal sequence finding functions in favour of TensorOperations [ITensors] Remove optimal sequence finding functions in favour of TensorOperations Mar 26, 2025
@mtfishman
Copy link
Member

Looks good, thanks @JoeyT1994!

@mtfishman mtfishman merged commit 1832434 into ITensor:main Mar 26, 2025
11 of 12 checks passed
@mtfishman mtfishman changed the title [ITensors] Remove optimal sequence finding functions in favour of TensorOperations [ITensors] Call out to TensorOperations.jl for optimal sequence finding Mar 26, 2025
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.

2 participants