Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Spooky kernels (kernel calls inside kernels don't honor modules) #2344

Open
3 of 4 tasks
boschmitt opened this issue Nov 1, 2024 · 1 comment
Open
3 of 4 tasks
Labels
python bridge Involves the python bridge to quake python-lang Anything related to the Python CUDA Quantum language implementation

Comments

@boschmitt
Copy link
Collaborator

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

CUDA-Q does not honor module namespace on kernel calls inside kernels.

Steps to reproduce the bug

Take the following directory project structure:

|-- foo/
|   |-- __init__.py
|
|-- main.py

Where foo/__init__.py contains:

import cudaq

@cudaq.kernel
def spooky_kernel():
    cudaq.qubit()

And main.py contains:

import foo
import cudaq

@cudaq.kernel
def test0():
    spooky_kernel()

counts = cudaq.sample(test0)
print(counts)

Running this code python main.py outputs: { 0:1000 }, which is wrong because it is calling spooky_kernel() and not foo.spooky_kernel()

Expected behavior

A NameError since spooky_kernel is not defined.

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

Suggestions

No response

@boschmitt boschmitt changed the title [Python] Spooky kernels [Python] Spooky kernels (kernel calls inside kernels don't honor modules) Nov 1, 2024
@schweitzpgi
Copy link
Collaborator

👻

@schweitzpgi schweitzpgi added python-lang Anything related to the Python CUDA Quantum language implementation python bridge Involves the python bridge to quake labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python bridge Involves the python bridge to quake python-lang Anything related to the Python CUDA Quantum language implementation
Projects
None yet
Development

No branches or pull requests

2 participants