Combine Pauli measurements and postselection#7492
Combine Pauli measurements and postselection#7492ddddddanni wants to merge 5 commits intoquantumlib:mainfrom
Conversation
eliottrosenberg
left a comment
There was a problem hiding this comment.
Thanks, Danni! This is a really great start! In addition to the comments below, it would be great if we could return the fraction of the bitstrings that survive the postselection, and maybe even more granular information in addition, like how many violate each of the symmetries. Maybe we can also optionally return the raw bitstrings to the users in case they want to do more analysis on them.
| together. | ||
| postselection_symmetries: A dictionary mapping Pauli strings or Pauli sums to | ||
| expected values for postselection symmetries. The | ||
| circuit is the eigenvector of each Pauli string or |
There was a problem hiding this comment.
-> "The final state generated by the circuit is an eigenvector ... with the specified eigenvalues."
|
|
||
| circuit: circuits.FrozenCircuit | ||
| pauli_strings: list[ops.PauliString] | list[list[ops.PauliString]] | ||
| postselection_symmetries: dict[ops.PauliString | ops.PauliSum, int] |
There was a problem hiding this comment.
Maybe this should default to None?
|
|
||
| circuit: circuits.FrozenCircuit | ||
| pauli_strings: list[ops.PauliString] | list[list[ops.PauliString]] | ||
| postselection_symmetries: dict[ops.PauliString | ops.PauliSum, int] |
There was a problem hiding this comment.
I realized that if I try to construct a dictionary with PauliSums as keys, I get the error TypeError: unhashable type: 'PauliSum'. Do you have any suggestions of what to do here? Should we use tuples or make a new data structure?
There was a problem hiding this comment.
Curious is PauliSum just a combination of PauliStrings? If so, can we remove the PauliSum from the postselection_symmetries: dict[ops.PauliString | ops.PauliSum, int], and make it postselection_symmetries: dict[ops.PauliString, int] instead?
For users who originally want to make
psum = cirq.PauliSum.from_pauli_strings([
pauli_1,
pauli_2,
pauli_3
])
postselection_symmetries[psum] = 1
they can split the psum into paulistrings and make the postselection_symmetries dict by
postselection_symmetries[pauli_1] = 1
postselection_symmetries[pauli_2] = 1
etc
Wdyt?
There was a problem hiding this comment.
There are some cases where the symmetry has to be specified by a PauliSum. For example, if total number is conserved, then
There was a problem hiding this comment.
Ahh got it, thanks for the clarification! In this case, I think we can define postselection_symmetries as a list of tuples such as Sequence[tuple[cirq.PauliString | cirq.PauliSum, int]]?
I actually have Maybe I can add:
|
| def measure_pauli_strings_with_symmetries( | ||
| sampler: work.Sampler, | ||
| circuits_to_pauli_params: list[CircuitToPauliStringsParameters], | ||
| pauli_measurement_circuits: list[circuits.Circuit], |
There was a problem hiding this comment.
Do we need this input given that we have circuits_to_pauli_params?
There was a problem hiding this comment.
I guess the user doesn't use this function directly, so it's ok
|
@ddddddanni ah, I missed that I can do |
|
@ddddddanni Just wanted to gently ask what the status of this is. No pressure; I know this is a draft. |
Thanks for checking!! I was working on the other PRs and Q3 okrs. I plan to get back to this PR this week. |
|
@ddddddanni No problem at all. Thanks for your quick reply! |
eliottrosenberg
left a comment
There was a problem hiding this comment.
@ddddddanni This looks really great! I tested it in this colab, and it is easy to use and seems to work as intended! My only nit is that the docstrings could be a bit clearer.
| same measurement results. | ||
| - A list of PauliStrings (list[ops.PauliString]). In this case, each | ||
| PauliString is treated as its own measurement group. | ||
| postselection_symmetries: A dictionary mapping Pauli strings or Pauli sums to |
There was a problem hiding this comment.
This isn't exactly a dictionary, so let's modify the docstring.
| # Skip if no circuits to measure | ||
| if not circuits_to_pauli: | ||
| return [] | ||
|
|
There was a problem hiding this comment.
We can also skip this if we're postselecting on at least one of the qubits in each observable, since then the postselection already does some of the readout mitigation. I think you are already skipping this in the analysis, but we can also skip it in the data taking (maybe you are already doing this), and it should be clear in the docstring that we are doing so.
There was a problem hiding this comment.
By "skip this if we're postselecting on at least one of the qubits in each observable" - do you mean skip readout data taking (generating random bitstrings, finding e0 and e1 for each qubits and calculating confusion matrices)? Yes we are not doing it if we use posteselecting method.
|
This pull request has been automatically labeled as stale because 90 days have passed without comments or other activity. If no further activity occurs and the If you have questions or feedback about this process, we welcome your input. You can open a new issue to let us know (please also reference this issue there, for continuity), or reach out to the project maintainers at quantum-oss-maintainers@google.com. |
I split this #7492 giant PR into smaller pieces for easier review. This PR: 1. Adds a CircuitToPauliStringsParameters class which supports postselection_symmetries. 2. Modify the validation method 3. Allows measure_pauli_strings to take CircuitToPauliStringsParameters as a input.
No description provided.