[python] Calling builder kernels within decorator kernels is not supported
Open
Nobody has claimed this yet.
stale-notified
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 455
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 165
Description
Required prerequisites
- Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
- If possible, make a PR with a failing test to give us a starting point to work on!
Describe the bug
The following tests fail with the error "error: unhandled function call - builder_kernel".
def test_call_builder_kernel_from_decorator_kernel():
"""Tests that a kernel built with make_kernel can be called
from within a @cudaq.kernel decorated function."""
builder_kernel, qubit = cudaq.make_kernel(cudaq.qubit)
builder_kernel.x(qubit)
@cudaq.kernel
def caller():
q = cudaq.qubit()
builder_kernel(q)
counts = cudaq.sample(caller, shots_count=10)
assert counts["1"] == 10
def test_call_builder_kernel_from_decorator_kernel_2():
"""Tests that a parameterized builder kernel can be called
from within a @cudaq.kernel decorated function."""
builder_kernel, angle = cudaq.make_kernel(float)
qubits = builder_kernel.qalloc(1)
builder_kernel.ry(angle, qubits[0])
@cudaq.kernel
def caller():
builder_kernel(np.pi)
counts = cudaq.sample(caller, shots_count=10)
assert counts["1"] == 10
Steps to reproduce the bug
run the above test
Expected behavior
tests pass, or a better error is raised
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
- CUDA-Q version:
- Python version:
- C++ compiler:
- Operating system:
Suggestions
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the two reproducer tests, test_call_builder_kernel_from_decorator_kernel and test_call_builder_kernel_from_decorator_kernel_2, to confirm the unhandled function call error. Trace how builder kernels created with cudaq.make_kernel are invoked from @cudaq.kernel functions; done means both tests pass or a clearer error is raised.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- quantum-computing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100