cirq-core 1.4.0.dev20231218225836__py3-none-any.whl → 1.4.0.dev20231218234457__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.
cirq/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.4.0.dev20231218225836"
1
+ __version__ = "1.4.0.dev20231218234457"
@@ -17,6 +17,7 @@ import itertools
17
17
 
18
18
  from typing import Any, cast, Iterator, List, Optional, Sequence, Tuple, TYPE_CHECKING
19
19
  import numpy as np
20
+ from scipy.optimize import curve_fit
20
21
 
21
22
  from matplotlib import pyplot as plt
22
23
 
@@ -92,13 +93,44 @@ class RandomizedBenchMarkResult:
92
93
  fig, ax = plt.subplots(1, 1, figsize=(8, 8)) # pragma: no cover
93
94
  ax = cast(plt.Axes, ax) # pragma: no cover
94
95
  ax.set_ylim((0.0, 1.0)) # pragma: no cover
95
- ax.plot(self._num_cfds_seq, self._gnd_state_probs, 'ro-', **plot_kwargs)
96
+ ax.plot(self._num_cfds_seq, self._gnd_state_probs, 'ro', label='data', **plot_kwargs)
97
+ x = np.linspace(self._num_cfds_seq[0], self._num_cfds_seq[-1], 100)
98
+ opt_params, _ = self._fit_exponential()
99
+ ax.plot(x, opt_params[0] * opt_params[2] ** x + opt_params[1], '--k', label='fit')
100
+ ax.legend(loc='upper right')
96
101
  ax.set_xlabel(r"Number of Cliffords")
97
102
  ax.set_ylabel('Ground State Probability')
98
103
  if show_plot:
99
104
  fig.show()
100
105
  return ax
101
106
 
107
+ def pauli_error(self) -> float:
108
+ r"""Returns the Pauli error inferred from randomized benchmarking.
109
+
110
+ If sequence fidelity $F$ decays with number of gates $m$ as
111
+
112
+ $$F = A p^m + B,$$
113
+
114
+ where $0 < p < 1$, then the Pauli error $r_p$ is given by
115
+
116
+ $$r_p = (1 - 1/d^2) * (1 - p),$$
117
+
118
+ where $d = 2^N_Q$ is the Hilbert space dimension and $N_Q$ is the number of qubits.
119
+ """
120
+ opt_params, _ = self._fit_exponential()
121
+ p = opt_params[2]
122
+ return (1.0 - 1.0 / 4.0) * (1.0 - p)
123
+
124
+ def _fit_exponential(self) -> Tuple[np.ndarray, np.ndarray]:
125
+ exp_fit = lambda x, A, B, p: A * p**x + B
126
+ return curve_fit(
127
+ f=exp_fit,
128
+ xdata=self._num_cfds_seq,
129
+ ydata=self._gnd_state_probs,
130
+ p0=[0.5, 0.5, 1.0 - 1e-3],
131
+ bounds=([0, 0.25, 0], [0.5, 0.75, 1]),
132
+ )
133
+
102
134
 
103
135
  class TomographyResult:
104
136
  """Results from a state tomography experiment."""
@@ -85,12 +85,11 @@ def test_single_qubit_randomized_benchmarking():
85
85
  # sequences is always unity.
86
86
  simulator = sim.Simulator()
87
87
  qubit = GridQubit(0, 0)
88
- num_cfds = range(5, 20, 5)
89
- results = single_qubit_randomized_benchmarking(
90
- simulator, qubit, num_clifford_range=num_cfds, repetitions=100
91
- )
88
+ num_cfds = tuple(np.logspace(np.log10(5), 3, 5, dtype=int))
89
+ results = single_qubit_randomized_benchmarking(simulator, qubit, num_clifford_range=num_cfds)
92
90
  g_pops = np.asarray(results.data)[:, 1]
93
91
  assert np.isclose(np.mean(g_pops), 1.0)
92
+ assert np.isclose(results.pauli_error(), 0.0, atol=1e-7) # warning is expected
94
93
 
95
94
 
96
95
  def test_two_qubit_randomized_benchmarking():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.4.0.dev20231218225836
3
+ Version: 1.4.0.dev20231218234457
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,7 +4,7 @@ cirq/_compat_test.py,sha256=iQJYqIP1uyRe8mNUwi2VKccyUaJDFYH7b3Fg6cqQLQw,35053
4
4
  cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
5
5
  cirq/_import.py,sha256=p9gMHJscbtDDkfHOaulvd3Aer0pwUF5AXpL89XR8dNw,8402
6
6
  cirq/_import_test.py,sha256=6K_v0riZJXOXUphHNkGA8MY-JcmGlezFaGmvrNhm3OQ,1015
7
- cirq/_version.py,sha256=oRrCwmW303NEQucRxIpvSR-ySp_dkNijl5czwtL8y-c,40
7
+ cirq/_version.py,sha256=-HaCO8zLtHZyG4GUXGGAwr_fP3r2hChhkbR5eMb7Ml0,40
8
8
  cirq/_version_test.py,sha256=yYS6xm5-nuBRQJa9R3n41WdvFtVyY7Lb5Q8bea3VgBI,133
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=S0HaPOCUIck-vNSQlS6KxnQtle6w-2dGuSxkUbJQY9Y,13168
@@ -184,8 +184,8 @@ cirq/experiments/n_qubit_tomography.py,sha256=9M_kf2-1hvFxfZOWND7ACwHYgD9SJU5nYF
184
184
  cirq/experiments/n_qubit_tomography_test.py,sha256=wHfV2OpGYSDXfoyEh-B5dc1Dv8sxKNFbUoHyjIWZoFk,4362
185
185
  cirq/experiments/purity_estimation.py,sha256=6D1UwFlQRzHeajXMTyTUfBYAc0jJQ8Cfz4lteFKeUaM,2467
186
186
  cirq/experiments/purity_estimation_test.py,sha256=xlBGp0NOBYR0IhTy3bckHPgi81FkGSGxKqk9hwXG-I8,923
187
- cirq/experiments/qubit_characterizations.py,sha256=cXREBqUIx4Z9hS57LbmWUkP0RL1McwZsUATGUil4W4E,27658
188
- cirq/experiments/qubit_characterizations_test.py,sha256=h0fd3y-wI2C7sVmjnjBgt7HuaU_IaOJ9trAnoiKL22c,7695
187
+ cirq/experiments/qubit_characterizations.py,sha256=nZMNmHCtTBx_AVmymStQomnN5IuNFBXKCABkYDqqgm0,28846
188
+ cirq/experiments/qubit_characterizations_test.py,sha256=5YYx-j04HzsF5nGtq0pxvAEUgXX9iE_7cdqVExdAoIo,7781
189
189
  cirq/experiments/random_quantum_circuit_generation.py,sha256=R_w7z35plUHEYBY0-F80bPcWJSSSjNQDaP2GbxVBEZg,28143
190
190
  cirq/experiments/random_quantum_circuit_generation_test.py,sha256=1rvgN8-Ajedn_70FyYKVzjvzR6NVpHj6KQgo6tra-Jc,15995
191
191
  cirq/experiments/readout_confusion_matrix.py,sha256=gsRjGJTDcxRPtY7G63t-nYoJ1BcByC1jl02zHh2B8fQ,17278
@@ -1148,8 +1148,8 @@ cirq/work/sampler.py,sha256=JVv1vvfa6EgFiR3UeDk44U186dCrioH2NZXueCgsb9w,19828
1148
1148
  cirq/work/sampler_test.py,sha256=zo1Hj6sn6fLs_WZMxYRApBqgBsldmptn74NL0jhNukc,12325
1149
1149
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1150
1150
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1151
- cirq_core-1.4.0.dev20231218225836.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1152
- cirq_core-1.4.0.dev20231218225836.dist-info/METADATA,sha256=vq0b3KlL_qSDD7sr_5OLi1R_6A2RBSodwc0ybvxezyc,2075
1153
- cirq_core-1.4.0.dev20231218225836.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
1154
- cirq_core-1.4.0.dev20231218225836.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1155
- cirq_core-1.4.0.dev20231218225836.dist-info/RECORD,,
1151
+ cirq_core-1.4.0.dev20231218234457.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1152
+ cirq_core-1.4.0.dev20231218234457.dist-info/METADATA,sha256=H_acyYJyfG7pF0SWcGIlaymmyuNddz4Z7Yc8F3el82k,2075
1153
+ cirq_core-1.4.0.dev20231218234457.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
1154
+ cirq_core-1.4.0.dev20231218234457.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1155
+ cirq_core-1.4.0.dev20231218234457.dist-info/RECORD,,