Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

gates_per_clifford

gates_per_clifford(transpiled_circuits_list, clifford_lengths, basis, qubits) GitHub(opens in a new tab)

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.

Example

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(
    nseeds=5,
    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)
    transpiled_circuits_list.append(rb_circs_transpiled)
 
# count gate per Clifford
ngates = rb.rb_utils.gates_per_clifford(
    transpiled_circuits_list=transpiled_circuits_list,
    clifford_lengths=xdata[0],
    basis=basis, qubits=[0, 1])
 
pprint.pprint(ngates)
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.

Parameters

  • 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]]

Returns

Nested dictionary of gate counts per Clifford.

Raises

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

Was this page helpful?
Report a bug or request content on GitHub.