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] Unable to find kernel when calling from inside another kernel #2346

Open
3 of 4 tasks
boschmitt opened this issue Nov 1, 2024 · 0 comments
Open
3 of 4 tasks

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

This bug might be related to #2344. In that issue, CUDA-Q is able to find a kernel when it shouldn't. Here it is not able to find the kernel when it should.

Steps to reproduce the bug

Take the following directory structure:

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

Where foo/bar/zaz.py contains:

import cudaq

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

foo/bar/__init__.py contains:

from .bar import zaz

main.py contains:

from foo import bar
import cudaq

@cudaq.kernel
def test0():
    bar.zaz.kernel()

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

Running the code python main.py outputs:

cudaq.kernel.ast_bridge.CompilerError: main.py:6: error: bar.zaz.kernel is not a valid quantum kernel to call.
	 (offending source -> bar.zaz.kernel())

Interestingly, using foo.bar.zaz.kernel() or only kernel() will make it work. (Likely because of #2344)

Expected behavior

This kernel should correctly execute.

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

Not a regression

Environment

Suggestions

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant