-
Notifications
You must be signed in to change notification settings - Fork 316
[monolithic change] Rework the way CUDA-Q embeds in Python #3693
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
The current implementation of the Python handling of CUDA-Q has baked in
various attempts to deal with the language coupling between Python and
CUDA-Q kernels. These solutions have been accumulating and making it more
and more difficult to work on the Python implementation.
These changes are a total rewrite to bring the Python implementation more
closely aligned with the C++ implementation.
Changes:
- The kernel builder and kernel decorator are fundamentally different
and will no longer share a duck-typed interface. It doesn't work well.
The builder assembles a CUDA-Q kernel dynamically. As such all symbolic
references are known immediately. The decorator converts a static AST
of code into a CUDA-Q kernel. Symbolic references are either local or
not. Non-local symbols are unknown at the point the decorator is
processed. All non-local symbols in a decorator are recorded with the
decorator itself and lambda lifted as actual arguments.
- MLIR requires that symbols be uniqued. The previous implementation ignored
this requirement.
- Lazy state maintenance in Python and the C++ runtime layers is buggy and
not needed. It is removed. This includes dangling MLIR bindings from the
AST bridge's python MLIR bindings.
- Kernels are no longer built with assumptions, then rebuilt when those
guesses prove wrong. Kernels are no longer built and rebuilt for different
steps in the process. A kernel decorator builds a target agnostic, context
independent kernel, and saves that MLIR ModuleOp under a unique name.
- Launch scenarios have been reworked and consolidated to use the ModuleOp
directly instead of shuffling between string representations (possibly
under maps that were not thread-safe) and ModuleOp instances.
- Every step of the process creating a brand new MLIRContext and loading all
the dialects into that context, etc. is removed. This is done once and the
Python interpreter uses the same context to build all modules.
Other changes include:
Fix GIL issue in get_state_async.
Restructure lambda lifting so it handles recursive ops.
Clone the ModuleOps as they go into the make_copyable_function closure
to prevent them from being erased along the way.
Remove VQE tests. Use VQE from CUDA-QX!
Simplifying cudaq::state support.
Handle kernel decorator from import module
Simplify the symbol table. Python is not a scoped language other than LEGB.
Convert kernel builder to generate code compatible with C++ for state initialization of veqs.
Refactor the AST bridge to generate state objects from the runtime.
Fixes for various tests.
Signed-off-by: Eric Schweitz <[email protected]>
Co-authored-by: Thien Nguyen <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
* Fixes for alternate module resolution. Teaches kernel launching to understand how to deal with qualified symbols and the symbol lookup rules that are entailed from that. Signed-off-by: Eric Schweitz <[email protected]> * Fix module seeking issues. Signed-off-by: Eric Schweitz <[email protected]> * Remove debug print. Signed-off-by: Eric Schweitz <[email protected]> --------- Signed-off-by: Eric Schweitz <[email protected]>
sync with main
* Don't implicit handle density matrix as a flattened vector Signed-off-by: Thien Nguyen <[email protected]> * Format Signed-off-by: Thien Nguyen <[email protected]> * Fix Clang build Signed-off-by: Thien Nguyen <[email protected]> * Code review: fix style and add test Signed-off-by: Thien Nguyen <[email protected]> * Fix clang build Signed-off-by: Thien Nguyen <[email protected]> * More clang build fix Signed-off-by: Thien Nguyen <[email protected]> --------- Signed-off-by: Thien Nguyen <[email protected]>
Much of this no longer makes much sense, but port the parts of the tests that do make sense to the new Python refactoring. Specifically verboten: It does not make sense to try and synthesize Python kernel decorators or look them up by non-unique short names in C++ code. The python interpreter knows what kernel decorators it is referencing and must do the resolution of symbols to bindings. Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Fixes for Python/C++ interop.
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Correcting the last weight (#3654)
… with a nullptr guard Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
…ests Signed-off-by: Eric Schweitz <[email protected]>
[features/py-redesign] Fix for C++ mock server tests
Signed-off-by: Eric Schweitz <[email protected]>
Command Bot: Processing... |
Command Bot: Processing... |
Signed-off-by: Sachin Pisal <[email protected]>
Command Bot: Processing... |
Command Bot: Processing... |
Signed-off-by: Eric Schweitz <[email protected]>
Signed-off-by: Eric Schweitz <[email protected]>
Command Bot: Processing... |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Sachin Pisal <[email protected]>
Command Bot: Processing... |
I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 39ec1fe I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 47088c5 I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: de9912a I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 917efc1 I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 01ef52b I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 37ac0ed I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 383a4d5 I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 2db277f I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: a346745 I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: d604ba6 I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: b5d0963 I, Sachin Pisal <[email protected]>, hereby add my Signed-off-by to this commit: 11474fb Signed-off-by: Sachin Pisal <[email protected]>
Command Bot: Processing... |
I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 7bf59b9 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 97e2216 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 7c9197b I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: bfba600 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: f78e4ab Signed-off-by: Thien Nguyen <[email protected]>
Command Bot: Processing... |
…ply.github.com> I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 7bf59b9 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 97e2216 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 7c9197b I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: bfba600 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: f78e4ab Signed-off-by: Thien Nguyen <[email protected]> Signed-off-by: Thien Nguyen <[email protected]>
…ply.github.com> I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 7bf59b9 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 97e2216 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: 7c9197b I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: bfba600 I, Thien Nguyen <[email protected]>, hereby add my Signed-off-by to this commit: f78e4ab Signed-off-by: Thien Nguyen <[email protected]>
Command Bot: Processing... |
Signed-off-by: Sachin Pisal <[email protected]>
…A/cuda-quantum into features/python.redesign.0
Command Bot: Processing... |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
This is a huge change that crosscuts almost every aspect of the system (except for the C++ frontend, maybe?).
The main drivers are: