MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / test_kernel_control_float_args

Function test_kernel_control_float_args

python/tests/mlir/control.py:100–116  ·  view source on GitHub ↗

Tests `Kernel::control()` with another kernel that's parameterized by a float. Test for both a single qubit and a register of qubits as the controls.

(qubit_count)

Source from the content-addressed store, hash-verified

98
99@pytest.mark.parametrize("qubit_count", [1, 5])
100def test_kernel_control_float_args(qubit_count):
101 """
102 Tests `Kernel::control()` with another kernel that's
103 parameterized by a float. Test for both a single qubit
104 and a register of qubits as the controls.
105 """
106 other_kernel, other_float = cudaq.make_kernel(float)
107 other_qubit = other_kernel.qalloc()
108 other_kernel.rx(other_float, other_qubit)
109
110 kernel, float_ = cudaq.make_kernel(float)
111 control_qubit = kernel.qalloc(qubit_count)
112 # Call `kernel.control()`.
113 kernel.control(other_kernel, control_qubit, float_)
114
115 # Check the MLIR.
116 print(kernel)
117
118
119# CHECK-LABEL: func.func @__nvqpp__mlirgen__PythonKernelBuilderInstance

Callers

nothing calls this directly

Calls 3

printFunction · 0.50
qallocMethod · 0.45
controlMethod · 0.45

Tested by

no test coverage detected