Skip to content

[Python] The AST bridge accepts anything that has the components of cudaq.dbg.ast as a call to it #2342

@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

Seems like the python AST bridge is a bit too lax in identifying calls to cudaq.dbg.ast. Or is it cudaq.ast.dbg? Currently, it doesn't matter, as long as there is cudaq, ast and dbg, anything goes. Perhaps someone can argue that this is a feature.

Steps to reproduce the bug

import cudaq

@cudaq.kernel
def simple(n: int):
    q = cudaq.qvector(n)
    cudaq.dbg.ast.print_i64(n)
    dbg.cudaq.ast.print_i64(n)
    dbg.ast.cudaq.print_i64(n)
    ast.dbg.cudaq.print_i64(n)
    ast.cudaq.dbg.print_i64(n)
    ast.cudaq.dbg.whatever.i.can.put.almost.ANYTHING.print_i64(n)

counts = cudaq.sample(simple, 10)
print(counts)

Result:

[cudaq-ast-dbg] 10
[cudaq-ast-dbg] 10
[cudaq-ast-dbg] 10
[cudaq-ast-dbg] 10
[cudaq-ast-dbg] 10
[cudaq-ast-dbg] 10
{ 0000000000:1000 }

Expected behavior

Only accept cudaq.dbg.ast

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

No one assigned

    Labels

    python bridgeInvolves the python bridge to quakepython-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