uniqc.calibration.xeb.circuits module

Random circuit generators for cross-entropy benchmarking (XEB).

Generates 1-qubit and 2-qubit XEB circuits in OriginIR format using the Circuit builder API.

uniqc.calibration.xeb.circuits.generate_1q_xeb_circuits(qubit, depths, n_circuits=50, seed=None)[source]

Generate random 1-qubit XEB circuits.

Each circuit consists of depth random single-qubit layers, followed by measurement. The circuits are designed to measure the per-layer depolarizing fidelity by fitting the exponential decay of the normalized linear XEB estimator as depth increases.

Parameters:
  • qubit (int) – Qubit index to operate on.

  • depths (list[int]) – List of circuit depths to generate (one circuit per depth is generated n_circuits times).

  • n_circuits (int) – Number of circuits to generate per depth.

  • seed (int | None) – Random seed for reproducibility.

Returns:

List of Circuit objects, one per (depth, circuit_index) pair. The total number of circuits is len(depths) * n_circuits.

Return type:

list[Circuit]

uniqc.calibration.xeb.circuits.generate_2q_xeb_circuit(qubit_u, qubit_v, depth, entangler_gate='CNOT', seed=None)[source]

Generate a single random 2-qubit XEB circuit.

Each layer consists of:
  1. Random single-qubit gate on each qubit

  2. The specified entangling gate on the pair

Parameters:
  • qubit_u (int) – First qubit index.

  • qubit_v (int) – Second qubit index.

  • depth (int) – Number of random layers (>= 1).

  • entangler_gate (str) – 2-qubit gate name (e.g. “CNOT”, “CZ”, “ISWAP”).

  • seed (int | None) – Random seed for reproducibility.

Returns:

A single Circuit object.

Return type:

Circuit

uniqc.calibration.xeb.circuits.generate_2q_xeb_circuits(qubit_u, qubit_v, depths, n_circuits=50, entangler_gate='CNOT', seed=None)[source]

Generate random 2-qubit XEB circuits for a single qubit pair.

Parameters:
  • qubit_u (int) – First qubit index.

  • qubit_v (int) – Second qubit index.

  • depths (list[int]) – List of circuit depths.

  • n_circuits (int) – Number of circuits per depth.

  • entangler_gate (str) – 2-qubit gate name.

  • seed (int | None) – Random seed.

Returns:

List of Circuit objects.

Return type:

list[Circuit]

uniqc.calibration.xeb.circuits.generate_parallel_2q_xeb_circuits(pairs, depth, entangler_gates, n_circuits=50, seed=None)[source]

Generate parallel 2-qubit XEB circuits.

All pairs are executed in parallel (within a single multi-qubit circuit) at each layer. This simulates full-chip parallel execution where disjoint pairs of qubits execute 2-qubit gates simultaneously.

Parameters:
  • pairs (list[tuple[int, int]]) – List of qubit pairs to include in parallel.

  • depth (int) – Number of random layers per pair.

  • entangler_gates (dict[tuple[int, int], str]) – Mapping from pair to entangler gate name. Falls back to “CNOT” for any pair not in the dict.

  • n_circuits (int) – Number of parallel circuits to generate.

  • seed (int | None) – Random seed.

Returns:

one circuit per n_circuits. Inner list: one Circuit per pair (all measured in the same circuit object — a single multi-qubit circuit). Actually returns a list of Circuits where each Circuit operates on all qubits in the union of all pairs.

Return type:

List of lists of Circuit objects. Outer list