-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow users to run readout benchmarking with sweep #7435
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7435 +/- ##
==========================================
- Coverage 98.69% 97.54% -1.16%
==========================================
Files 1112 1095 -17
Lines 98076 99203 +1127
==========================================
- Hits 96798 96767 -31
- Misses 1278 2436 +1158 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cc: @eliottrosenberg this is a smaller RP I split from #7358. This one only touches the readout benchmarking but not pauli expectation calculation. |
@@ -84,6 +101,79 @@ def _generate_readout_calibration_circuits( | |||
return readout_calibration_circuits, random_bitstrings | |||
|
|||
|
|||
def _generate_parameterized_readout_calibration_circuit_with_sweep( | |||
qubits: list[ops.Qid], rng: np.random.Generator, num_random_bitstrings: 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.
traditionally rng
should be the last input, same below
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!
qubits_set: set[ops.Qid] = set() | ||
for circuit in input_circuits: | ||
qubits_set.update(circuit.all_qubits()) | ||
qubits_to_measure = [sorted(qubits_set)] |
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.
nit: this can be a single line
qubits_to_measure = [sorted(qubits_set)] | |
qubits_to_measure = [sorted(set(q for circuit in input_circuits for q in circuit.all_qubits())] |
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!
cirq-core/cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking.py
Show resolved
Hide resolved
cirq-core/cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking.py
Show resolved
Hide resolved
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 overall LGTM%nits
# Check readout_repetitions is bigger than 0 | ||
if readout_repetitions <= 0: | ||
raise ValueError("Must provide non-zero readout_repetitions for readout calibration.") | ||
def _validate_experiment_input_with_sweep( |
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.
nit: move this logic inside __attrs_post_init__
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 don't think this one could be moved to the attrs_post_init under ReadoutBenchmarkingParams? The reason is this is a specific validation if the experiment input is with sweep. However, the ReadoutBenchmarkingParams can be used by both sweep/non sweep functions.
cirq-core/cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py
Outdated
Show resolved
Hide resolved
|
||
def _determine_qubits_to_measure( | ||
input_circuits: Sequence[circuits.Circuit], | ||
qubits: Optional[Sequence[ops.Qid] | Sequence[Sequence[ops.Qid]]], |
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 type annotation for qubits
is strange, why is a nested sequence?
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 is because each input circuit can have a corresponding qubit list to be measured. And since the function can accept a list of circuits, so it has a corresponding list[list[qid]], where each list[qid] matches a circuit.
Requested by @NoureldinYosri, this pr is splited from #7358.
The pr adds a new function run_sweep_with_readout_benchmarking which runs the sweep circuits with readout error benchmarking (without shuffling).