cuQuantum icon indicating copy to clipboard operation
cuQuantum copied to clipboard

[Performance] cuTN circuit2einsum slower than opt_einsum

Open mtjrider opened this issue 1 year ago • 5 comments

Discussed in https://github.com/NVIDIA/cuQuantum/discussions/53

Originally posted by rht May 12, 2023 I was benchmarking cuTensorNet and opt_einsum on the QFT and QAOA circuit, and I found the former to be consistently slower than the latter. I used the same code in https://github.com/NVIDIA/cuQuantum/discussions/23 for cuTensorNet, and for opt_einsum:

bitstring = "0" * len(qubits)
# https://optimized-einsum.readthedocs.io/en/stable/autosummary/opt_einsum.contract_path.html#opt_einsum.contract_path
expression, operands = myconverter.amplitude(bitstring=bitstring)
tic = time.time()
path, path_info = oe.contract_path(expression, *operands)
elapsed1 = time.time() - tic
print("Elapsed opt_einsum path finding", elapsed1)
tic = time.time()
output = oe.contract(expression, *operands, optimize=path)
elapsed2 = time.time() - tic
print("Elapsed opt_einsum contract", elapsed2)

Plot for QFT: benchmark

I think it has something to do with cuTensorNet's path finding being closer to the global optimum. Is there a way to tweak the hyperoptimizer to either stop early, or to have a larger error tolerance, so as to minimize the overall time?

mtjrider avatar Sep 26 '23 04:09 mtjrider

Created based on this discussion: https://github.com/NVIDIA/cuQuantum/discussions/53

cc @rht

mtjrider avatar Sep 26 '23 04:09 mtjrider

The benchmarking code is available in this discussion comment:

https://github.com/NVIDIA/cuQuantum/discussions/53#discussioncomment-5912275

Gist:

https://gist.github.com/rht/b65dc22ff4826170710661a4e5fec29a

mtjrider avatar Sep 26 '23 13:09 mtjrider

The benchmark plot needs to be updated to the 23.06 one: https://github.com/NVIDIA/cuQuantum/discussions/53#discussioncomment-6474186.

rht avatar Oct 07 '23 03:10 rht

The benchmark plot needs to be updated to the 23.06 one: https://github.com/NVIDIA/cuQuantum/discussions/53#discussioncomment-6474186.

Done. Please confirm.

mtjrider avatar Oct 10 '23 05:10 mtjrider

Confirmed.

rht avatar Oct 10 '23 07:10 rht