cirq-core 1.6.0.dev20250623211210__py3-none-any.whl → 1.6.0.dev20250624001344__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cirq-core might be problematic. Click here for more details.
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py +37 -13
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py +38 -1
- cirq/experiments/single_qubit_readout_calibration.py +11 -0
- {cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/RECORD +10 -10
- {cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
|
@@ -28,7 +28,9 @@ from cirq.contrib.shuffle_circuits import run_shuffled_with_readout_benchmarking
|
|
|
28
28
|
from cirq.experiments.readout_confusion_matrix import TensoredConfusionMatrices
|
|
29
29
|
|
|
30
30
|
if TYPE_CHECKING:
|
|
31
|
-
from cirq.experiments import
|
|
31
|
+
from cirq.experiments.single_qubit_readout_calibration import (
|
|
32
|
+
SingleQubitReadoutCalibrationResult,
|
|
33
|
+
)
|
|
32
34
|
from cirq.study import ResultDict
|
|
33
35
|
|
|
34
36
|
|
|
@@ -217,6 +219,11 @@ def _normalize_input_paulis(
|
|
|
217
219
|
return cast(dict[circuits.FrozenCircuit, list[list[ops.PauliString]]], circuits_to_pauli)
|
|
218
220
|
|
|
219
221
|
|
|
222
|
+
def _extract_readout_qubits(pauli_strings: list[ops.PauliString]) -> list[ops.Qid]:
|
|
223
|
+
"""Extracts unique qubits from a list of QWC Pauli strings."""
|
|
224
|
+
return sorted(set(q for ps in pauli_strings for q in ps.qubits))
|
|
225
|
+
|
|
226
|
+
|
|
220
227
|
def _pauli_strings_to_basis_change_ops(
|
|
221
228
|
pauli_strings: list[ops.PauliString], qid_list: list[ops.Qid]
|
|
222
229
|
):
|
|
@@ -315,16 +322,38 @@ def _process_pauli_measurement_results(
|
|
|
315
322
|
for pauli_group_index, circuit_result in enumerate(circuit_results):
|
|
316
323
|
measurement_results = circuit_result.measurements["m"]
|
|
317
324
|
pauli_strs = pauli_string_groups[pauli_group_index]
|
|
325
|
+
pauli_readout_qubits = _extract_readout_qubits(pauli_strs)
|
|
326
|
+
|
|
327
|
+
calibration_result = (
|
|
328
|
+
calibration_results[tuple(pauli_readout_qubits)]
|
|
329
|
+
if disable_readout_mitigation is False
|
|
330
|
+
else None
|
|
331
|
+
)
|
|
318
332
|
|
|
319
333
|
for pauli_str in pauli_strs:
|
|
320
334
|
qubits_sorted = sorted(pauli_str.qubits)
|
|
321
335
|
qubit_indices = [qubits.index(q) for q in qubits_sorted]
|
|
322
336
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
337
|
+
if disable_readout_mitigation:
|
|
338
|
+
pauli_str_calibration_result = None
|
|
339
|
+
confusion_matrices = _build_many_one_qubits_empty_confusion_matrix(
|
|
340
|
+
len(qubits_sorted)
|
|
341
|
+
)
|
|
342
|
+
else:
|
|
343
|
+
if calibration_result is None:
|
|
344
|
+
# This case should be logically impossible if mitigation is on,
|
|
345
|
+
# so we raise an error.
|
|
346
|
+
raise ValueError(
|
|
347
|
+
f"Readout mitigation is enabled, but no calibration result was "
|
|
348
|
+
f"found for qubits {pauli_readout_qubits}."
|
|
349
|
+
)
|
|
350
|
+
pauli_str_calibration_result = calibration_result.readout_result_for_qubits(
|
|
351
|
+
qubits_sorted
|
|
352
|
+
)
|
|
353
|
+
confusion_matrices = _build_many_one_qubits_confusion_matrix(
|
|
354
|
+
pauli_str_calibration_result
|
|
355
|
+
)
|
|
356
|
+
|
|
328
357
|
tensored_cm = TensoredConfusionMatrices(
|
|
329
358
|
confusion_matrices,
|
|
330
359
|
[[q] for q in qubits_sorted],
|
|
@@ -356,11 +385,7 @@ def _process_pauli_measurement_results(
|
|
|
356
385
|
mitigated_stddev=d_m_with_coefficient,
|
|
357
386
|
unmitigated_expectation=unmitigated_value_with_coefficient,
|
|
358
387
|
unmitigated_stddev=d_unmit_with_coefficient,
|
|
359
|
-
calibration_result=
|
|
360
|
-
calibration_results[tuple(qubits_sorted)]
|
|
361
|
-
if disable_readout_mitigation is False
|
|
362
|
-
else None
|
|
363
|
-
),
|
|
388
|
+
calibration_result=pauli_str_calibration_result,
|
|
364
389
|
)
|
|
365
390
|
)
|
|
366
391
|
|
|
@@ -428,8 +453,7 @@ def measure_pauli_strings(
|
|
|
428
453
|
unique_qubit_tuples = set()
|
|
429
454
|
for pauli_string_groups in normalized_circuits_to_pauli.values():
|
|
430
455
|
for pauli_strings in pauli_string_groups:
|
|
431
|
-
|
|
432
|
-
unique_qubit_tuples.add(tuple(sorted(pauli_string.qubits)))
|
|
456
|
+
unique_qubit_tuples.add(tuple(_extract_readout_qubits(pauli_strings)))
|
|
433
457
|
# qubits_list is a list of qubit tuples
|
|
434
458
|
qubits_list = sorted(unique_qubit_tuples)
|
|
435
459
|
|
|
@@ -23,7 +23,10 @@ import pytest
|
|
|
23
23
|
|
|
24
24
|
import cirq
|
|
25
25
|
from cirq.contrib.paulistring import measure_pauli_strings
|
|
26
|
-
from cirq.
|
|
26
|
+
from cirq.contrib.paulistring.pauli_string_measurement_with_readout_mitigation import (
|
|
27
|
+
_process_pauli_measurement_results,
|
|
28
|
+
)
|
|
29
|
+
from cirq.experiments.single_qubit_readout_calibration import SingleQubitReadoutCalibrationResult
|
|
27
30
|
from cirq.experiments.single_qubit_readout_calibration_test import NoisySingleQubitReadoutSampler
|
|
28
31
|
|
|
29
32
|
|
|
@@ -867,3 +870,37 @@ def test_group_paulis_type_mismatch() -> None:
|
|
|
867
870
|
measure_pauli_strings(
|
|
868
871
|
circuits_to_pauli, cirq.Simulator(), 1000, 1000, 1000, np.random.default_rng()
|
|
869
872
|
)
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
def test_process_pauli_measurement_results_raises_error_on_missing_calibration() -> None:
|
|
876
|
+
"""Test that the function raises an error if the calibration result is missing."""
|
|
877
|
+
qubits: list[cirq.Qid] = [q for q in cirq.LineQubit.range(5)]
|
|
878
|
+
|
|
879
|
+
measurement_op = cirq.measure(*qubits, key='m')
|
|
880
|
+
test_circuits = list[cirq.Circuit]()
|
|
881
|
+
for _ in range(3):
|
|
882
|
+
circuit_list = []
|
|
883
|
+
|
|
884
|
+
circuit = _create_ghz(5, qubits) + measurement_op
|
|
885
|
+
circuit_list.append(circuit)
|
|
886
|
+
test_circuits.extend(circuit_list)
|
|
887
|
+
|
|
888
|
+
pauli_strings = [_generate_random_pauli_string(qubits, True) for _ in range(3)]
|
|
889
|
+
sampler = cirq.Simulator()
|
|
890
|
+
|
|
891
|
+
circuit_results = sampler.run_batch(test_circuits, repetitions=1000)
|
|
892
|
+
|
|
893
|
+
empty_calibration_result_dict = {tuple(qubits): None}
|
|
894
|
+
|
|
895
|
+
with pytest.raises(
|
|
896
|
+
ValueError,
|
|
897
|
+
match="Readout mitigation is enabled, but no calibration result was found for qubits",
|
|
898
|
+
):
|
|
899
|
+
_process_pauli_measurement_results(
|
|
900
|
+
qubits,
|
|
901
|
+
[pauli_strings],
|
|
902
|
+
circuit_results[0], # type: ignore[arg-type]
|
|
903
|
+
empty_calibration_result_dict, # type: ignore[arg-type]
|
|
904
|
+
1000,
|
|
905
|
+
1.0,
|
|
906
|
+
)
|
|
@@ -179,6 +179,17 @@ class SingleQubitReadoutCalibrationResult:
|
|
|
179
179
|
ax.set_ylabel('Percentile')
|
|
180
180
|
return ax
|
|
181
181
|
|
|
182
|
+
def readout_result_for_qubits(
|
|
183
|
+
self, readout_qubits: list[ops.Qid]
|
|
184
|
+
) -> SingleQubitReadoutCalibrationResult:
|
|
185
|
+
"""Builds a calibration result for the specific readout qubits."""
|
|
186
|
+
return SingleQubitReadoutCalibrationResult(
|
|
187
|
+
zero_state_errors={qubit: self.zero_state_errors[qubit] for qubit in readout_qubits},
|
|
188
|
+
one_state_errors={qubit: self.one_state_errors[qubit] for qubit in readout_qubits},
|
|
189
|
+
timestamp=self.timestamp,
|
|
190
|
+
repetitions=self.repetitions,
|
|
191
|
+
)
|
|
192
|
+
|
|
182
193
|
@classmethod
|
|
183
194
|
def _from_json_dict_(
|
|
184
195
|
cls, zero_state_errors, one_state_errors, repetitions, timestamp, **kwargs
|
{cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.6.0.
|
|
3
|
+
Version: 1.6.0.dev20250624001344
|
|
4
4
|
Summary: A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
|
|
5
5
|
Home-page: http://github.com/quantumlib/cirq
|
|
6
6
|
Author: The Cirq Developers
|
{cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=emXpdD5ZvwLRlFAoQB8YatmZyU3b4e9jg6FppMTUhkU,33900
|
|
|
4
4
|
cirq/_doc.py,sha256=BrnoABo1hk5RgB3Cgww4zLHUfiyFny0F1V-tOMCbdaU,2909
|
|
5
5
|
cirq/_import.py,sha256=ixBu4EyGl46Ram2cP3p5eZVEFDW5L2DS-VyTjz4N9iw,8429
|
|
6
6
|
cirq/_import_test.py,sha256=oF4izzOVZLc7NZ0aZHFcGv-r01eiFFt_JORx_x7_D4s,1089
|
|
7
|
-
cirq/_version.py,sha256=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=8jHtusBUxrO8TPHKmIvvUfrqxtk2T092arLqOkcHbDA,1206
|
|
8
|
+
cirq/_version_test.py,sha256=4r41osEcge0AGQg8uFjE4K2PQtDc8mibS4SUaUgo6cY,155
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=hYyG53VJeV61X0oukK5ndZYega8lkL2FyaL1m0j6h5M,13556
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
@@ -96,8 +96,8 @@ cirq/contrib/paulistring/optimize.py,sha256=F02c_9nuc8a41XNsA9bzTGaW2kR3hZw-MdaQ
|
|
|
96
96
|
cirq/contrib/paulistring/optimize_test.py,sha256=FsmwyYFIGyyiO115oYgmCfaSV3De55Azd0_rzsi_xnU,3618
|
|
97
97
|
cirq/contrib/paulistring/pauli_string_dag.py,sha256=28bUVNsIS9WYKdyYCNIVrkRwqQOKlkpmCacWow6N6D0,1142
|
|
98
98
|
cirq/contrib/paulistring/pauli_string_dag_test.py,sha256=nH_1h5LQobV9rb5gitLmrvpIwWwrcRmNdUGDAhFMZtI,1168
|
|
99
|
-
cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py,sha256=
|
|
100
|
-
cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py,sha256=
|
|
99
|
+
cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py,sha256=tjN3R_aq5xwixlO8pCHaiWX4LsXXJHQxAEZgUHSgQac,21021
|
|
100
|
+
cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py,sha256=PLFPOfhoIepk-UhgEBcfvFnFtd0qpqLSPtvrcCaKpd0,36842
|
|
101
101
|
cirq/contrib/paulistring/pauli_string_optimize.py,sha256=ejHf7Bo0iUvnNBeZ5IN0bT0SIXF79DSGr1NxoAyVfiQ,2960
|
|
102
102
|
cirq/contrib/paulistring/pauli_string_optimize_test.py,sha256=_14FS9TAvzRsmnTZxJUsMXPNcenv5mb0eD2gGTxvohE,2955
|
|
103
103
|
cirq/contrib/paulistring/recombine.py,sha256=phJ-SY4zdqZpIZca0iSsY0lK6NdXd0M0sOOWnUdGn5U,4353
|
|
@@ -193,7 +193,7 @@ cirq/experiments/random_quantum_circuit_generation.py,sha256=pV6ubukLLdfPXLvJD2t
|
|
|
193
193
|
cirq/experiments/random_quantum_circuit_generation_test.py,sha256=4GSfUK2hw2r90JAO7R2zSBqjtwWi8vXuAhw-iK6quwY,16512
|
|
194
194
|
cirq/experiments/readout_confusion_matrix.py,sha256=ro3miCMr8K-EDW918PHKL_QcqrDUT-_uTXUvJ1PPzEI,20666
|
|
195
195
|
cirq/experiments/readout_confusion_matrix_test.py,sha256=DNapm_kLa0Mn9vW_KejWKrmM4yqJ8Q-7gqxNjFkOFQU,10668
|
|
196
|
-
cirq/experiments/single_qubit_readout_calibration.py,sha256
|
|
196
|
+
cirq/experiments/single_qubit_readout_calibration.py,sha256=0vnmKBtcjS8kCbJj_iJ0BWW23W6UCc4X2Ig9N_UUs0s,15243
|
|
197
197
|
cirq/experiments/single_qubit_readout_calibration_test.py,sha256=HQE29SxyL2mUhvNZnV9F_vOaAIJteox7volmDfZQy8g,7751
|
|
198
198
|
cirq/experiments/t1_decay_experiment.py,sha256=ojtmkQ5mgiQ-cK389YrvlRXotzHon83HNG_8sae-JdE,7099
|
|
199
199
|
cirq/experiments/t1_decay_experiment_test.py,sha256=vjm-zV0a2yrFrFhzq03GOMBy5U_XnvX1Ga3NN4FiT3k,9262
|
|
@@ -1220,8 +1220,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
|
|
|
1220
1220
|
cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
|
|
1221
1221
|
cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
|
|
1222
1222
|
cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
|
|
1223
|
-
cirq_core-1.6.0.
|
|
1224
|
-
cirq_core-1.6.0.
|
|
1225
|
-
cirq_core-1.6.0.
|
|
1226
|
-
cirq_core-1.6.0.
|
|
1227
|
-
cirq_core-1.6.0.
|
|
1223
|
+
cirq_core-1.6.0.dev20250624001344.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1224
|
+
cirq_core-1.6.0.dev20250624001344.dist-info/METADATA,sha256=NZAaS9bVYy5EqTBayzbSbFO0O_Rps_DMlh6KaNftM5w,4857
|
|
1225
|
+
cirq_core-1.6.0.dev20250624001344.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
1226
|
+
cirq_core-1.6.0.dev20250624001344.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1227
|
+
cirq_core-1.6.0.dev20250624001344.dist-info/RECORD,,
|
{cirq_core-1.6.0.dev20250623211210.dist-info → cirq_core-1.6.0.dev20250624001344.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|