-
Notifications
You must be signed in to change notification settings - Fork 126
Add generic support for scalar ITensor contraction #569
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
Conversation
Benchmark resultJudge resultBenchmark Report for /home/runner/work/ITensors.jl/ITensors.jlJob Properties
ResultsA ratio greater than
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfoTarget
Baseline
Target resultBenchmark Report for /home/runner/work/ITensors.jl/ITensors.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Baseline resultBenchmark Report for /home/runner/work/ITensors.jl/ITensors.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Runtime information
|
Thinking about this more, I'm uncomfortable designing this where: A = randomITensor(i, j)
B = A * ITensor(1) makes B = A * ITensor(2) does not. However, I was thinking that if you want the view behavior (i.e. you want to avoid the copy), we could use a A = randomITensor(i, j)
B1 = A * ITensor(1) # B1 is a copy of A
B2 = A * delta() # B2 is a view of A I think the interpretation of |
Benchmark resultJudge resultBenchmark Report for /home/runner/work/ITensors.jl/ITensors.jlJob Properties
ResultsA ratio greater than
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfoTarget
Baseline
Target resultBenchmark Report for /home/runner/work/ITensors.jl/ITensors.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Baseline resultBenchmark Report for /home/runner/work/ITensors.jl/ITensors.jlJob Properties
ResultsBelow is a table of this job's results, obtained by running the benchmarks.
Benchmark Group ListHere's a list of all the benchmark groups executed by this job:
Julia versioninfo
Runtime information
|
See #618 for a design proposal for tensors that contract and return views instead of copies. |
This fixes #564.
@emstoudenmire, the main subtlety here is that in this implementation, it adds a special case when the ITensor has a scalar value of 1 and does nothing at all to it (just returns the non-scalar ITensor). The alternative would be that it performs a copy of the ITensor in that case, since it may be surprising for people that contractions sometimes return views of the input ITensors. Do you have an opinion on this?
There are other cases where we would not want to do a copy in ITensor contraction, for example with delta contractions that are just replacing indices (i.e.
randomITensor(i, j) * delta(j, j')
). In those cases, I would also want to return a view of the ITensor data, so perhaps contraction withITensor(1)
can be lumped in with that category. The main subtlety for contraction withITensor(1)
is that it is a pretty sneaky behavior change between contracting withITensor(1)
and any other scalar value, so maybe someone relies on the return not being a view and then one day they don't realize they are contracting by a value of exactly1
and the view behavior changes... But maybe we can just make it clear in the docs that scalar-like ITensors have special behavior.