-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Combine Pauli measurements and postselection #7492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
eliottrosenberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> "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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this input given that we have circuits_to_pauli_params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't exactly a dictionary, so let's modify the docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #7746!
| # Skip if no circuits to measure | ||
| if not circuits_to_pauli: | ||
| return [] | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
No description provided.