quantum icon indicating copy to clipboard operation
quantum copied to clipboard

Support for Projectors in Expectation Calculations

Open MichaelBroughton opened this issue 5 years ago • 2 comments

Right now Cirq does not allow such things as:

a = cirq.Z(q0) * cirq.Z(q0) + projector(0111011001)
a.expectation_from_wavefunction(a, ...)

One must manually write out the projection operators like:

a = (1 - cirq.Z(q)) / 2 * (1 + cirq.Z(q2)) / 2 . . .

Storing such a large paulisum can quickly grow to be prohibitive despite the matrix having just one entry in the end and the post-processing step being very simple to implement on a real device. It would be nice if we could have this feature put into Cirq and then relayed up and supported in TFQ. What do people think ? @zaqqwerty .

MichaelBroughton avatar Aug 20 '20 23:08 MichaelBroughton

With the additions of https://github.com/quantumlib/Cirq/pull/4364 in the latest release of Cirq. We are now able to work on this issue.

  1. Upgrade to the latest version of Cirq.
  2. Implement serialization logic for ProjectorSums.
  3. Gradually incroporate ProjectorSum functionality in C++ ops incl. gradients.
  4. Add Projector sums to fuzz tests for ops.

MichaelBroughton avatar Aug 19 '21 17:08 MichaelBroughton

I am interested but I don't want to over-commit and under-deliver. Let me take a look at it and get back to you all.

For context these are the PRs: https://github.com/quantumlib/Cirq/pull/4331 (ProjectorString) https://github.com/quantumlib/Cirq/pull/4364 (ProjectorSum)

Only the first PR has made it to the current latest release: https://github.com/quantumlib/Cirq/releases/tag/v0.12.0

tonybruguier avatar Aug 19 '21 17:08 tonybruguier