Skip to content

[Python] AST bridge: reject cudaq.dbg.ast aliases and reorderings (#2342)#4310

Merged
mitchdz merged 2 commits intoNVIDIA:mainfrom
mitchdz:fix-overly-accepting-ast-bridge-names
Apr 23, 2026
Merged

[Python] AST bridge: reject cudaq.dbg.ast aliases and reorderings (#2342)#4310
mitchdz merged 2 commits intoNVIDIA:mainfrom
mitchdz:fix-overly-accepting-ast-bridge-names

Conversation

@mitchdz
Copy link
Copy Markdown
Collaborator

@mitchdz mitchdz commented Apr 13, 2026

Description:

cudaq.ast is defined as a lazy alias for cudaq.dbg.ast in
_LAZY_SUBMODULES. Because resolveQualifiedName returns obj.__name__
after traversing the attribute chain, cudaq.ast.print_i64(n) was
silently accepted inside kernels — cudaq.ast resolves to cudaq.dbg.ast
at runtime, so obj.__name__ comes back as 'cudaq.dbg.ast' and passes
the devKey guard.

Fix: add isExactCudaqDbgAstCall which walks the literal AST node
structure and requires the chain to be exactly <cudaq_alias>.dbg.ast.<name>.
The devKey check is now conjunctive with this AST check.

Tests cover:

  • valid cudaq.dbg.ast.print_i64 and print_f64 calls still work
  • cudaq.ast.print_i64 (lazy alias, the specific bug) is now rejected
  • dbg.cudaq.ast and ast.cudaq.dbg reorderings are rejected

Fixes #2342

mitchdz added 2 commits April 13, 2026 13:42
Signed-off-by: mdzurick <mitch_dz@hotmail.com>
Signed-off-by: mdzurick <mitch_dz@hotmail.com>
github-actions Bot pushed a commit that referenced this pull request Apr 13, 2026
@github-actions
Copy link
Copy Markdown

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Copy link
Copy Markdown
Collaborator

@1tnguyen 1tnguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@mitchdz mitchdz added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@mitchdz mitchdz added this pull request to the merge queue Apr 15, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 15, 2026
@mitchdz mitchdz added this pull request to the merge queue Apr 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 16, 2026
@mitchdz mitchdz added this pull request to the merge queue Apr 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 17, 2026
@mitchdz mitchdz added this pull request to the merge queue Apr 17, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Apr 17, 2026
@mitchdz mitchdz added this pull request to the merge queue Apr 23, 2026
Merged via the queue into NVIDIA:main with commit 8c33f0a Apr 23, 2026
209 checks passed
@mitchdz mitchdz deleted the fix-overly-accepting-ast-bridge-names branch April 23, 2026 07:08
github-actions Bot pushed a commit that referenced this pull request Apr 23, 2026
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

Successfully merging this pull request may close these issues.

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

2 participants