Skip to content

[Python] Aliasing cudaq name when importing it #2341

Open
@boschmitt

Description

@boschmitt

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

In Python, it is quite common to alias the name of imported libs, e.g., import ... as .... It is common practice even for libraries which don't have big names: import numpy as np. If one tries to alias CUDA-Q import, things break.

Steps to reproduce the bug

import cudaq as quda

@quda.kernel
def simple():
    q = quda.qubit()

counts = quda.sample(simple)
print(counts)

Result:

cudaq.kernel.ast_bridge.CompilerError: bug0.py:5: error: Invalid function call - 'quda' is unknown.
	 (offending source -> quda.qubit)

Expected behavior

Correct execution. Users should be able to alias cudaq.

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

Not a regression

Environment

Suggestions

No response

Metadata

Metadata

Assignees

Labels

python-langAnything related to the Python CUDA Quantum language implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions