cirq-core 1.4.0.dev20240117011228__py3-none-any.whl → 1.4.0.dev20240117184635__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/experiments/qubit_characterizations.py +130 -3
- cirq/experiments/qubit_characterizations_test.py +6 -1
- {cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/METADATA +1 -1
- {cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/RECORD +8 -8
- {cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/LICENSE +0 -0
- {cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/WHEEL +0 -0
- {cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.4.0.
|
|
1
|
+
__version__ = "1.4.0.dev20240117184635"
|
|
@@ -32,10 +32,14 @@ import numpy as np
|
|
|
32
32
|
from scipy.optimize import curve_fit
|
|
33
33
|
|
|
34
34
|
from matplotlib import pyplot as plt
|
|
35
|
+
import cirq.vis.heatmap as cirq_heatmap
|
|
36
|
+
import cirq.vis.histogram as cirq_histogram
|
|
35
37
|
|
|
36
38
|
# this is for older systems with matplotlib <3.2 otherwise 3d projections fail
|
|
37
39
|
from mpl_toolkits import mplot3d
|
|
38
40
|
from cirq import circuits, ops, protocols
|
|
41
|
+
from cirq.devices import grid_qubit
|
|
42
|
+
|
|
39
43
|
|
|
40
44
|
if TYPE_CHECKING:
|
|
41
45
|
import cirq
|
|
@@ -144,6 +148,127 @@ class RandomizedBenchMarkResult:
|
|
|
144
148
|
)
|
|
145
149
|
|
|
146
150
|
|
|
151
|
+
@dataclasses.dataclass(frozen=True)
|
|
152
|
+
class ParallelRandomizedBenchmarkingResult:
|
|
153
|
+
"""Results from a parallel randomized benchmarking experiment."""
|
|
154
|
+
|
|
155
|
+
results_dictionary: Mapping['cirq.Qid', 'RandomizedBenchMarkResult']
|
|
156
|
+
|
|
157
|
+
def plot_single_qubit(
|
|
158
|
+
self, qubit: 'cirq.Qid', ax: Optional[plt.Axes] = None, **plot_kwargs: Any
|
|
159
|
+
) -> plt.Axes:
|
|
160
|
+
"""Plot the raw data for the specified qubit.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
qubit: Plot data for this qubit.
|
|
164
|
+
ax: the plt.Axes to plot on. If not given, a new figure is created,
|
|
165
|
+
plotted on, and shown.
|
|
166
|
+
**plot_kwargs: Arguments to be passed to 'plt.Axes.plot'.
|
|
167
|
+
Returns:
|
|
168
|
+
The plt.Axes containing the plot.
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
return self.results_dictionary[qubit].plot(ax, **plot_kwargs)
|
|
172
|
+
|
|
173
|
+
def pauli_error(self) -> Mapping['cirq.Qid', float]:
|
|
174
|
+
"""Return a dictionary of Pauli errors.
|
|
175
|
+
Returns:
|
|
176
|
+
A dictionary containing the Pauli errors for all qubits.
|
|
177
|
+
"""
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
qubit: self.results_dictionary[qubit].pauli_error() for qubit in self.results_dictionary
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
def plot_heatmap(
|
|
184
|
+
self,
|
|
185
|
+
ax: Optional[plt.Axes] = None,
|
|
186
|
+
annotation_format: str = '0.1%',
|
|
187
|
+
title: str = 'Single-qubit Pauli error',
|
|
188
|
+
**plot_kwargs: Any,
|
|
189
|
+
) -> plt.Axes:
|
|
190
|
+
"""Plot a heatmap of the Pauli errors. If qubits are not cirq.GridQubits, throws an error.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
ax: the plt.Axes to plot on. If not given, a new figure is created,
|
|
194
|
+
plotted on, and shown.
|
|
195
|
+
annotation_format: The format string for the numbers in the heatmap.
|
|
196
|
+
title: The title printed above the heatmap.
|
|
197
|
+
**plot_kwargs: Arguments to be passed to 'cirq.Heatmap.plot()'.
|
|
198
|
+
Returns:
|
|
199
|
+
The plt.Axes containing the plot.
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
pauli_errors = self.pauli_error()
|
|
203
|
+
pauli_errors_with_grid_qubit_keys = {}
|
|
204
|
+
for qubit in pauli_errors:
|
|
205
|
+
assert type(qubit) == grid_qubit.GridQubit, "qubits must be cirq.GridQubits"
|
|
206
|
+
pauli_errors_with_grid_qubit_keys[qubit] = pauli_errors[qubit] # just for typecheck
|
|
207
|
+
|
|
208
|
+
if ax is None:
|
|
209
|
+
_, ax = plt.subplots(dpi=200, facecolor='white')
|
|
210
|
+
|
|
211
|
+
ax, _ = cirq_heatmap.Heatmap(pauli_errors_with_grid_qubit_keys).plot(
|
|
212
|
+
ax, annotation_format=annotation_format, title=title, **plot_kwargs
|
|
213
|
+
)
|
|
214
|
+
return ax
|
|
215
|
+
|
|
216
|
+
def plot_integrated_histogram(
|
|
217
|
+
self,
|
|
218
|
+
ax: Optional[plt.Axes] = None,
|
|
219
|
+
cdf_on_x: bool = False,
|
|
220
|
+
axis_label: str = 'Pauli error',
|
|
221
|
+
semilog: bool = True,
|
|
222
|
+
median_line: bool = True,
|
|
223
|
+
median_label: Optional[str] = 'median',
|
|
224
|
+
mean_line: bool = False,
|
|
225
|
+
mean_label: Optional[str] = 'mean',
|
|
226
|
+
show_zero: bool = False,
|
|
227
|
+
title: Optional[str] = None,
|
|
228
|
+
**kwargs,
|
|
229
|
+
) -> plt.Axes:
|
|
230
|
+
"""Plot the Pauli errors using cirq.integrated_histogram().
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
ax: The axis to plot on. If None, we generate one.
|
|
234
|
+
cdf_on_x: If True, flip the axes compared the above example.
|
|
235
|
+
axis_label: Label for x axis (y-axis if cdf_on_x is True).
|
|
236
|
+
semilog: If True, force the x-axis to be logarithmic.
|
|
237
|
+
median_line: If True, draw a vertical line on the median value.
|
|
238
|
+
median_label: If drawing median line, optional label for it.
|
|
239
|
+
mean_line: If True, draw a vertical line on the mean value.
|
|
240
|
+
mean_label: If drawing mean line, optional label for it.
|
|
241
|
+
title: Title of the plot. If None, we assign "N={len(data)}".
|
|
242
|
+
show_zero: If True, moves the step plot up by one unit by prepending 0
|
|
243
|
+
to the data.
|
|
244
|
+
**kwargs: Kwargs to forward to `ax.step()`. Some examples are
|
|
245
|
+
color: Color of the line.
|
|
246
|
+
linestyle: Linestyle to use for the plot.
|
|
247
|
+
lw: linewidth for integrated histogram.
|
|
248
|
+
ms: marker size for a histogram trace.
|
|
249
|
+
label: An optional label which can be used in a legend.
|
|
250
|
+
Returns:
|
|
251
|
+
The axis that was plotted on.
|
|
252
|
+
"""
|
|
253
|
+
|
|
254
|
+
ax = cirq_histogram.integrated_histogram(
|
|
255
|
+
data=self.pauli_error(),
|
|
256
|
+
ax=ax,
|
|
257
|
+
cdf_on_x=cdf_on_x,
|
|
258
|
+
axis_label=axis_label,
|
|
259
|
+
semilog=semilog,
|
|
260
|
+
median_line=median_line,
|
|
261
|
+
median_label=median_label,
|
|
262
|
+
mean_line=mean_line,
|
|
263
|
+
mean_label=mean_label,
|
|
264
|
+
show_zero=show_zero,
|
|
265
|
+
title=title,
|
|
266
|
+
**kwargs,
|
|
267
|
+
)
|
|
268
|
+
ax.set_ylabel('Percentile')
|
|
269
|
+
return ax
|
|
270
|
+
|
|
271
|
+
|
|
147
272
|
class TomographyResult:
|
|
148
273
|
"""Results from a state tomography experiment."""
|
|
149
274
|
|
|
@@ -265,7 +390,7 @@ def single_qubit_randomized_benchmarking(
|
|
|
265
390
|
num_circuits=num_circuits,
|
|
266
391
|
repetitions=repetitions,
|
|
267
392
|
)
|
|
268
|
-
return result[qubit]
|
|
393
|
+
return result.results_dictionary[qubit]
|
|
269
394
|
|
|
270
395
|
|
|
271
396
|
def parallel_single_qubit_randomized_benchmarking(
|
|
@@ -278,7 +403,7 @@ def parallel_single_qubit_randomized_benchmarking(
|
|
|
278
403
|
),
|
|
279
404
|
num_circuits: int = 10,
|
|
280
405
|
repetitions: int = 1000,
|
|
281
|
-
) ->
|
|
406
|
+
) -> 'ParallelRandomizedBenchmarkingResult':
|
|
282
407
|
"""Clifford-based randomized benchmarking (RB) single qubits in parallel.
|
|
283
408
|
|
|
284
409
|
This is the same as `single_qubit_randomized_benchmarking` except on all
|
|
@@ -321,7 +446,9 @@ def parallel_single_qubit_randomized_benchmarking(
|
|
|
321
446
|
idx += 1
|
|
322
447
|
for qubit in qubits:
|
|
323
448
|
gnd_probs[qubit].append(1.0 - np.mean(excited_probs[qubit]))
|
|
324
|
-
return
|
|
449
|
+
return ParallelRandomizedBenchmarkingResult(
|
|
450
|
+
{q: RandomizedBenchMarkResult(num_clifford_range, gnd_probs[q]) for q in qubits}
|
|
451
|
+
)
|
|
325
452
|
|
|
326
453
|
|
|
327
454
|
def two_qubit_randomized_benchmarking(
|
|
@@ -126,8 +126,13 @@ def test_parallel_single_qubit_randomized_benchmarking():
|
|
|
126
126
|
simulator, num_clifford_range=num_cfds, repetitions=100, qubits=qubits
|
|
127
127
|
)
|
|
128
128
|
for qubit in qubits:
|
|
129
|
-
g_pops = np.asarray(results[qubit].data)[:, 1]
|
|
129
|
+
g_pops = np.asarray(results.results_dictionary[qubit].data)[:, 1]
|
|
130
130
|
assert np.isclose(np.mean(g_pops), 1.0)
|
|
131
|
+
_ = results.plot_single_qubit(qubit)
|
|
132
|
+
pauli_errors = results.pauli_error()
|
|
133
|
+
assert len(pauli_errors) == len(qubits)
|
|
134
|
+
_ = results.plot_heatmap()
|
|
135
|
+
_ = results.plot_integrated_histogram()
|
|
131
136
|
|
|
132
137
|
|
|
133
138
|
def test_two_qubit_randomized_benchmarking():
|
{cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev20240117184635
|
|
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.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/RECORD
RENAMED
|
@@ -4,7 +4,7 @@ cirq/_compat_test.py,sha256=Qq3ZcfgD-Nb81cEppQdJqhAyrVqXKtfXZYGXT0p-Wh0,34718
|
|
|
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=
|
|
7
|
+
cirq/_version.py,sha256=f05_s3c7o10pZkJLa75XQH8qfQVyCvUETi-Wk17Emmc,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
|
|
188
|
-
cirq/experiments/qubit_characterizations_test.py,sha256=
|
|
187
|
+
cirq/experiments/qubit_characterizations.py,sha256=-VkwyvL6DanIfV4hiHflqupzvV33SFDfUN-p_qjGhyc,36637
|
|
188
|
+
cirq/experiments/qubit_characterizations_test.py,sha256=PuG7kgVFmflE0ZJJqLQbkLDL5bX0_anHBECdcY3DeMk,9256
|
|
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=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
|
|
|
1148
1148
|
cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
|
|
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.
|
|
1152
|
-
cirq_core-1.4.0.
|
|
1153
|
-
cirq_core-1.4.0.
|
|
1154
|
-
cirq_core-1.4.0.
|
|
1155
|
-
cirq_core-1.4.0.
|
|
1151
|
+
cirq_core-1.4.0.dev20240117184635.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1152
|
+
cirq_core-1.4.0.dev20240117184635.dist-info/METADATA,sha256=BLooGDTKxtGshmwe12wak3hde3CkjzrLqZmj3yKMjR0,2075
|
|
1153
|
+
cirq_core-1.4.0.dev20240117184635.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
1154
|
+
cirq_core-1.4.0.dev20240117184635.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1155
|
+
cirq_core-1.4.0.dev20240117184635.dist-info/RECORD,,
|
{cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.4.0.dev20240117011228.dist-info → cirq_core-1.4.0.dev20240117184635.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|