gates_per_clifford(transpiled_circuits_list, clifford_lengths, basis, qubits)[source]

Take a list of transpiled QuantumCircuit and use these to calculate the number of gates per Clifford. Each QuantumCircuit should be transpiled into given basis set. The result can be used to convert a value of error per Clifford into error per basis gate under appropriate assumption.


This example shows how to calculate gate per Clifford of 2Q RB sequence for qubit 0 and qubit 1. You can refer to the function randomized_benchmarking_seq for the detail of RB circuit generation.

import pprint
import qiskit
import qiskit.ignis.verification.randomized_benchmarking as rb
from qiskit.test.mock.backends import FakeAlmaden

rb_circs_list, xdata = rb.randomized_benchmarking_seq(
    length_vector=[1, 20, 50, 100],
    rb_pattern=[[0, 1]])
basis = FakeAlmaden().configuration().basis_gates

# transpile
transpiled_circuits_list = []
for rb_circs in rb_circs_list:
    rb_circs_transpiled = qiskit.transpile(rb_circs, basis_gates=basis)

# count gate per Clifford
ngates = rb.rb_utils.gates_per_clifford(
    basis=basis, qubits=[0, 1])

Making the n=2 Clifford Table
{0: {'cx': 1.5211428571428571,
     'id': 0.0,
     'u1': 0.2502857142857143,
     'u2': 1.2731428571428571,
     'u3': 0.1737142857142857},
 1: {'cx': 1.5211428571428571,
     'id': 0.0,
     'u1': 0.224,
     'u2': 1.2605714285714287,
     'u3': 0.20914285714285713}}

The gate counts for qubit 0 (1) is obtained by ngates[0] (ngates[1]) as usual python dictionary. If all gate counts are zero, you might specify wrong basis or input circuit list is not transpiled into basis gates.

  • transpiled_circuits_list (Union[List[List[QuantumCircuit]], List[QasmQobj]]) – List of transpiled RB circuit for each seed.

  • clifford_lengths (Union[ndarray, List[int]]) – number of Cliffords in each circuit

  • basis (List[str]) – gates basis for the qobj

  • qubits (List[int]) – qubits to count over

Return type

Dict[int, Dict[str, float]]


Nested dictionary of gate counts per Clifford.


QiskitError – when input object is not a list of QuantumCircuit.