I am having troubles with the creation of controlled custom gates in Qiskit.
I am using the
qiskit.extensions.UnitaryGate object but the execution time to create the controlled version of the gate becomes extremely long as the number on controls increase.
The example code below shows the problem : it takes about 70 seconds just to create the gate
import time import numpy as np from qiskit.extensions import UnitaryGate Dmatrix = np.array([[-1/3, 2/3, 0, 2/3], [ 2/3, -1/3, 0, 2/3], [ 0, 0, -1, 0], [ 2/3, 2/3, 0, -1/3]]) Dgate = UnitaryGate(Dmatrix) st = time.time() C6Dgate = Dgate.control(6) # Step that takes a long time print(round(time.time() - st, 2)) # print ~70 secs
Why is it taking so long ?
Is this the right way to create controlled custom gate in Qiskit ?
Is there another qiskit tool that does a similar thing in less time ?