Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

ddddddanni
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added the size: XL lines changed >1000 label Jul 15, 2025
Copy link
Collaborator

@eliottrosenberg eliottrosenberg left a 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
Copy link
Collaborator

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]
Copy link
Collaborator

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]
Copy link
Collaborator

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator

@eliottrosenberg eliottrosenberg Aug 4, 2025

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 $\sum_i Z_i$ is conserved, but each $Z_i$ individually is not necessarily.

Copy link
Collaborator Author

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]]?

@ddddddanni
Copy link
Collaborator Author

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.

I actually have

@attrs.frozen
class PostFilteringSymmetryCalibrationResult:
    """Result of post-selection symmetry calibration.
    Attributes:
        raw_bitstrings: The raw bitstrings obtained from the measurement.
        filtered_bitstrings: The bitstrings after applying post-selection symmetries.
    """

    raw_bitstrings: np.ndarray
    filtered_bitstrings: np.ndarray

Maybe I can add:

  1. fraction_of_survived_bistrings: float
  2. symmetry_to_filtered_bistrings: dict{paulistring|paulisum, list[bitstrings]}?

def measure_pauli_strings_with_symmetries(
sampler: work.Sampler,
circuits_to_pauli_params: list[CircuitToPauliStringsParameters],
pauli_measurement_circuits: list[circuits.Circuit],
Copy link
Collaborator

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?

Copy link
Collaborator

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

@eliottrosenberg
Copy link
Collaborator

eliottrosenberg commented Jul 15, 2025

@ddddddanni ah, I missed that I can do .calibration_result.filtered_bitstrings and .calibration_result.calibration_result.filtered_bitstrings. That's great! Thanks!

@mhucka
Copy link
Contributor

mhucka commented Oct 13, 2025

@ddddddanni Just wanted to gently ask what the status of this is. No pressure; I know this is a draft.

@ddddddanni
Copy link
Collaborator Author

@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.

@mhucka
Copy link
Contributor

mhucka commented Oct 14, 2025

@ddddddanni No problem at all. Thanks for your quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XL lines changed >1000

Projects

Status: Waiting

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.