Skip to content

[python] Move kernel signature inference out of MLIR compilation#3930

Merged
lmondada merged 9 commits intoNVIDIA:mainfrom
lmondada:lm/aot-sig
Feb 16, 2026
Merged

[python] Move kernel signature inference out of MLIR compilation#3930
lmondada merged 9 commits intoNVIDIA:mainfrom
lmondada:lm/aot-sig

Conversation

@lmondada
Copy link
Copy Markdown
Collaborator

@lmondada lmondada commented Feb 11, 2026

I've broken up this PR into two commits that can be reviewed independently:

The first commit contains "clean-ups". It doesn't introduce any new functionality nor should it change how anything is currently working. It just removes function arguments that aren't used, renames a couple of things and should make the code more readable. I'm including this here because it made my actual work much easier. These breaking changes are acceptable as they are within the python/cudaq/kernel folder, which is not publicly exposed (discussed with Bettina).

The second commit is the real contribution:

  • The main goal is to parse the kernel signature before running the MLIR compilation. This is required so that we can delay MLIR compilation until the first kernel invocation (in a future PR).
  • To this end, an AST visitor in python/cudaq/kernel/analysis.py is extended to parse the function annotations. This can be run before MLIR compilation
  • A type KernelSignature is introduced to consolidate all kernel type information that was scattered across many attributes in one place.
  • KernelSignature now only stores the kernel types as MLIR types (before, both Python and MLIR types were stored). This makes it easier to handle as there is a single source of truth (and Python types can be recovered using mlirTypeToPyType)

EDIT: Added a third commit that fixes issue #2895

I've noted that a lot of this Python code uses CamelCase, even though our style guide (Google style guide) recommends snake_case. I'm using snake_case where new names/variables are introduced, but limited the number of existing names that had to be changed.

closes #2895

Signed-off-by: Luca Mondada <luca@mondada.net>
@lmondada
Copy link
Copy Markdown
Collaborator Author

lmondada commented Feb 12, 2026

EDIT: done

Note: I've already rebased on top of #3932 but am waiting for that to get merged in. In the meantime ignore commit cec7875 as it has already been reviewed. Will do a final rebase on main when that's possible.

Signed-off-by: Luca Mondada <luca@mondada.net>
Signed-off-by: Luca Mondada <luca@mondada.net>
@github-actions
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Collaborator

@khalatepradnya khalatepradnya left a comment

Choose a reason for hiding this comment

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

Commit#1 looks good. One Q.

Copy link
Copy Markdown
Collaborator

@khalatepradnya khalatepradnya left a comment

Choose a reason for hiding this comment

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

Commit#2 looks good to me.
One minor comment and request to extend tests.

Copy link
Copy Markdown
Collaborator

@khalatepradnya khalatepradnya left a comment

Choose a reason for hiding this comment

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

Suggest moving commit# 3 in a separate PR.

Copy link
Copy Markdown
Collaborator

@taalexander taalexander left a comment

Choose a reason for hiding this comment

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

At a high-level this looks good to me. As I am unfamiliar I will leave to others to approve.

@github-actions
Copy link
Copy Markdown

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

Signed-off-by: Luca Mondada <luca@mondada.net>
Signed-off-by: Luca Mondada <luca@mondada.net>
Signed-off-by: Luca Mondada <luca@mondada.net>
@github-actions
Copy link
Copy Markdown

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

@github-actions
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Collaborator

@khalatepradnya khalatepradnya left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @lmondada !

@github-actions
Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no release notes Don't list this PR in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python] cudaq.sample API assumes broadcast on nested list arguments

4 participants