Closed ACE07-Sev closed 4 months ago
Hi @ACE07-Sev,
Looking at your example, I think you can achieve it with:
import cudaq
class CUDA:
def __init__(self,
num_qubits: int) -> None:
self.num_qubits = num_qubits
self.circuit = cudaq.make_kernel()
self.qr = self.circuit.qalloc(self.num_qubits)
def X(self,
qubit_index: int) -> None:
self.circuit.x(self.qr[qubit_index])
def H(self,
qubit_index: int) -> None:
self.circuit.h(self.qr[qubit_index])
def CX(self,
control_index: int,
target_index: int) -> None:
self.circuit.cx(self.qr[control_index], self.qr[target_index])
def CCX(self,
control_index1: int,
control_index2: int,
target_index: int) -> None:
self.circuit.cx([self.qr[control_index1], self.qr[control_index2]], self.qr[target_index])
def draw(self) -> None:
print(cudaq.draw(self.circuit))
qc = CUDA(3)
qc.H(1)
qc.CX(1, 2)
qc.CCX(0, 1, 2)
qc.draw()
Ooh I see, thank you very much!
Greetings there,
Hope all are well. I am trying to wrap
cuda-quantum
in my package, and I would like to follow aqiskit
UI. I saw the closest to that UI is to usecudaq.make_kernel()
and add gates as methods. However, I am having some difficulty doing this for multi-controlled gates.Here is a toy class example to demonstrate the issue:
And the error I am getting is
I am actively going through the docs and notebooks you have provided, but I'd appreciate your kind feedback on the best way of doing this as well.