Skip to content

Commit df20ade

Browse files
Fix bug that caused XEB to fail when requesting depth > 100. (#6671)
* Pass max_cycle_depth to generate_library_of_2q_circuits * update default cycle depths * update default depths * Make notebook more robust to numerical errors
1 parent 8d09a32 commit df20ade

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

cirq-core/cirq/experiments/two_qubit_xeb.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def parallel_xeb_workflow(
354354
n_repetitions: int = 10**4,
355355
n_combinations: int = 10,
356356
n_circuits: int = 20,
357-
cycle_depths: Sequence[int] = tuple(np.arange(3, 100, 20)),
357+
cycle_depths: Sequence[int] = (5, 25, 50, 100, 200, 300),
358358
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
359359
ax: Optional[plt.Axes] = None,
360360
**plot_kwargs,
@@ -402,7 +402,10 @@ def parallel_xeb_workflow(
402402
ax.plot(**plot_kwargs)
403403

404404
circuit_library = rqcg.generate_library_of_2q_circuits(
405-
n_library_circuits=n_circuits, two_qubit_gate=entangling_gate, random_state=rs
405+
n_library_circuits=n_circuits,
406+
two_qubit_gate=entangling_gate,
407+
random_state=rs,
408+
max_cycle_depth=max(cycle_depths),
406409
)
407410

408411
combs_by_layer = rqcg.get_random_combinations_for_device(
@@ -435,7 +438,7 @@ def parallel_two_qubit_xeb(
435438
n_repetitions: int = 10**4,
436439
n_combinations: int = 10,
437440
n_circuits: int = 20,
438-
cycle_depths: Sequence[int] = tuple(np.arange(3, 100, 20)),
441+
cycle_depths: Sequence[int] = (5, 25, 50, 100, 200, 300),
439442
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
440443
ax: Optional[plt.Axes] = None,
441444
**plot_kwargs,
@@ -483,7 +486,7 @@ def run_rb_and_xeb(
483486
np.logspace(np.log10(5), np.log10(1000), 5, dtype=int)
484487
),
485488
entangling_gate: 'cirq.Gate' = ops.CZ,
486-
depths_xeb: Sequence[int] = tuple(np.arange(3, 100, 20)),
489+
depths_xeb: Sequence[int] = (5, 25, 50, 100, 200, 300),
487490
xeb_combinations: int = 10,
488491
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
489492
) -> InferredXEBResult:

docs/noise/qcvv/parallel_xeb.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@
111111
"# Simulation\n",
112112
"qubits = cirq.GridQubit.rect(3, 2, 4, 3)\n",
113113
"result = cirq.experiments.parallel_two_qubit_xeb(\n",
114-
" sampler=cirq.DensityMatrixSimulator(noise=cirq.depolarize(5e-3)), # Any simulator or a ProcessorSampler.\n",
115-
" qubits=qubits \n",
114+
" sampler=cirq.DensityMatrixSimulator(noise=cirq.depolarize(5e-3), dtype=np.complex128), # Any simulator or a ProcessorSampler.\n",
115+
" qubits=qubits\n",
116116
")"
117117
]
118118
},
@@ -554,7 +554,8 @@
554554
"toc_visible": true
555555
},
556556
"kernelspec": {
557-
"display_name": "Python 3",
557+
"display_name": "Python 3 (ipykernel)",
558+
"language": "python",
558559
"name": "python3"
559560
},
560561
"language_info": {
@@ -567,9 +568,9 @@
567568
"name": "python",
568569
"nbconvert_exporter": "python",
569570
"pygments_lexer": "ipython3",
570-
"version": "3.10.13"
571+
"version": "3.11.8"
571572
}
572573
},
573574
"nbformat": 4,
574-
"nbformat_minor": 0
575+
"nbformat_minor": 4
575576
}

0 commit comments

Comments
 (0)