From 32eaccb7cb1a1d79c48d504f81a00211c11598c5 Mon Sep 17 00:00:00 2001 From: Pradnya Khalate Date: Tue, 23 Jul 2024 14:13:20 -0700 Subject: [PATCH] * Check if there is any name clashing - update kernel names and arguments for the two new tests, and crashing 'remote' backend test. --- python/tests/kernel/test_kernel_features.py | 33 ++++++++++----------- python/tests/remote/test_remote_platform.py | 12 ++++---- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/python/tests/kernel/test_kernel_features.py b/python/tests/kernel/test_kernel_features.py index 02d5eda1c0..51f42b674d 100644 --- a/python/tests/kernel/test_kernel_features.py +++ b/python/tests/kernel/test_kernel_features.py @@ -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 diff --git a/python/tests/remote/test_remote_platform.py b/python/tests/remote/test_remote_platform.py index 2edb7f4ad5..d46516aadd 100644 --- a/python/tests/remote/test_remote_platform.py +++ b/python/tests/remote/test_remote_platform.py @@ -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