SolovayKitaev¶
- class SolovayKitaev(*args, **kwargs)[source]¶
Bases:
qiskit.transpiler.basepasses.TransformationPass
Approximately decompose 1q gates to a discrete basis using the Solovay-Kitaev algorithm.
The Solovay-Kitaev theorem [1] states that any single qubit gate can be approximated to arbitrary precision by a set of fixed single-qubit gates, if the set generates a dense subset in \(SU(2)\). This is an important result, since it means that any single-qubit gate can be expressed in terms of a discrete, universal gate set that we know how to implement fault-tolerantly. Therefore, the Solovay-Kitaev algorithm allows us to take any non-fault tolerant circuit and rephrase it in a fault-tolerant manner.
This implementation of the Solovay-Kitaev algorithm is based on [2].
For example, the following circuit
┌─────────┐ q_0: ┤ RX(0.8) ├ └─────────┘
can be decomposed into
global phase: 7π/8 ┌───┐┌───┐┌───┐ q_0: ┤ H ├┤ T ├┤ H ├ └───┘└───┘└───┘
with an L2-error of approximately 0.01.
Examples
import numpy as np from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import TGate, HGate, TdgGate from qiskit.transpiler.passes.synthesis import SolovayKitaev from qiskit.quantum_info import Operator circuit = QuantumCircuit(1) circuit.rx(0.8, 0) print("Original circuit:") print(circuit.draw()) basis_gates = [TGate(), TdgGate(), HGate()] skd = SolovayKitaev(recursion_degree=2) discretized = skd(circuit) print("Discretized circuit:") print(discretized.draw()) print("Error:", np.linalg.norm(Operator(circuit).data - Operator(discretized).data))
Original circuit: ┌─────────┐ q: ┤ Rx(0.8) ├ └─────────┘ Discretized circuit: global phase: 7π/8 ┌───┐┌───┐┌───┐ q: ┤ H ├┤ T ├┤ H ├ └───┘└───┘└───┘ Error: 2.828408279166474
References
- [1]: Kitaev, A Yu (1997). Quantum computations: algorithms and error correction.
Russian Mathematical Surveys. 52 (6): 1191–1249. Online.
- [2]: Dawson, Christopher M.; Nielsen, Michael A. (2005) The Solovay-Kitaev Algorithm.
- Parameters
recursion_degree – The recursion depth for the Solovay-Kitaev algorithm. A larger recursion depth increases the accuracy and length of the decomposition.
basic_approximations – The basic approximations for the finding the best discrete decomposition at the root of the recursion. If a string, it specifies the
.npy
file to load the approximations from. If a dictionary, it contains{label: SO(3)-matrix}
pairs. If None, a default based on the H, T and Tdg gates up to combinations of depth 10 is generated.
Methods
Return the name of the pass.
Run the
SolovayKitaev
pass on dag.Attributes
- is_analysis_pass¶
Check if the pass is an analysis pass.
If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.
- is_transformation_pass¶
Check if the pass is a transformation pass.
If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).