cirq-core 1.7.0.dev20250825174419__py3-none-any.whl → 1.7.0.dev20250825220830__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 CHANGED
@@ -28,4 +28,4 @@ if sys.version_info < (3, 11, 0): # pragma: no cover
28
28
  'of Cirq (e.g. "python -m pip install cirq==1.5.0")'
29
29
  )
30
30
 
31
- __version__ = "1.7.0.dev20250825174419"
31
+ __version__ = "1.7.0.dev20250825220830"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version() -> None:
6
- assert cirq.__version__ == "1.7.0.dev20250825174419"
6
+ assert cirq.__version__ == "1.7.0.dev20250825220830"
@@ -18,7 +18,7 @@ import dataclasses
18
18
  import functools
19
19
  import itertools
20
20
  import uuid
21
- from typing import Any, cast, Iterator, Mapping, Sequence, TYPE_CHECKING
21
+ from typing import Any, cast, Iterator, Mapping, Optional, Sequence, TYPE_CHECKING
22
22
 
23
23
  import attrs
24
24
  import numpy as np
@@ -73,7 +73,12 @@ class Cliffords:
73
73
  class RandomizedBenchMarkResult:
74
74
  """Results from a randomized benchmarking experiment."""
75
75
 
76
- def __init__(self, num_cliffords: Sequence[int], ground_state_probabilities: Sequence[float]):
76
+ def __init__(
77
+ self,
78
+ num_cliffords: Sequence[int],
79
+ ground_state_probabilities: Sequence[float],
80
+ ground_state_probabilities_std: Optional[Sequence[float]] | None = None,
81
+ ):
77
82
  """Inits RandomizedBenchMarkResult.
78
83
 
79
84
  Args:
@@ -81,9 +86,20 @@ class RandomizedBenchMarkResult:
81
86
  study.
82
87
  ground_state_probabilities: The corresponding average ground state
83
88
  probabilities.
89
+ ground_state_probabilities_std: The standard deviation of the probabilities.
84
90
  """
85
91
  self._num_cfds_seq = num_cliffords
86
92
  self._gnd_state_probs = ground_state_probabilities
93
+ if ground_state_probabilities_std is None or np.all(
94
+ np.isclose(ground_state_probabilities_std, 0)
95
+ ):
96
+ self._gnd_state_probs_std = None
97
+ else:
98
+ self._gnd_state_probs_std = np.array(ground_state_probabilities_std)
99
+ zeros = np.isclose(self._gnd_state_probs_std, 0)
100
+ self._gnd_state_probs_std[zeros] = self._gnd_state_probs_std[
101
+ np.logical_not(zeros)
102
+ ].min()
87
103
 
88
104
  @property
89
105
  def data(self) -> Sequence[tuple[int, float]]:
@@ -142,6 +158,7 @@ class RandomizedBenchMarkResult:
142
158
  f=exp_fit,
143
159
  xdata=self._num_cfds_seq,
144
160
  ydata=self._gnd_state_probs,
161
+ sigma=self._gnd_state_probs_std,
145
162
  p0=[0.5, 0.5, 1.0 - 1e-3],
146
163
  bounds=([0, -1, 0], [1, 1, 1]),
147
164
  )
@@ -534,6 +551,7 @@ def parallel_single_qubit_rb(
534
551
  # run circuits
535
552
  results = sampler.run_batch(circuits_all, repetitions=parameters.repetitions)
536
553
  gnd_probs: dict = {q: [] for q in qubits}
554
+ gnd_probs_std: dict = {q: [] for q in qubits}
537
555
  idx = 0
538
556
  for num_cliffords in parameters.num_clifford_range:
539
557
  excited_probs: dict[cirq.Qid, list[float]] = {q: [] for q in qubits}
@@ -544,9 +562,17 @@ def parallel_single_qubit_rb(
544
562
  idx += 1
545
563
  for qubit in qubits:
546
564
  gnd_probs[qubit].append(1.0 - np.mean(excited_probs[qubit]))
565
+ gnd_probs_std[qubit].append(
566
+ np.std(excited_probs[qubit]) / np.sqrt(parameters.repetitions)
567
+ )
547
568
 
548
569
  return ParallelRandomizedBenchmarkingResult(
549
- {q: RandomizedBenchMarkResult(parameters.num_clifford_range, gnd_probs[q]) for q in qubits}
570
+ {
571
+ q: RandomizedBenchMarkResult(
572
+ parameters.num_clifford_range, gnd_probs[q], gnd_probs_std[q]
573
+ )
574
+ for q in qubits
575
+ }
550
576
  )
551
577
 
552
578
 
@@ -595,6 +621,7 @@ def two_qubit_randomized_benchmarking(
595
621
  cliffords = _single_qubit_cliffords()
596
622
  cfd_matrices = _two_qubit_clifford_matrices(first_qubit, second_qubit, cliffords)
597
623
  gnd_probs = []
624
+ gnd_probs_std = []
598
625
  for num_cfds in num_clifford_range:
599
626
  gnd_probs_l = []
600
627
  for _ in range(num_circuits):
@@ -606,8 +633,9 @@ def two_qubit_randomized_benchmarking(
606
633
  gnds = [(not r[0] and not r[1]) for r in results.measurements['z']]
607
634
  gnd_probs_l.append(np.mean(gnds))
608
635
  gnd_probs.append(float(np.mean(gnd_probs_l)))
636
+ gnd_probs_std.append(float(np.std(gnd_probs_l) / np.sqrt(repetitions)))
609
637
 
610
- return RandomizedBenchMarkResult(num_clifford_range, gnd_probs)
638
+ return RandomizedBenchMarkResult(num_clifford_range, gnd_probs, gnd_probs_std)
611
639
 
612
640
 
613
641
  def single_qubit_state_tomography(
@@ -140,6 +140,22 @@ def test_parallel_single_qubit_parallel_single_qubit_randomized_benchmarking() -
140
140
  _ = results.plot_integrated_histogram()
141
141
 
142
142
 
143
+ @mock.patch.dict(os.environ, clear='CIRQ_TESTING')
144
+ def test_parallel_single_qubit_randomized_benchmarking_with_noise() -> None:
145
+ simulator = sim.Simulator(noise=cirq.depolarize(1e-3), seed=0)
146
+ qubits = (GridQubit(0, 0), GridQubit(0, 1))
147
+ num_cfds = range(5, 7, 1)
148
+ results = parallel_single_qubit_randomized_benchmarking(
149
+ simulator, num_clifford_range=num_cfds, repetitions=10, qubits=qubits
150
+ )
151
+ for qubit in qubits:
152
+ g_pops = np.asarray(results.results_dictionary[qubit].data)[:, 1]
153
+ assert np.isclose(np.mean(g_pops), 0.99, atol=1e-2)
154
+ _ = results.plot_single_qubit(qubit)
155
+ pauli_errors = results.pauli_error()
156
+ assert len(pauli_errors) == len(qubits)
157
+
158
+
143
159
  def test_two_qubit_randomized_benchmarking() -> None:
144
160
  # Check that the ground state population at the end of the Clifford
145
161
  # sequences is always unity.
cirq/ops/pauli_string.py CHANGED
@@ -1008,7 +1008,7 @@ class PauliString(raw_types.Operation, Generic[TKey]):
1008
1008
  """
1009
1009
  return self.conjugated_by(ops)
1010
1010
 
1011
- @deprecated(deadline="v2.0", fix="Use conjuagetd_by()/before()/after() instead.")
1011
+ @deprecated(deadline="v2.0", fix="Use conjugated_by(), before(), or after() instead.")
1012
1012
  def pass_operations_over(
1013
1013
  self, ops: Iterable[cirq.Operation], after_to_before: bool = False
1014
1014
  ) -> PauliString: # pragma: no cover
@@ -200,7 +200,7 @@ class PauliStringPhasor(gate_operation.GateOperation):
200
200
  pn = self.exponent_neg
201
201
  return PauliStringPhasor(new_pauli_string, exponent_pos=pp, exponent_neg=pn)
202
202
 
203
- @deprecated(deadline="v2.0", fix="Use conjuagetd_by() instead.")
203
+ @deprecated(deadline="v2.0", fix="Use conjugated_by() instead.")
204
204
  def pass_operations_over(
205
205
  self, ops: Iterable[raw_types.Operation], after_to_before: bool = False
206
206
  ) -> PauliStringPhasor: # pragma: no cover
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.7.0.dev20250825174419
3
+ Version: 1.7.0.dev20250825220830
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
@@ -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=YIvBpq_l5SLKoWa186LrENBpt1M757ZL_SWUU3va528,1206
8
- cirq/_version_test.py,sha256=222LlxGJYKlSh0nN-Yy_DG8HY35rqZRmH4QDAEujyjk,155
7
+ cirq/_version.py,sha256=5JYjiFhvPsT5D7qWRyEQWiLi0bdLQhQsnRabLANsV70,1206
8
+ cirq/_version_test.py,sha256=ZvimSeW5uNyVuBVSTq5v_yHrJPL-7Yp0loYJrEx-ZPI,155
9
9
  cirq/conftest.py,sha256=wSDKNdIQRDfLnXvOCWD3erheOw8JHRhdfQ53EyTUIXg,1239
10
10
  cirq/json_resolver_cache.py,sha256=A5DIgFAY1hUNt9vai_C3-gGBv24116CJMzQxMcXOax4,13726
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -199,8 +199,8 @@ cirq/experiments/n_qubit_tomography.py,sha256=16u0Tv14SyUM9WCk-ZxbBit9cl93MbZodG
199
199
  cirq/experiments/n_qubit_tomography_test.py,sha256=8wIgs0O8DtlCGOyC0MZA_d3tLNoURX1ARcqnnp1360g,4439
200
200
  cirq/experiments/purity_estimation.py,sha256=20MRvxDyxlcnWkwI94_PzMexOytS3NgnaaVbtFwLv2c,2516
201
201
  cirq/experiments/purity_estimation_test.py,sha256=ZDU6k-pja5W5kQ-5cy4id1IWUQ86WMiQYNOiXyAI0YU,967
202
- cirq/experiments/qubit_characterizations.py,sha256=RO-gxOI_7n4HhGOmumgLGacV4Ve8bAY_s7XyxkOTUjo,40887
203
- cirq/experiments/qubit_characterizations_test.py,sha256=gcMeYJLMWvboZGJqOicNAmGV736Ty1I5D5Ihd4EHOf0,11066
202
+ cirq/experiments/qubit_characterizations.py,sha256=FaCyAiBbiuzQvVT8YNjxZnuNvyrGMlxraQTjnoPUlKA,41990
203
+ cirq/experiments/qubit_characterizations_test.py,sha256=z5WFvZmFtvm3j2W_aF6A-dzPKvoYcW8KdD7zccW0aKk,11775
204
204
  cirq/experiments/random_quantum_circuit_generation.py,sha256=90iD2KulPXKy9mu5MiHnir2ozCJ5bgGBzxNv9odw5FY,28016
205
205
  cirq/experiments/random_quantum_circuit_generation_test.py,sha256=R4ShY12vAfLd4fTT9mX0VQM9VQol58ZdPsqBkZvFds4,16737
206
206
  cirq/experiments/readout_confusion_matrix.py,sha256=qK6qDoNRuIHGTV7PS8xGkS7tCXGGyoDfUJJj6575-cE,20664
@@ -351,8 +351,8 @@ cirq/ops/pauli_interaction_gate.py,sha256=1drxD57PLCmp7dI9p5oDX2HPzsqwh0rrqHltUj
351
351
  cirq/ops/pauli_interaction_gate_test.py,sha256=9IGQjf4cRNe1EAsxVJjTMysoO2TxUhDlp-6lXJuAYD8,4643
352
352
  cirq/ops/pauli_measurement_gate.py,sha256=OzbQeMzr9cHQsai8K-usg3Il74o8gdXZLksLuYr8RcU,7113
353
353
  cirq/ops/pauli_measurement_gate_test.py,sha256=IDnbQgyaj-nbYw_sslPBccl8aRGTlMrADc_EEiAvluk,6929
354
- cirq/ops/pauli_string.py,sha256=_OYVeQ9G9sgim636rdrqD3h-KyPhuYHMqBRE8lTy6e8,64066
355
- cirq/ops/pauli_string_phasor.py,sha256=JLKZem7rdshQ0doNvFMJmP7cLhl9lCsHAI1QlOmbmrg,18207
354
+ cirq/ops/pauli_string.py,sha256=FaigNkmYOizcxEEgV_sZyAxffG7_JnyB6fbbeUyTEqk,64071
355
+ cirq/ops/pauli_string_phasor.py,sha256=5Tm_OoR_v44Kb3AQAw5XIxpcmKtompdbq5ZefYGEUmk,18207
356
356
  cirq/ops/pauli_string_phasor_test.py,sha256=ZIoraHH3kOFjtEfThXDS-sxUvSU8MYZ2avtdiPcyN6w,28309
357
357
  cirq/ops/pauli_string_raw_types.py,sha256=mBOAwfBT_y7yiSyC6Hr-ofLyIkjyOH5urmK-gitD3-Y,2226
358
358
  cirq/ops/pauli_string_raw_types_test.py,sha256=ZcOZ31KSVIc7ReZoO8WZEX8MOyPOhUWaYLppvGTE4-8,2761
@@ -1234,8 +1234,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
1234
1234
  cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
1235
1235
  cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
1236
1236
  cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
1237
- cirq_core-1.7.0.dev20250825174419.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1238
- cirq_core-1.7.0.dev20250825174419.dist-info/METADATA,sha256=HDtfPmc5sbaI5AMAN1fSFVDxaZynP1vayAB05Ci0CfE,4819
1239
- cirq_core-1.7.0.dev20250825174419.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1240
- cirq_core-1.7.0.dev20250825174419.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1241
- cirq_core-1.7.0.dev20250825174419.dist-info/RECORD,,
1237
+ cirq_core-1.7.0.dev20250825220830.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1238
+ cirq_core-1.7.0.dev20250825220830.dist-info/METADATA,sha256=UK6Y-rNaCiFxLMEc2kNKzJbq_RUPTIsALqm-Fuv9Zqo,4819
1239
+ cirq_core-1.7.0.dev20250825220830.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1240
+ cirq_core-1.7.0.dev20250825220830.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1241
+ cirq_core-1.7.0.dev20250825220830.dist-info/RECORD,,