quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.27k stars 1.01k forks source link

Exponential of a (commuting) PauliSum #3169

Open tanujkhattar opened 4 years ago

tanujkhattar commented 4 years ago

Exponentiating a PauliSum where individual terms commute is a fairly common utility function. Both TFQ and OpenFermion need/implement this functionality.

Given all the related nice functions which already exist in Cirq (to_z_basis_ops, PauliSumCollector etc.), I think we should also add a utility to achieve this.

Thoughts? I can send a PR if we have a consensus.

balopat commented 4 years ago

Thank you for opening this Tanuj! I'm personally open to it, but I'd like to get the opinion of the rest of the maintainers - let's discuss on Cirq Cynq tomorrow!

balopat commented 4 years ago

Cirq Cynque:

dabacon commented 4 years ago

There are sort of three cases: 1) commuting Pauli terms. 2) case where there are only a few anticommuting terms 3) no real structure.

Let H=c_1P_1+c_2P_2 +... +c_k P_k

In case 1) you can write this as a series of PauliStringPhasors, i.e. exp(iH) = exp(ic_1P) exp(ic_2P_2)...exp(ic_kP_k)

In case 2) you can use a stabilizer tableau (https://pdfs.semanticscholar.org/67af/c372369240e202ec902fb11ab25832d403af.pdf). The basic idea would be to iterate over the P_i and build up a tableau. If the next P_i commutes with the everything in the current tableau, and is not in the tableau, you add it as a z stabilizer for a new logical qubit. If it anticommutes with some of the elements in the tableau, you think about it as an encoded operation on the logical qubits, or whether you can add a new logical stabilizer to make it a product of an existing x/y stabilizer and this new stabilizer. Note that it may span multiple logical qubits. Then you look at the topological sort of z stabilizers and these logical qubits. Different disjoint sets can then be exponentiated. You have to do this numerically, except probably you could be explicit about the case where these are single qubits since exp(iH) for H a single qubit is easy to write down.

Case 3) is where you just do the full exponentiation numerically.

I'm not sure how much the optimization in case 2 matters now that I think about it. Certainly for the exp(iH)s I like to think about for error correction it does, but it might not be worth doing this optimization.

thanacles commented 3 years ago

@balopat @tanujkhattar It looks like the last PR for this was merged over 6 months ago. Is there more work to do here?