-
Notifications
You must be signed in to change notification settings - Fork 294
Various fixes for dynamic kernel loading #3507
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
Various fixes for dynamic kernel loading #3507
Conversation
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Thien Nguyen <[email protected]>
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Thien Nguyen <[email protected]>
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @1tnguyen.
|
I'm going to very likely revert this with my changes. Yes. I'll revert these changes in my total rewrite of the python handling of builders, decorators, compilation, and launching. |
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.
These changes also revert some work on the bridge meant to fix bugs that was
in conflict. This includes NVIDIA#3507, NVIDIA#3545.
Signed-off-by: Eric Schweitz <[email protected]>
Description
(1) Allow override in
registerDeviceKernel(2) Clear kernel decorator's
module(parsed from walking the Python AST) as we switch target.The lack of this
moduleattribute tells the decorator to perform a propercompile().Note: Other global maps might be populated during kernel constructor (i.e., as Python sees kernels); hence might not be safe to clear.
(3) Python to honor the default simulator environment variable for hardware target emulation. It was hardcoded to
qppfor those targets that don't define a simulator.