Skip to content

Commit

Permalink
* Tests for kernel that takes arguments, basic test for state
Browse files Browse the repository at this point in the history
* WIP: Get the state object
  • Loading branch information
khalatepradnya committed Sep 16, 2024
1 parent d9c2af9 commit cbd56f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/runtime/cudaq/algorithms/py_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ state pyGetStateRemote(py::object kernel, py::args args) {

state pyGetStateLibraryMode(py::object kernel, py::args args) {

// cudaq::info("Size of arguments = {}", args.size());
/// TODO: Unpack arguments

cudaq::info("Size of arguments = {}", args.size());
/// TODO: Pack / unpack arguments
return details::extractState([&]() mutable {
if (0 == args.size())
cudaq::invokeKernel(std::forward<py::object>(kernel));
Expand Down
17 changes: 17 additions & 0 deletions python/tests/handlers/test_photonics_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def kernel():
assert len(counts) == 1
assert '3' in counts

state = cudaq.get_state(kernel)
state.dump()
# TODO: Add check for 'state' object


def test_qudit_list():

Expand Down Expand Up @@ -78,6 +82,19 @@ def kernel():
counts.dump()


def test_kernel_with_args():

@cudaq.kernel
def kernel(theta: float):
q = qudit(4)
plus(q)
phase_shift(q, theta)
mz(q)

result = cudaq.sample(kernel, 0.5)
result.dump()


def test_target_change():

@cudaq.kernel
Expand Down

0 comments on commit cbd56f8

Please sign in to comment.