Repository navigation
Enable run API - #2927
Merged
Merged
Enable run API#2927
run API#2927Conversation
[maint] Merge main to feature branch
This is just to get us going. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
* Add output function stubs to NVQIR.cpp. These need to output to something other than std::cout. Using std::cout temporarily... Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Replace cout with an outputLog string in the ExecutionContext. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Turn into a template to avoid copies of code. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> --------- Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
[features/run] Align with main
* Start to add return to output logging pass. Add test. Add struct test. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Workaround overly excitable warnings in GCC 12. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Make the labels like the design doc. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Update the CHECK lines. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Wrap all string building terms in std::string constructors explicitly since it appears GCC-12 isn't smart enough to know how to compile them. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> --------- Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
…2594) Once the decoder produces a buffer of values, as interpreted from the output log, one can use this function to convert to buffer into a std::vector<T> object. This function transfers the ownership of the data buffer to the vector instead of making another copy of the data. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
* * Skeleton for output record logging and parsing -- primitive types TODO: Handle arrays (vector of results) * Naive way of parsing integer array log Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * * More tests - labeled arrays, multiple shots, failing test for tuple Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * * Clean-up: Removed the logger functionality since the API was implemented for testing only * Addressing PR comment Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * * Fix the format of array label - <type x size> Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * * Build fix - back to working stage. Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * WIP: Using the new interface for parser Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * * Handle primitive types * Updated tests Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * * Fix test, add "qir-api" to attributes Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> * Update runtime/common/RecordLogDecoder.h Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * review comments Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> --------- Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
* [features/run] Work on getting things working end to end. Add a test. Add the pass to convert return types and get end-to-end flow working. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Remove debug code. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Fix regression test. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Fix unittest to include the sizes. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> --------- Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
* Add support for remote-mqpu platform Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Edit the test Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Fix CI Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Use runtime platform info Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> --------- Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com>
* State synthesis for quantum devices (#2291) * DCO Remediation Commit for Ben Howe <bhowe@nvidia.com> I, Ben Howe <bhowe@nvidia.com>, hereby add my Signed-off-by to this commit: 86681ef Signed-off-by: Ben Howe <bhowe@nvidia.com> Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * State pointer synthesis for quantum hardware Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Merge with main Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Merge with main Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix test failure on anyon platform Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Make StateInitialization a funcOp pass Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix issues and tests for the rest of quantum architectures Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix failing quantinuum state prep tests Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Format Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix failing test Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Format Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Format Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Replaced getState intrinsic by cc.get_state op Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Remove print Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Remove getCudaqState references Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Minor updates Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix failing quake test Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Add a few state-related cc ops Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix test_argument_conversion Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Add printing in failing tests Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Add printing in failing tests Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix failing tests Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Add description for new algorithm for state syntesis Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix tests Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Make intermediate IR legal by separating allocs * DCO Remediation Commit for Anna Gringauze <agringauze@nvidia.com> I, Anna Gringauze <agringauze@nvidia.com>, hereby add my Signed-off-by to this commit: 9563371 Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address some PR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address more CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address more CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address more CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Store new functions in subst module and update synthesis Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Make argument synthesis transitive Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Update callers of synthesis Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Use PointerOf in quake defs Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Addressed more CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Recursive with caching Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * StateAggregatorWithArgumentConverter Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Make ArgumentConverter handle the state call tree Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Make argument converter handle kernels created from states Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix null alloc size and add tests Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Keep storing ops when generating numSubits func Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix failing test Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix failing doc build Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address more CR comments and add a test Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address more CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix links Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix links Signed-off-by: Anna Gringauze <agringauze@nvidia.com> --------- Signed-off-by: Ben Howe <bhowe@nvidia.com> Signed-off-by: Anna Gringauze <agringauze@nvidia.com> Co-authored-by: Ben Howe <bhowe@nvidia.com> * Some fixes for complex numbers and vectors (#2739) * Some fixes for complex numbers and vectors Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Update lib/Optimizer/Dialect/CC/CCOps.cpp Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix links Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix links Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix links Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Fix links Signed-off-by: Anna Gringauze <agringauze@nvidia.com> --------- Signed-off-by: Anna Gringauze <agringauze@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> * Add docs for `apply_noise` (#2745) * Enabling afqmc notebook by freezing numba to 0.60.0 (#2759) * Enabling afqmc by freezing numba to 0.60.0 Signed-off-by: Sachin Pisal <spisal@nvidia.com> * removing afqmc form skipped_notebooks Signed-off-by: Sachin Pisal <spisal@nvidia.com> --------- Signed-off-by: Sachin Pisal <spisal@nvidia.com> * Replacing existing spin_ops with the general operators (#2710) This PR contains the full replacement of the existing spin_ops with the new general operators. See the PR description on GitHub for a full list of all changes. --------- Signed-off-by: Bettina Heim <heimb@outlook.com> Signed-off-by: Ben Howe <bhowe@nvidia.com> Signed-off-by: Anna Gringauze <agringauze@nvidia.com> Co-authored-by: Ben Howe <bhowe@nvidia.com> Co-authored-by: cuda-quantum-bot <cuda-quantum-bot@users.noreply.github.com> Co-authored-by: Anna Gringauze <agringauze@nvidia.com> * Allow Return Value Optimization instead of forcing moves (#2765) Signed-off-by: Ben Howe <bhowe@nvidia.com> * Dev Container psi-header extension: retain original copyright year (#2766) For those of us using VSCode dev containers, this makes the psi-header extension work with other projects that don't all have 2022 as a starting point. More specifically - with this change, the extension will attempt to retain the existing starting copyright year and update only the ending copyright year if it exists (rather than updating both the start copyright year and current copyright year). Additionally, if the file is a new file, it will use "now" as the starting copyright year, which is more correct anyway. Signed-off-by: Ben Howe <bhowe@nvidia.com> --------- Signed-off-by: Ben Howe <bhowe@nvidia.com> Signed-off-by: Anna Gringauze <agringauze@nvidia.com> Signed-off-by: Sachin Pisal <spisal@nvidia.com> Signed-off-by: Bettina Heim <heimb@outlook.com> Co-authored-by: Anna Gringauze <agringauze@nvidia.com> Co-authored-by: Ben Howe <bhowe@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com> Co-authored-by: Sachin Pisal <spisal@nvidia.com> Co-authored-by: Bettina Heim <heimb@outlook.com> Co-authored-by: cuda-quantum-bot <cuda-quantum-bot@users.noreply.github.com>
This reverts commit f9ef6fc.
Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com>
Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
* Add support for remote-mqpu platform Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Edit the test Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Fix CI Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Use runtime platform info Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Support emulation mode Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Rename __quantum__rt__integer_record_output Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Support qir adaptive extension Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Fix spelling Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Update runtime/common/RuntimeMLIRCommonImpl.h Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com> Signed-off-by: Thien Nguyen <58006629+1tnguyen@users.noreply.github.com> * Code review: simplify, reduce code dup and edit comments Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> --------- Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> Signed-off-by: Thien Nguyen <58006629+1tnguyen@users.noreply.github.com> Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com>
* Adjust run API template and add async Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Support noise as well Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> --------- Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com>
* [WIP] python support for cudaq::run Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Support noise Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Support remote sim and emulation Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Support async run on Python Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Update test files Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Fix spelling Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> * Update python/runtime/cudaq/algorithms/py_run_async.cpp Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Signed-off-by: Thien Nguyen <58006629+1tnguyen@users.noreply.github.com> * Fix clang compiler warnings: unused lambda capture Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> --------- Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> Signed-off-by: Thien Nguyen <58006629+1tnguyen@users.noreply.github.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Align feature branch with mainline
* Update cudaq.run for python Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Address CR comments Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Update python/runtime/cudaq/algorithms/py_run.cpp Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Remove failing test for now Signed-off-by: Anna Gringauze <agringauze@nvidia.com> * Cleanup Signed-off-by: Anna Gringauze <agringauze@nvidia.com> --------- Signed-off-by: Anna Gringauze <agringauze@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
[features/run] Align with `main`
* Fix bug with wrong output call being selected. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> * Fix the bool array bug. Add a regression for it. Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> --------- Signed-off-by: Eric Schweitz <eschweitz@nvidia.com>
Collaborator
Author
Command Bot: Processing... |
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
reviewed
Jun 3, 2025
sacpis
approved these changes
Jun 3, 2025
sacpis
left a comment
Collaborator
There was a problem hiding this comment.
Few comments. LGTM. Thanks @khalatepradnya.
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Collaborator
Author
Command Bot: Processing... |
khalatepradnya
enabled auto-merge (squash)
June 3, 2025 23:59
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
annagrin
added a commit
to annagrin/cuda-quantum
that referenced
this pull request
Jun 17, 2025
Towards: issue NVIDIA#2526 This PR introduces new CUDA-Q API - `run` which provides a way to execute a specific kernel with non-void return values. For a kernel with return type `T`, one can use `cudaq::run` (C++), or `cudaq.run` (Python) to launch the quantum kernel, specifying the number of shots, the kernel argument values, etc. When the kernel has been executed, control will return to the user code with `cudaq::run` returning a value of `std::vector<T>`. Added a new pass, `ReturnToOutputLog`, to convert kernel return values into QIR output logging calls. This PR covers: - kernels that return primitive types (integers, floating point numbers, Boolean values) and vectors / lists of primitive types supported in both C++ and Python for local and remote simulators - kernels that return structs of primitive types supported in C++ only for local simulators - kernels that return tuples of primitive types supported in Python only for local simulators - C++ library mode Not supported: - kernels that return nested aggregate data types not yet supported Note: `-fenable-cudaq-run` flag required in C++ (this flag will be enabled by default in the future) --------- Signed-off-by: Eric Schweitz <eschweitz@nvidia.com> Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com> Signed-off-by: Thien Nguyen <thiennguyen@nvidia.com> Signed-off-by: Ben Howe <bhowe@nvidia.com> Signed-off-by: Anna Gringauze <agringauze@nvidia.com> Signed-off-by: Sachin Pisal <spisal@nvidia.com> Signed-off-by: Bettina Heim <heimb@outlook.com> Signed-off-by: Thien Nguyen <58006629+1tnguyen@users.noreply.github.com> Signed-off-by: Pradnya Khalate <148914294+khalatepradnya@users.noreply.github.com> Co-authored-by: Ben Howe <141149032+bmhowe23@users.noreply.github.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Thien Nguyen <58006629+1tnguyen@users.noreply.github.com> Co-authored-by: Anna Gringauze <agringauze@nvidia.com> Co-authored-by: Ben Howe <bhowe@nvidia.com> Co-authored-by: Sachin Pisal <spisal@nvidia.com> Co-authored-by: Bettina Heim <heimb@outlook.com> Co-authored-by: cuda-quantum-bot <cuda-quantum-bot@users.noreply.github.com> Co-authored-by: Thien Nguyen <thiennguyen@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Towards: issue #2526
This PR introduces new CUDA-Q API -
runwhich provides a way to execute a specific kernel with non-void return values.For a kernel with return type
T, one can usecudaq::run(C++), orcudaq.run(Python) to launch the quantum kernel, specifying the number of shots, the kernel argument values, etc. When the kernel has been executed, control will return to the user code withcudaq::runreturning a value ofstd::vector<T>.Added a new pass,
ReturnToOutputLog, to convert kernel return values into QIR output logging calls.This PR covers:
Not supported:
Note:
-fenable-cudaq-runflag required in C++ (this flag will be enabled by default in the future)