---
title: SolovayKitaevDecomposition (v2.2)
description: API reference for qiskit.synthesis.SolovayKitaevDecomposition in qiskit v2.2
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/2.2/qiskit.synthesis.SolovayKitaevDecomposition
---

# SolovayKitaevDecomposition

*class* `qiskit.synthesis.SolovayKitaevDecomposition(basic_approximations=None, *, basis_gates=None, depth=12, check_input=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/synthesis/discrete_basis/solovay_kitaev.py#L33-L263)

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

The Solovay Kitaev discrete decomposition algorithm.

This class is called recursively by the transpiler pass, which is why it is separated. See [`SolovayKitaev`](/docs/api/qiskit/2.2/qiskit.transpiler.passes.SolovayKitaev "qiskit.transpiler.passes.SolovayKitaev") for more information.

**Parameters**

- **basic\_approximations** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)  *|*[*dict*](https://docs.python.org/3/library/stdtypes.html#dict)*\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str)*, np.ndarray] |* [*list*](https://docs.python.org/3/library/stdtypes.html#list)*\[GateSequence] | None*) –

  A specification of the basic SO(3) approximations in terms of discrete gates. At each iteration this algorithm, the remaining error is approximated with the closest sequence of gates in this set. If a `str`, this specifies a filename from which to load the approximation. If a `dict`, then this contains `{gates: effective_SO3_matrix}` pairs, e.g. `{"h t": np.array([[0, 0.7071, -0.7071], [0, -0.7071, -0.7071], [-1, 0, 0]]}`. If a list, this contains the same information as the dict, but already converted to `GateSequence` objects, which contain the SO(3) matrix and gates.

  Either this parameter, or `basis_gates` and `depth` can be specified.

- **basis\_gates** ([*list*](https://docs.python.org/3/library/stdtypes.html#list)*\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str)  *|*[*Gate*](/docs/api/qiskit/2.2/qiskit.circuit.Gate "qiskit.circuit.Gate")*] | None*) – A list of discrete (i.e., non-parameterized) standard gates. Defaults to `["h", "t", "tdg"]`.

- **depth** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The number of basis gate combinations to consider in the basis set. This determines how fast (and if) the algorithm converges and should be chosen sufficiently high.

- **check\_input** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If `True`, perform intermediate steps checking whether the matrices are of expected form.

## Attributes

### basis\_gates

The basis gate set of the basic approximations.

If `None`, defaults to `["h", "t", "tdg"]`.

### check\_input

Whether to perform runtime checks on the internal data.

### depth

The maximum gate depth of the basic approximations.

## Methods

### find\_basic\_approximation

`find_basic_approximation(sequence)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/synthesis/discrete_basis/solovay_kitaev.py#L248-L263)

Find `GateSequence` in `self._basic_approximations` that approximates `sequence`.

> **Deprecated since version 2.1\_pending**
>
> The method `qiskit.synthesis.discrete_basis.solovay_kitaev.SolovayKitaevDecomposition.find_basic_approximation()` is pending deprecation as of Qiskit 2.1. It will be marked deprecated in a future release, and then removed no earlier than 3 months after the release date. Use query\_basic\_approximation instead, which takes a Gate or matrix as input and returns a QuantumCircuit object.

**Parameters**

**sequence** (*GateSequence*) – `GateSequence` to find the approximation to.

**Returns**

`GateSequence` in that approximates `sequence`.

**Return type**

GateSequence

### load\_basic\_approximations

*static* `load_basic_approximations(data)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/synthesis/discrete_basis/solovay_kitaev.py#L111-L165)

Load basic approximations.

**Parameters**

**data** ([*list*](https://docs.python.org/3/library/stdtypes.html#list)  *|*[*str*](https://docs.python.org/3/library/stdtypes.html#str)  *|*[*dict*](https://docs.python.org/3/library/stdtypes.html#dict)) – If a string, specifies the path to the file from where to load the data. If a dictionary, directly specifies the decompositions as `{gates: matrix}` or `{gates: (matrix, global_phase)}`. There, `gates` are the names of the gates producing the SO(3) matrix `matrix`, e.g. `{"h t": np.array([[0, 0.7071, -0.7071], [0, -0.7071, -0.7071], [-1, 0, 0]]}` and the `global_phase` can be given to account for a global phase difference between the U(2) matrix of the quantum gates and the stored SO(3) matrix. If not given, the `global_phase` will be assumed to be 0.

**Returns**

A list of basic approximations as type `GateSequence`.

**Raises**

[**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the number of gate combinations and associated matrices does not match.

**Return type**

[list](https://docs.python.org/3/library/stdtypes.html#list)\[GateSequence]

### query\_basic\_approximation

`query_basic_approximation(gate)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/synthesis/discrete_basis/solovay_kitaev.py#L238-L246)

Query a basic approximation of a matrix.

**Parameters**

**gate** (*np.ndarray |* [*Gate*](/docs/api/qiskit/2.2/qiskit.circuit.Gate "qiskit.circuit.Gate")) –

**Return type**

[QuantumCircuit](/docs/api/qiskit/2.2/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")

### run

`run(gate_matrix, recursion_degree, return_dag=False, check_input=True)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/synthesis/discrete_basis/solovay_kitaev.py#L195-L236)

Run the algorithm.

**Parameters**

- **gate\_matrix** (*np.ndarray |* [*Gate*](/docs/api/qiskit/2.2/qiskit.circuit.Gate "qiskit.circuit.Gate")) – The single-qubit gate to approximate. Can either be a [`Gate`](/docs/api/qiskit/2.2/qiskit.circuit.Gate "qiskit.circuit.Gate"), where [`Gate.to_matrix()`](/docs/api/qiskit/2.2/qiskit.circuit.Gate#to_matrix "qiskit.circuit.Gate.to_matrix") returns the matrix, or a $2\times 2$ unitary matrix representing the gate.
- **recursion\_degree** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The recursion degree, called $n$ in the paper.
- **return\_dag** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If `True` return a [`DAGCircuit`](/docs/api/qiskit/2.2/qiskit.dagcircuit.DAGCircuit "qiskit.dagcircuit.DAGCircuit"), else a [`QuantumCircuit`](/docs/api/qiskit/2.2/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit").
- **check\_input** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – If `True` check that the input matrix is valid for the decomposition. Overrides the class attribute with the same name, but only for this function call.

**Returns**

A one-qubit circuit approximating the `gate_matrix` in the specified discrete basis.

**Return type**

[QuantumCircuit](/docs/api/qiskit/2.2/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit") | [DAGCircuit](/docs/api/qiskit/2.2/qiskit.dagcircuit.DAGCircuit "qiskit.dagcircuit.DAGCircuit")

### save\_basic\_approximations

`save_basic_approximations(filename)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.2/qiskit/synthesis/discrete_basis/solovay_kitaev.py#L167-L193)

Save the basic approximations into a file.

This can then be loaded again via the class initializer (preferred) or via [`load_basic_approximations()`](#qiskit.synthesis.SolovayKitaevDecomposition.load_basic_approximations "qiskit.synthesis.SolovayKitaevDecomposition.load_basic_approximations"):

```python
filename = "approximations.bin"
sk.save_basic_approximations(filename)

new_sk = SolovayKitaevDecomposition(filename)
```

**Parameters**

**filename** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – The filename to store the approximations in.

**Raises**

[**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError) – If the filename has a .npy extension. The format is not .npy, and storing as such can cause errors when loading the file again.
