Skip to content
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

Add a tool for measuring expectation values of Pauli strings with readout error mitigation #7067

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ddddddanni
Copy link
Contributor

This PR does the following two things:

  1. Improved Readout Benchmarking: Modified run_shuffled_with_readout_benchmarking to accept a list of qubit tuples (List[Tuple[Qubit]]). This allows for calculating the readout error rate on specific qubit subsets, ensuring alignment with the qubit sets used in non-identity Pauli operators within Pauli strings.

  2. Added a tool to compute expectation values for Pauli operators. This tool calculates both unmitigated and readout-error-mitigated expectation values for each circuit, and integrates the results from the readout benchmarking.

@ddddddanni ddddddanni requested review from vtomole and a team as code owners February 14, 2025 00:41
@CirqBot CirqBot added the size: L 250< lines changed <1000 label Feb 14, 2025
@ddddddanni
Copy link
Contributor Author

Hey @eliottrosenberg and @NoureldinYosri if you could take a look at this. Thanks!

@NoureldinYosri NoureldinYosri self-requested a review February 14, 2025 01:46
@NoureldinYosri NoureldinYosri self-assigned this Feb 14, 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.

Very nice work Danni!! This looks really great!

A few initial comments:

Regarding line 55 in shuffle_circuits_with_readout_benchmarking.py, it should be possible to specify 0 for num_random_bitstrings in order to do the measurement without readout mitigation (or have a different way of running without readout mitigation).

I think you went with lists of tuples for circuits_to_pauli because you can't put a cirq.Circuit into a dictionary, but you can put a cirq.FrozenCircuit into a dictionary, so maybe that would be more convenient (not sure). Also, the object that measure_pauli_strings outputs is pretty complicated, with lots of nested tuples, so maybe we want to create some data class for the output?

…_random_bitstrings, and add a test to cover the situation. The design is the run_shuffled_with_readout_benchmarking method will return a empty SingleQubitReadoutCalibrationResult if no calibration is actually done.

2. Allow measure_pauli_strings to take num_random_bitstrings = 0. In this case, no mitigation is actually done, and the mitigated result and unmitigated result are the same. Also add a test to handle this situation.
3. Make the return type of measure_pauli_strings a data class.
@ddddddanni
Copy link
Contributor Author

Very nice work Danni!! This looks really great!

A few initial comments:

Regarding line 55 in shuffle_circuits_with_readout_benchmarking.py, it should be possible to specify 0 for num_random_bitstrings in order to do the measurement without readout mitigation (or have a different way of running without readout mitigation).

I think you went with lists of tuples for circuits_to_pauli because you can't put a cirq.Circuit into a dictionary, but you can put a cirq.FrozenCircuit into a dictionary, so maybe that would be more convenient (not sure). Also, the object that measure_pauli_strings outputs is pretty complicated, with lots of nested tuples, so maybe we want to create some data class for the output?

Done.
In the new commit, I allow shuffle_circuits_with_readout_benchmarking to take 0 for num_random_bitstrings, and add a test to cover the situation. The design is the run_shuffled_with_readout_benchmarking method will return a empty SingleQubitReadoutCalibrationResult if no calibration is actually done.
I also allow measure_pauli_strings to take num_random_bitstrings = 0. In this case, no mitigation is actually done, and the mitigated result and unmitigated result are the same. Also add a test to handle this situation. (not sure if we really want to have this situation supported?)
Besides, I make the return type of measure_pauli_strings a data class CircuitToPauliStringsMeasurementResult. Thanks for the suggestion, the code is more readable with this change.

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!! I tried testing it in this colab and got the error shown there.

@ddddddanni
Copy link
Contributor Author

Thanks, Danni!! I tried testing it in this colab and got the error shown there.

Can you try again? The problem should be fixed in the latest commit ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants