cirq-core 1.5.0.dev20241108000946__py3-none-any.whl → 1.5.0.dev20241108182643__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/experiments/two_qubit_xeb.py +51 -12
- cirq/experiments/two_qubit_xeb_test.py +19 -2
- {cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/METADATA +1 -1
- {cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/RECORD +9 -9
- {cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/LICENSE +0 -0
- {cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/WHEEL +0 -0
- {cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
|
@@ -53,6 +53,46 @@ def _manhattan_distance(qubit1: 'cirq.GridQubit', qubit2: 'cirq.GridQubit') -> i
|
|
|
53
53
|
return abs(qubit1.row - qubit2.row) + abs(qubit1.col - qubit2.col)
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
def qubits_and_pairs(
|
|
57
|
+
sampler: 'cirq.Sampler',
|
|
58
|
+
qubits: Optional[Sequence['cirq.GridQubit']] = None,
|
|
59
|
+
pairs: Optional[Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]] = None,
|
|
60
|
+
) -> Tuple[Sequence['cirq.GridQubit'], Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]]:
|
|
61
|
+
"""Extract qubits and pairs from sampler.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
If qubits are not provided, then they are extracted from the pairs (if given) or the sampler.
|
|
65
|
+
If pairs are not provided then all pairs of adjacent qubits are used.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
sampler: The quantum engine or simulator to run the circuits.
|
|
69
|
+
qubits: Optional list of qubits.
|
|
70
|
+
pairs: Optional list of pair to use.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
- Qubits to use.
|
|
74
|
+
- Pairs of qubits to use.
|
|
75
|
+
|
|
76
|
+
Raises:
|
|
77
|
+
ValueError: If qubits are not specified and can't be deduced from other arguments.
|
|
78
|
+
"""
|
|
79
|
+
if qubits is None:
|
|
80
|
+
if pairs is None:
|
|
81
|
+
qubits = _grid_qubits_for_sampler(sampler)
|
|
82
|
+
if qubits is None:
|
|
83
|
+
raise ValueError("Couldn't determine qubits from sampler. Please specify them.")
|
|
84
|
+
else:
|
|
85
|
+
qubits_set = set(itertools.chain(*pairs))
|
|
86
|
+
qubits = list(qubits_set)
|
|
87
|
+
|
|
88
|
+
if pairs is None:
|
|
89
|
+
pairs = [
|
|
90
|
+
pair for pair in itertools.combinations(qubits, 2) if _manhattan_distance(*pair) == 1
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
return qubits, pairs
|
|
94
|
+
|
|
95
|
+
|
|
56
96
|
@dataclass(frozen=True)
|
|
57
97
|
class TwoQubitXEBResult:
|
|
58
98
|
"""Results from an XEB experiment."""
|
|
@@ -359,6 +399,7 @@ def parallel_xeb_workflow(
|
|
|
359
399
|
cycle_depths: Sequence[int] = (5, 25, 50, 100, 200, 300),
|
|
360
400
|
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
|
|
361
401
|
ax: Optional[plt.Axes] = None,
|
|
402
|
+
pairs: Optional[Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]] = None,
|
|
362
403
|
pool: Optional['multiprocessing.pool.Pool'] = None,
|
|
363
404
|
**plot_kwargs,
|
|
364
405
|
) -> Tuple[pd.DataFrame, Sequence['cirq.Circuit'], pd.DataFrame]:
|
|
@@ -375,6 +416,7 @@ def parallel_xeb_workflow(
|
|
|
375
416
|
random_state: The random state to use.
|
|
376
417
|
ax: the plt.Axes to plot the device layout on. If not given,
|
|
377
418
|
no plot is created.
|
|
419
|
+
pairs: Pairs to use. If not specified, use all pairs between adjacent qubits.
|
|
378
420
|
pool: An optional multiprocessing pool.
|
|
379
421
|
**plot_kwargs: Arguments to be passed to 'plt.Axes.plot'.
|
|
380
422
|
|
|
@@ -391,14 +433,8 @@ def parallel_xeb_workflow(
|
|
|
391
433
|
"""
|
|
392
434
|
rs = value.parse_random_state(random_state)
|
|
393
435
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if qubits is None:
|
|
397
|
-
raise ValueError("Couldn't determine qubits from sampler. Please specify them.")
|
|
398
|
-
|
|
399
|
-
graph = nx.Graph(
|
|
400
|
-
pair for pair in itertools.combinations(qubits, 2) if _manhattan_distance(*pair) == 1
|
|
401
|
-
)
|
|
436
|
+
qubits, pairs = qubits_and_pairs(sampler, qubits, pairs)
|
|
437
|
+
graph = nx.Graph(pairs)
|
|
402
438
|
|
|
403
439
|
if ax is not None:
|
|
404
440
|
nx.draw_networkx(graph, pos={q: (q.row, q.col) for q in qubits}, ax=ax)
|
|
@@ -445,6 +481,7 @@ def parallel_two_qubit_xeb(
|
|
|
445
481
|
cycle_depths: Sequence[int] = (5, 25, 50, 100, 200, 300),
|
|
446
482
|
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
|
|
447
483
|
ax: Optional[plt.Axes] = None,
|
|
484
|
+
pairs: Optional[Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]] = None,
|
|
448
485
|
**plot_kwargs,
|
|
449
486
|
) -> TwoQubitXEBResult:
|
|
450
487
|
"""A convenience method that runs the full XEB workflow.
|
|
@@ -460,6 +497,7 @@ def parallel_two_qubit_xeb(
|
|
|
460
497
|
random_state: The random state to use.
|
|
461
498
|
ax: the plt.Axes to plot the device layout on. If not given,
|
|
462
499
|
no plot is created.
|
|
500
|
+
pairs: Pairs to use. If not specified, use all pairs between adjacent qubits.
|
|
463
501
|
**plot_kwargs: Arguments to be passed to 'plt.Axes.plot'.
|
|
464
502
|
Returns:
|
|
465
503
|
A TwoQubitXEBResult object representing the results of the experiment.
|
|
@@ -469,6 +507,7 @@ def parallel_two_qubit_xeb(
|
|
|
469
507
|
fids, *_ = parallel_xeb_workflow(
|
|
470
508
|
sampler=sampler,
|
|
471
509
|
qubits=qubits,
|
|
510
|
+
pairs=pairs,
|
|
472
511
|
entangling_gate=entangling_gate,
|
|
473
512
|
n_repetitions=n_repetitions,
|
|
474
513
|
n_combinations=n_combinations,
|
|
@@ -493,6 +532,7 @@ def run_rb_and_xeb(
|
|
|
493
532
|
depths_xeb: Sequence[int] = (5, 25, 50, 100, 200, 300),
|
|
494
533
|
xeb_combinations: int = 10,
|
|
495
534
|
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
|
|
535
|
+
pairs: Optional[Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]] = None,
|
|
496
536
|
) -> InferredXEBResult:
|
|
497
537
|
"""A convenience method that runs both RB and XEB workflows.
|
|
498
538
|
|
|
@@ -506,6 +546,7 @@ def run_rb_and_xeb(
|
|
|
506
546
|
depths_xeb: The cycle depths to use for XEB.
|
|
507
547
|
xeb_combinations: The number of combinations to generate for XEB.
|
|
508
548
|
random_state: The random state to use.
|
|
549
|
+
pairs: Pairs to use. If not specified, use all pairs between adjacent qubits.
|
|
509
550
|
|
|
510
551
|
Returns:
|
|
511
552
|
An InferredXEBResult object representing the results of the experiment.
|
|
@@ -514,10 +555,7 @@ def run_rb_and_xeb(
|
|
|
514
555
|
ValueError: If qubits are not specified and the sampler has no device.
|
|
515
556
|
"""
|
|
516
557
|
|
|
517
|
-
|
|
518
|
-
qubits = _grid_qubits_for_sampler(sampler)
|
|
519
|
-
if qubits is None:
|
|
520
|
-
raise ValueError("Couldn't determine qubits from sampler. Please specify them.")
|
|
558
|
+
qubits, pairs = qubits_and_pairs(sampler, qubits, pairs)
|
|
521
559
|
|
|
522
560
|
rb = parallel_single_qubit_randomized_benchmarking(
|
|
523
561
|
sampler=sampler,
|
|
@@ -530,6 +568,7 @@ def run_rb_and_xeb(
|
|
|
530
568
|
xeb = parallel_two_qubit_xeb(
|
|
531
569
|
sampler=sampler,
|
|
532
570
|
qubits=qubits,
|
|
571
|
+
pairs=pairs,
|
|
533
572
|
entangling_gate=entangling_gate,
|
|
534
573
|
n_repetitions=repetitions,
|
|
535
574
|
n_circuits=num_circuits,
|
|
@@ -261,26 +261,43 @@ def test_inferred_plots(ax, target_error, kind):
|
|
|
261
261
|
|
|
262
262
|
|
|
263
263
|
@pytest.mark.parametrize(
|
|
264
|
-
'sampler,qubits',
|
|
264
|
+
'sampler,qubits,pairs',
|
|
265
265
|
[
|
|
266
266
|
(
|
|
267
267
|
cirq.DensityMatrixSimulator(
|
|
268
268
|
seed=0, noise=cirq.ConstantQubitNoiseModel(cirq.amplitude_damp(0.1))
|
|
269
269
|
),
|
|
270
270
|
cirq.GridQubit.rect(3, 2, 4, 3),
|
|
271
|
+
None,
|
|
272
|
+
),
|
|
273
|
+
(
|
|
274
|
+
cirq.DensityMatrixSimulator(
|
|
275
|
+
seed=0, noise=cirq.ConstantQubitNoiseModel(cirq.amplitude_damp(0.1))
|
|
276
|
+
),
|
|
277
|
+
None,
|
|
278
|
+
[
|
|
279
|
+
(cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)),
|
|
280
|
+
(cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)),
|
|
281
|
+
],
|
|
271
282
|
),
|
|
272
283
|
(
|
|
273
284
|
DensityMatrixSimulatorWithProcessor(
|
|
274
285
|
seed=0, noise=cirq.ConstantQubitNoiseModel(cirq.amplitude_damp(0.1))
|
|
275
286
|
),
|
|
276
287
|
None,
|
|
288
|
+
None,
|
|
277
289
|
),
|
|
278
290
|
],
|
|
279
291
|
)
|
|
280
|
-
def test_run_rb_and_xeb(
|
|
292
|
+
def test_run_rb_and_xeb(
|
|
293
|
+
sampler: cirq.Sampler,
|
|
294
|
+
qubits: Optional[Sequence[cirq.GridQubit]],
|
|
295
|
+
pairs: Optional[Sequence[tuple[cirq.GridQubit, cirq.GridQubit]]],
|
|
296
|
+
):
|
|
281
297
|
res = cirq.experiments.run_rb_and_xeb(
|
|
282
298
|
sampler=sampler,
|
|
283
299
|
qubits=qubits,
|
|
300
|
+
pairs=pairs,
|
|
284
301
|
repetitions=100,
|
|
285
302
|
num_clifford_range=tuple(np.arange(3, 10, 1)),
|
|
286
303
|
xeb_combinations=1,
|
{cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.5.0.
|
|
3
|
+
Version: 1.5.0.dev20241108182643
|
|
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.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ 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=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=feprtOmxGB6-eC9uB0sJ-djGJkyXZgQvyA72W_9WUJA,1206
|
|
8
|
+
cirq/_version_test.py,sha256=406ziBxrNleUa6rLZarB--prKsEz8MCsErm1L3gt_6g,147
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=ytePZtNZgKjOF2NiVpUTuotB-JKZmQNOFIFdvXqsxHw,13271
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
@@ -196,8 +196,8 @@ cirq/experiments/t1_decay_experiment.py,sha256=ealdmc_RTE__z1YUcaDEncDzQOaiT0K6I
|
|
|
196
196
|
cirq/experiments/t1_decay_experiment_test.py,sha256=Pgbm-37JiCdw9iQg2OaXVvs72xGWV2629CgsTQlLQnw,9139
|
|
197
197
|
cirq/experiments/t2_decay_experiment.py,sha256=lTgZ9yJ7Fk9_ozUCHysQn1qKrMQwTpsgEv-QnvsEif0,19158
|
|
198
198
|
cirq/experiments/t2_decay_experiment_test.py,sha256=DFR0BGn0Id4qNPfqIExj70TEAqf7Vrc8eK91Wj0YKTc,15031
|
|
199
|
-
cirq/experiments/two_qubit_xeb.py,sha256=
|
|
200
|
-
cirq/experiments/two_qubit_xeb_test.py,sha256=
|
|
199
|
+
cirq/experiments/two_qubit_xeb.py,sha256=QsGQ-wR8T-m4YhOOJ1COXKi6roJuZmFuv1u8YWXkHBI,21636
|
|
200
|
+
cirq/experiments/two_qubit_xeb_test.py,sha256=wJi-ulxtSJyE5pzJPoUgoV8X2NLZG_H0jlW1JKHSo_I,10681
|
|
201
201
|
cirq/experiments/xeb_fitting.py,sha256=Tzo2kg62udpRp654XArSDVcyVNhlhkNmpx9UVyxZiiw,30337
|
|
202
202
|
cirq/experiments/xeb_fitting_test.py,sha256=0GQ6ifSWdvEJ6-ICIcSR-R9lFLRwBykgf6toLElmg0o,15483
|
|
203
203
|
cirq/experiments/xeb_sampling.py,sha256=6ZOidGi7Kt6p4cMQCjK7qQuIUXVHCYl47B2GnL8M-Bw,14987
|
|
@@ -1188,8 +1188,8 @@ cirq/work/sampler.py,sha256=BDd1HrUOOcHBOvXNJqVX0vRcvmm8btZmZa5yYC5y8n0,19856
|
|
|
1188
1188
|
cirq/work/sampler_test.py,sha256=hL2UWx3dz2ukZVNxWftiKVvJcQoLplLZdQm-k1QcA40,13282
|
|
1189
1189
|
cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
|
|
1190
1190
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1191
|
-
cirq_core-1.5.0.
|
|
1192
|
-
cirq_core-1.5.0.
|
|
1193
|
-
cirq_core-1.5.0.
|
|
1194
|
-
cirq_core-1.5.0.
|
|
1195
|
-
cirq_core-1.5.0.
|
|
1191
|
+
cirq_core-1.5.0.dev20241108182643.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1192
|
+
cirq_core-1.5.0.dev20241108182643.dist-info/METADATA,sha256=MRS0Cpo4ZLX3K_SGrWc1mWsAHkCDEmQKbqqVjEkTXwI,1992
|
|
1193
|
+
cirq_core-1.5.0.dev20241108182643.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
1194
|
+
cirq_core-1.5.0.dev20241108182643.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1195
|
+
cirq_core-1.5.0.dev20241108182643.dist-info/RECORD,,
|
{cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.5.0.dev20241108000946.dist-info → cirq_core-1.5.0.dev20241108182643.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|