Open rht opened 1 year ago
Hi @rht, to be clear cotengra
and opt_einsum
offer different optimizers that will take different amounts of time. But the same whether you call them via opt_einsum
or quimb
. However,
1 cotengra
has more advanced optimizers, that can find better paths for large contractions.
cotengra
can also be much faster as it uses batch matrix multiplication for hpyer indices, (but they will be similar for non-hyper contractions)If you have the einsum equation and arrays, you can use contegra
or quimb
directly.
E.g.:
expr = ctg.contraction_expression(eq, *shapes, optimize=opt)
out = expr(*arrays)
In https://github.com/dgasmith/opt_einsum/issues/217#issuecomment-1620525115, @jcmgray stated that running
cotengra
optimization viaoe.contract_path(expression, *operands, optimize=opt)
(whereopt
is acotengra
optimizer) is slower than doing it viaquimb
. I have to add more detail that the path finding part of theopt_einsum
method alone is much slower than the entirety of the run viaquimb
. As such, the reasoning in that comment applies only to the contraction phase.What is the recommended way to do the path finding via
opt_einsum
, that is performant? The main use case is that most circuits are written in Qiskit/Cirq, and withcuQuantum
'sCircuitToEinsum
, it enables one to do contraction of any Qiskit/Cirq circuits.