-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ITensors][NDTensors] An attempt to address contract compile time #1125
Conversation
@emstoudenmire I looked into the error and its one I helped Ryan with last week. A recent update to the Julia version 1.9 causes an issue in the Zygote package. As a result one of our unit tests fails. So the failing test is not related to the work in this PR. (Ryan made a PR with only a change to documentation and was worried about why the unittest were failing) |
To keep you in the loop @mtfishman , Karl and I discussed this in detail today, and agreed it's more of an experimental PR to see what kinds of compilation speedups might be possible to get and how to get them. Karl is going to add some more examples that put even more pressure on the compiler to see how big the speedups can be. A final PR implementing these ideas would need to be designed differently (some parts of the new code here being absorbed into functions above, and other parts being moved to NDTensors.jl). |
Sounds good, glad this is getting explored and it's good timing with the release of Julia 1.9 which should make precompilation more effective once we refactor the contraction code properly. This was a branch I was working on which refactored the contraction code logic to help with precompilation: https://github.com/ITensor/ITensors.jl/tree/ITensors_precompile. It's similar in spirit, where I was creating function barriers to split apart the logic of converting the tensors to matrices and then performing the contraction, but at a lower level in the NDTensors code. The goal was to make it so that less of the code had to get recompiled for tensors with new tensor orders that get input into the In our next meeting, we can try to go through the logic of the |
Description
The lowest contract function in NDTensors is explicitly dependent on the number of tensor indices for tensors
A
,B
, andC
, for a generic tensor contractionC = A * B
. Therefore when we change the number of modes for A, B or C, we need to recompile the full stack of contract functions.Fixes #(issue)
Because most of the contractions fall into a matrix contraction (gemm), we could refactor the original ITensors into ITensors of order-2 and then follow the standard contract approach. This would mean that we only have to recompile the top-most function which converts order-N tensors into order-2 tensors.
Minimal demonstration of previous behavior
Minimal demonstration of new behavior
How Has This Been Tested?
Tests will be added in the contract section that use the
matricize
portion of contract and give the exact same result as thenon-matricized
portionChecklist:
using JuliaFormatter; format(".")
in the base directory of the repository (~/.julia/dev/ITensors
) to format your code according to our style guidelines.