Support for Projectors in Expectation Calculations
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 .
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.
- Upgrade to the latest version of Cirq.
- Implement serialization logic for ProjectorSums.
- Gradually incroporate ProjectorSum functionality in C++ ops incl. gradients.
- Add Projector sums to fuzz tests for ops.
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