List of callables as an input to the kernel raises an error
Open
Nobody has claimed this yet.
stale-notified
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 456
- 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
I can use a callable as an input to the kernel, but the list of callables raises an error.
RuntimeError: kernel argument type is 'list' but argument provided is not (argument 0, value=module {
func.func @__nvqpp__mlirgen__X(%arg0: !quake.ref) attributes {"cudaq-kernel"} {
quake.x %arg0 : (!quake.ref) -> ()
return
}
}
, type=<class 'cudaq.kernel.kernel_decorator.PyKernelDecorator'>).
Steps to reproduce the bug
import cudaq
from typing import Callable
@cudaq.kernel
def X(q : cudaq.qubit):
x(q)
@cudaq.kernel
def kernel(f: list[Callable[[cudaq.qubit], None]]):
q = cudaq.qvector(2)
f[0](q[0])
f[1](q[1])
result = cudaq.sample(kernel, [X,X])
print(result)
Expected behavior
The kernel should be able to accept a list of callables.
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 with the Python reproducer using @cudaq.kernel and cudaq.sample, comparing the working single-callable case with the failing list[Callable] argument. Confirm that sampling a kernel accepting [X, X] succeeds without the reported kernel argument type error; the payload does not identify a source file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- quantum-computing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100