4
$\begingroup$

I know the Solovay-Kitaev algorithm can achieve this. Is there an implementation of this or any other algorithm for the same task in Qiskit? Or perhaps some other library that interfaces well with Qiskit?

$\endgroup$
0
4
$\begingroup$

On the Qiskit front, a Solovay-Kitaev algorithm implementation is on its way https://github.com/Qiskit/qiskit-terra/pull/5657.

If you want to use or have a look to this LNoorl:feature/sk-pass branch (remember is a WIP), you can install it like this:

pip install git+https://github.com/LNoorl/qiskit-terra.git@feature/sk-pass

Here is a usage example:

from qiskit.circuit import QuantumCircuit
from qiskit.circuit.library import TGate, HGate, TdgGate
from qiskit.transpiler.passes import SolovayKitaevDecomposition

circuit = QuantumCircuit(1)
circuit.rx(0.7, 0)

print('Orginal circuit:')
print(circuit)

basis_gates = [TGate(), TdgGate(), HGate()]
skd = SolovayKitaevDecomposition(recursion_degree=2, basis_gates=basis_gates, depth=5)

discretized = skd(circuit)

print('Discretized circuit:')
print(discretized)
Orginal circuit:
     ┌─────────┐
q_0: ┤ RX(0.7) ├
     └─────────┘
Discretized circuit:
global phase: -π/8
     ┌───┐┌───┐┌───┐┌─────┐┌───┐┌───┐┌───┐┌───┐┌───┐┌─────┐┌───┐┌───┐┌───┐»
q_0: ┤ H ├┤ T ├┤ H ├┤ TDG ├┤ H ├┤ T ├┤ H ├┤ T ├┤ H ├┤ TDG ├┤ H ├┤ T ├┤ H ├»
     └───┘└───┘└───┘└─────┘└───┘└───┘└───┘└───┘└───┘└─────┘└───┘└───┘└───┘»
«     ┌─────┐┌───┐┌─────┐┌─────┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌─────┐»
«q_0: ┤ TDG ├┤ H ├┤ TDG ├┤ TDG ├┤ H ├┤ T ├┤ H ├┤ T ├┤ T ├┤ H ├┤ T ├┤ H ├┤ TDG ├»
«     └─────┘└───┘└─────┘└─────┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└─────┘»
«     ┌─────┐┌───┐┌─────┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌─────┐┌───┐┌─────┐»
«q_0: ┤ TDG ├┤ H ├┤ TDG ├┤ H ├┤ T ├┤ H ├┤ T ├┤ H ├┤ T ├┤ H ├┤ TDG ├┤ H ├┤ TDG ├»
«     └─────┘└───┘└─────┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└─────┘└───┘└─────┘»
«     ┌─────┐┌───┐┌─────┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌─────┐
«q_0: ┤ TDG ├┤ H ├┤ TDG ├┤ H ├┤ T ├┤ T ├┤ H ├┤ T ├┤ H ├┤ TDG ├
«     └─────┘└───┘└─────┘└───┘└───┘└───┘└───┘└───┘└───┘└─────┘
```
$\endgroup$
3
  • $\begingroup$ Thanks for this answer! Can I use any universal set of basis gates? $\endgroup$ Apr 22 at 12:33
  • 1
    $\begingroup$ you can try any basis set, even when it is not universal. However, universal sets will work with any circuit in the universe :P $\endgroup$
    – luciano
    Apr 23 at 9:52
  • $\begingroup$ It only decomposes single qubit gates though right? Line 94 here github.com/LNoorl/qiskit-terra/blob/master/qiskit/transpiler/… $\endgroup$ Apr 26 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.