82 lines
3.1 KiB
Plaintext
82 lines
3.1 KiB
Plaintext
---
|
||
title: gates_per_clifford (v0.31)
|
||
description: API reference for qiskit.ignis.verification.gates_per_clifford in qiskit v0.31
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: function
|
||
python_api_name: qiskit.ignis.verification.gates_per_clifford
|
||
---
|
||
|
||
<span id="qiskit-ignis-verification-gates-per-clifford" />
|
||
|
||
# qiskit.ignis.verification.gates\_per\_clifford
|
||
|
||
<Function id="qiskit.ignis.verification.gates_per_clifford" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-ignis/tree/stable/0.6/qiskit/ignis/verification/randomized_benchmarking/rb_utils.py" signature="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.
|
||
|
||
```python
|
||
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.5017142857142858,
|
||
'id': 0.0,
|
||
'u1': 0.144,
|
||
'u2': 1.6137142857142857,
|
||
'u3': 0.14857142857142858},
|
||
1: {'cx': 1.5017142857142858,
|
||
'id': 0.0,
|
||
'u1': 0.14057142857142857,
|
||
'u2': 1.6377142857142857,
|
||
'u3': 0.1737142857142857}}
|
||
```
|
||
|
||
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.
|
||
</Function>
|
||
|