quimb icon indicating copy to clipboard operation
quimb copied to clipboard

interface to Google Cirq

Open alexandrupaler opened this issue 6 years ago • 10 comments

Hello,

would an interface from quimb to Google Cirq be something of interest?

Alexandru

alexandrupaler avatar Mar 04 '20 18:03 alexandrupaler

Do you mean quimb as a simulation backend to Cirq? I personally haven't used and don't know much about Google Cirq. However, it may be of interest to others!

jcmgray avatar Mar 04 '20 23:03 jcmgray

Yes, like a simulation backend. In addition to using Qasm input files, it would allow to take (hopefully) arbitrary Cirq files and send them to quimb.

alexandrupaler avatar Mar 05 '20 00:03 alexandrupaler

Yeah I think an interface that would allow quimb to be compatible with some standard frameworks would be cool. Do you know what functionality is required of a cirq backend? Is it sufficient just to produce the full wavefunction?

jcmgray avatar Mar 05 '20 19:03 jcmgray

I guess an interface would accept circuits and output some kind of wave/samples. If you can produce the full wavefunction then that would be possible to get into Cirq. It depends on the size of the wave. Otherwise samples requires less memory.

alexandrupaler avatar Mar 05 '20 19:03 alexandrupaler

Producing the full wavefunction is the most efficient thing to do, if it can fit into memory. Efficiently sampling exactly without forming the dense representation would require a few more changes, namely an implementation of partial trace -> partial outcome -> final outcome conditioned on partial outcome.

jcmgray avatar Mar 05 '20 20:03 jcmgray

Should be doable. For example, for the qasm input does it mean that quimb can use up to ~30 qubit circuits if the memory allows it? Do you restrict the number of qubits at import time?

alexandrupaler avatar Mar 06 '20 19:03 alexandrupaler

There's no restriction, the problem is just when randomly sampling from the constructed tensor network to mimic a quantum computer currently the full output wavefunction is produced. So the memory for that is at least ~2^N.

On the other hand, this can be avoided by computing the marginal probabilities on some qubits, then using those to compute the probabilities for the remaining qubits, without every constructing the full wavefunction. This would be a neat to implement at some point!

jcmgray avatar Mar 07 '20 00:03 jcmgray

There's some prototype-level code here: https://github.com/quantumlib/Cirq/tree/master/cirq/contrib/quimb that can convert cirq Circuits to quimb tensor networks (for statevector or density matrix)

mpharrigan avatar Apr 06 '21 01:04 mpharrigan

Nice, thanks for that link. I should also mention that all the unbiased sampling stuff I described in previous comments (and various other high-level interfaces) has now been implemented - https://quimb.readthedocs.io/en/latest/tensor-circuit.html, but indeed mixed state / density matrix evolution is not yet handled.

jcmgray avatar Apr 06 '21 03:04 jcmgray