jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
467 stars 107 forks source link

interface to Google Cirq #53

Open alexandrupaler opened 4 years ago

alexandrupaler commented 4 years ago

Hello,

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

Alexandru

jcmgray commented 4 years ago

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!

alexandrupaler commented 4 years ago

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.

jcmgray commented 4 years ago

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?

alexandrupaler commented 4 years ago

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.

jcmgray commented 4 years ago

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.

alexandrupaler commented 4 years ago

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?

jcmgray commented 4 years ago

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!

mpharrigan commented 3 years ago

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)

jcmgray commented 3 years ago

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.