qiskit-documentation/docs/api/qiskit/0.36/qiskit.ignis.verification.c...

84 lines
3.4 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: calculate_2q_epc
description: API reference for qiskit.ignis.verification.calculate_2q_epc
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.ignis.verification.calculate_2q_epc
---
# qiskit.ignis.verification.calculate\_2q\_epc
<Function id="qiskit.ignis.verification.calculate_2q_epc" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-ignis/tree/stable/0.7/qiskit/ignis/verification/randomized_benchmarking/rb_utils.py" signature="calculate_2q_epc(gate_per_cliff, epg_2q, qubit_pair, list_epgs_1q, two_qubit_name='cx')">
Convert error per gate (EPG) into error per Clifford (EPC) of two qubit `cx` gates.
Given that we know the number of gates per Clifford $N_i$ and those EPGs, we can predict EPC of that RB sequence:
$$
EPC = 1 - \prod_i \left( 1 - EPG_i \right)^{N_i}
$$
This function isolates the contribution of two qubit gate to the EPC \[1]. This will give you more accurate estimation of EPC, especially when the `cx` gate fidelity is close to that of single qubit gate. To run this function, you need to know EPG of both single and two qubit gates. For example, when you prepare 2Q RB experiment with appropriate error model, you can define EPG of those basis gate set. Then you can estimate the EPC of prepared RB sequence without running experiment.
```python
import qiskit.ignis.verification.randomized_benchmarking as rb
# gate counts of your 2Q RB experiment
gpc = {0: {'cx': 1.49, 'u1': 0.25, 'u2': 0.95, 'u3': 0.56},
1: {'cx': 1.49, 'u1': 0.24, 'u2': 0.98, 'u3': 0.49}}
# EPGs from error model
epgs_q0 = {'u1': 0, 'u2': 0.001, 'u3': 0.002}
epgs_q1 = {'u1': 0, 'u2': 0.002, 'u3': 0.004}
epg_q01 = 0.03
# calculate 2Q EPC
epc_2q = rb.rb_utils.calculate_2q_epc(
gate_per_cliff=gpc,
epg_2q=epg_q01,
qubit_pair=[0, 1],
list_epgs_1q=[epgs_q0, epgs_q1])
# calculate EPC according to the definition
fid = 1
for qubit in (0, 1):
for epgs in (epgs_q0, epgs_q1):
for gate, val in epgs.items():
fid *= (1 - val) ** gpc[qubit][gate]
fid *= (1 - epg_q01) ** 1.49
epc = 1 - fid
print('Total sequence EPC: %f, 2Q gate contribution: %f' % (epc, epc_2q))
```
```python
Total sequence EPC: 0.055868, 2Q gate contribution: 0.051004
```
As you can see two qubit gate contribution is dominant in this RB sequence.
**References**
\[1] D. C. McKay, S. Sheldon, J. A. Smolin, J. M. Chow, and J. M. Gambetta, “Three-Qubit Randomized Benchmarking,” Phys. Rev. Lett., vol. 122, no. 20, 2019 (arxiv:1712.06550).
**Parameters**
* **gate\_per\_cliff** (`Dict`\[`int`, `Dict`\[`str`, `float`]]) dictionary of gate per Clifford. see [`gates_per_clifford()`](qiskit.ignis.verification.gates_per_clifford "qiskit.ignis.verification.gates_per_clifford").
* **epg\_2q** (`float`) EPG estimated by error model.
* **qubit\_pair** (`List`\[`int`]) index of two qubits to calculate EPC.
* **list\_epgs\_1q** (`List`\[`Dict`\[`str`, `float`]]) list of single qubit EPGs of qubit listed in `qubit_pair`.
* **two\_qubit\_name** (`Optional`\[`str`]) name of two qubit gate in `basis gates`.
**Return type**
`float`
**Returns**
EPG of 2Q gate.
**Raises**
**QiskitError** when `cx` is not found, specified `qubit_pair` is not included in the gate count dictionary, or length of `qubit_pair` is not 2.
</Function>