Skip to content

Commit

Permalink
* Check if there is any name clashing - update kernel names and
Browse files Browse the repository at this point in the history
  arguments for the two new tests, and crashing 'remote' backend test.
  • Loading branch information
khalatepradnya committed Jul 23, 2024
1 parent c72877d commit 32eaccb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
33 changes: 16 additions & 17 deletions python/tests/kernel/test_kernel_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1679,47 +1679,46 @@ def invalid_ctrl():
def test_control_then_adjoint():

@cudaq.kernel
def my_func(q: cudaq.qubit, theta: float):
ry(theta, q)
rz(theta, q)
def my_func(q: cudaq.qubit, omega: float):
ry(omega, q)
rz(omega, q)

@cudaq.kernel
def kernel(theta: float):
def other_kernel(delta: float):
ancilla = cudaq.qubit()
q = cudaq.qubit()

h(ancilla)
cudaq.control(my_func, ancilla, q, theta)
cudaq.adjoint(my_func, q, theta)
cudaq.control(my_func, ancilla, q, delta)
cudaq.adjoint(my_func, q, delta)

theta = 1.5
# test here is that this compiles and runs
cudaq.sample(kernel, theta).dump()
cudaq.sample(other_kernel, theta).dump()


def test_control_on_adjoint():

@cudaq.kernel
def my_func(q: cudaq.qubit, theta: float):
ry(theta, q)
rz(theta, q)
def rot_y_z(q: cudaq.qubit, alpha: float):
ry(alpha, q)
rz(alpha, q)

@cudaq.kernel
def adj_func(q: cudaq.qubit, theta: float):
cudaq.adjoint(my_func, q, theta)
def adj_func(q: cudaq.qubit, beta: float):
cudaq.adjoint(rot_y_z, q, beta)

@cudaq.kernel
def kernel(theta: float):
def apply_control(gamma: float):
ancilla = cudaq.qubit()
q = cudaq.qubit()

h(ancilla)
cudaq.control(my_func, ancilla, q, theta)
cudaq.control(adj_func, ancilla, q, theta)
cudaq.control(rot_y_z, ancilla, q, gamma)
cudaq.control(adj_func, ancilla, q, gamma)

theta = 1.5
# test here is that this compiles and runs
cudaq.sample(kernel, theta).dump()
cudaq.sample(apply_control, 1.5).dump()


# leave for gdb debugging
Expand Down
12 changes: 6 additions & 6 deletions python/tests/remote/test_remote_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def check_observe(entity):

def test_observe():
# Create the parameterized ansatz
kernel, theta = cudaq.make_kernel(float)
qreg = kernel.qalloc(2)
kernel.x(qreg[0])
kernel.ry(theta, qreg[1])
kernel.cx(qreg[1], qreg[0])
ansatz, phi = cudaq.make_kernel(float)
qreg = ansatz.qalloc(2)
ansatz.x(qreg[0])
ansatz.ry(phi, qreg[1])
ansatz.cx(qreg[1], qreg[0])

check_observe(kernel)
check_observe(ansatz)


# Make sure spin_op serializes and deserializes correctly
Expand Down

0 comments on commit 32eaccb

Please sign in to comment.