qiskit.ignis.verification.gates_per_clifford
gates_per_clifford(transpiled_circuits_list, clifford_lengths, basis, qubits)
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)
{0: {'cx': 1.5131428571428571,
'id': 0.0,
'u1': 0.13942857142857143,
'u2': 1.696,
'u3': 0.17942857142857144},
1: {'cx': 1.5131428571428571,
'id': 0.0,
'u1': 0.12685714285714286,
'u2': 1.7348571428571429,
'u3': 0.13028571428571428}}
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.