-
Notifications
You must be signed in to change notification settings - Fork 202
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
First pass of support for C++ operators #2511
Open
anthony-santana
wants to merge
21
commits into
NVIDIA:experimental/operators
Choose a base branch
from
sacpis:dynamics_cpp_operators
base: experimental/operators
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
First pass of support for C++ operators #2511
anthony-santana
wants to merge
21
commits into
NVIDIA:experimental/operators
from
sacpis:dynamics_cpp_operators
Conversation
This file contains 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
This PR fixes an LLVM discrepancy in our Docker images vs our Python wheels. This should fix NVIDIA#1421 and NVIDIA#1799 for our Python wheels. (The Docker images were already correct.)
* Docs for trajectory simulation Signed-off-by: Thien Nguyen <[email protected]> * Fix spelling and code format Signed-off-by: Thien Nguyen <[email protected]> * Update mgpu hash: include fixes for 2434 Signed-off-by: Thien Nguyen <[email protected]> * Update docs/sphinx/snippets/cpp/using/backends/trajectory.cpp Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]> * Update docs/sphinx/snippets/cpp/using/backends/trajectory.cpp Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]> * Update docs/sphinx/snippets/cpp/using/backends/trajectory_observe.cpp Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]> * Update docs/sphinx/snippets/cpp/using/backends/trajectory_observe.cpp Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]> * Update python/cudaq/runtime/observe.py Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]> --------- Signed-off-by: Thien Nguyen <[email protected]> Signed-off-by: Thien Nguyen <[email protected]> Co-authored-by: Eric Schweitz <[email protected]>
For small controlled ops, i.e., singly controlled, expand the gate matrix and use cutensornetStateApplyTensorOperator. Add CUDAQ_TENSORNET_CONTROLLED_RANK threshold to determine when cutensornetStateApplyControlledTensorOperator is used. For MPS, this is fixed at 1 as it cannot handle gate ops with more than 2 qubits. Add doc for the setting and also remove some stale notes about random seeds in the docs. Signed-off-by: Thien Nguyen <[email protected]>
sacpis
approved these changes
Jan 15, 2025
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 if all tests are running successfully.
* add skeleton of new API functions without connecting to docs yet Signed-off-by: A.M. Santana <[email protected]> * updates Signed-off-by: A.M. Santana <[email protected]> * boilerplate Signed-off-by: A.M. Santana <[email protected]> * clean up linking bug Signed-off-by: A.M. Santana <[email protected]> * adding schedule implementation * fixing typo * small updates Signed-off-by: A.M. Santana <[email protected]> * Cleaning up docs preview for PR #6. * push initial tests that show memory leak in current translation to complex matrix Signed-off-by: A.M. Santana <[email protected]> * completely work around eigen in default elementary ops Signed-off-by: A.M. Santana <[email protected]> * storing changes Signed-off-by: A.M. Santana <[email protected]> * start to build out callback function class Signed-off-by: A.M. Santana <[email protected]> * working function wrapper implementation Signed-off-by: A.M. Santana <[email protected]> * implement complex matrix equality operator Signed-off-by: A.M. Santana <[email protected]> * push with broken to matrix overload Signed-off-by: A.M. Santana <[email protected]> * fix scoping issue found in to matrix Signed-off-by: A.M. Santana <[email protected]> * fill out unit tests for to matrix overload Signed-off-by: A.M. Santana <[email protected]> * add skeleton of new API functions without connecting to docs yet Signed-off-by: A.M. Santana <[email protected]> * updates Signed-off-by: A.M. Santana <[email protected]> * boilerplate Signed-off-by: A.M. Santana <[email protected]> * clean up linking bug Signed-off-by: A.M. Santana <[email protected]> * initial scalar value support and tests Signed-off-by: A.M. Santana <[email protected]> * update to_value to evaluate to amtch python api Signed-off-by: A.M. Santana <[email protected]> * adding kwargs capability in C++ by using std::variant and std::bind * renaming VariantArg to NumericType to match Python * adding a std::variant returntype nad adjusting the test accordingly * Cleaning up docs preview for PR #7. * commit first draft of arithmetic against complex doubles Signed-off-by: A.M. Santana <[email protected]> * little build errors Signed-off-by: A.M. Santana <[email protected]> * call generator directly instead of evaluate in operator overloads Signed-off-by: A.M. Santana <[email protected]> * remove old constructor Signed-off-by: A.M. Santana <[email protected]> * copy constructor Signed-off-by: A.M. Santana <[email protected]> * push partially working arithmetic operations Signed-off-by: A.M. Santana <[email protected]> * comment back in tests Signed-off-by: A.M. Santana <[email protected]> * remove constructor that takes removed parameters member Signed-off-by: A.M. Santana <[email protected]> * still having memory issues Signed-off-by: A.M. Santana <[email protected]> * implement and test remaining pre defined elementary ops except displace and squeeze. implement complex matrix exponential Signed-off-by: A.M. Santana <[email protected]> * fix for segfault in copy constructor but still have memory issues from arithmetic Signed-off-by: A.M. Santana <[email protected]> * temp patch to get scalar arithmetic against complex doubles working. against doubles wrapped in functions still broken Signed-off-by: A.M. Santana <[email protected]> * potential fix for callback function going out of scope Signed-off-by: A.M. Santana <[email protected]> * confirm fix for scalar ops from functions and reenable tests Signed-off-by: A.M. Santana <[email protected]> * begin to support scalar against scalar ops and simplify other arithmetic definitions with macros Signed-off-by: A.M. Santana <[email protected]> * support for remaining arithmetic against other scalar ops except for assignment operators Signed-off-by: A.M. Santana <[email protected]> * add checks to ensure local variables are picked up fine in generator functions Signed-off-by: A.M. Santana <[email protected]> * clean up test file Signed-off-by: A.M. Santana <[email protected]> * full refactor to take a [arameter map with elementary operator implementation back under construction Signed-off-by: A.M. Santana <[email protected]> * fix elementary ops Signed-off-by: A.M. Santana <[email protected]> * start to manually merge in operator sum changes Signed-off-by: A.M. Santana <[email protected]> * camel case some things and underscore some others Signed-off-by: A.M. Santana <[email protected]> * fix build errors from header file Signed-off-by: A.M. Santana <[email protected]> * refactor implementation file names, delete unused dynamics.h, refactor unittests with new dynamics folder Signed-off-by: A.M. Santana <[email protected]> * storing large set of changes to dynamics folder structure and implementing more arithmetic Signed-off-by: A.M. Santana <[email protected]> * add cudaq tensor type Signed-off-by: Alex McCaskey <[email protected]> * add uint8 tensor to python api Signed-off-by: Alex McCaskey <[email protected]> * Update unittests/utils/tensor_tester.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update unittests/utils/tensor_tester.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update unittests/utils/tensor_tester.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/details/impls/xtensor_impl.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/details/impls/xtensor_impl.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/details/impls/xtensor_impl.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update python/runtime/utils/py_tensor.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/extension_point.h Co-authored-by: Ben Howe <[email protected]> Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/extension_point.h Co-authored-by: Ben Howe <[email protected]> Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/tensor.h Co-authored-by: Ben Howe <[email protected]> Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/tensor.h Co-authored-by: Ben Howe <[email protected]> Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/details/impls/xtensor_impl.cpp Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/details/tensor_impl.h Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/details/tensor_impl.h Signed-off-by: Eric Schweitz <[email protected]> * Update runtime/cudaq/utils/details/tensor_impl.h Signed-off-by: Eric Schweitz <[email protected]> * Spelling fixes. Signed-off-by: Eric Schweitz <[email protected]> * push current state Signed-off-by: A.M. Santana <[email protected]> * Format Signed-off-by: Anna Gringauze <[email protected]> * Format Signed-off-by: Anna Gringauze <[email protected]> * Drop debug code. Signed-off-by: Eric Schweitz <[email protected]> * Cleanup tensor types a tad. Signed-off-by: Eric Schweitz <[email protected]> * Fix spelling Signed-off-by: Anna Gringauze <[email protected]> * Fix spelling and format python code Signed-off-by: Anna Gringauze <[email protected]> * Sort spelling allowlist Signed-off-by: Anna Gringauze <[email protected]> * Cleaning up docs preview for PR #9. * more arithmetic support Signed-off-by: A.M. Santana <[email protected]> * Update spelling and formatting Signed-off-by: Anna Gringauze <[email protected]> * more implementation and more tests Signed-off-by: A.M. Santana <[email protected]> * Update spelling and formatting Signed-off-by: Anna Gringauze <[email protected]> * This is an attempt to sort out the different ownership models of tensor data. The python stub for "take" needs to be implemented however. The semantics are: - copy : the tensor object makes a copy of the data and owns the copy. i.e. there is a unique_ptr. - take : the tensor object steals a copy of the data from the caller. In order for this case to make sense, we want the caller to guarantee that the data is unique before we steal it. This can be done by forcing the client code to wrap the tensor data in a unique_ptr *before* the take call. - borrow : In this case, the tensor object has no ownership of the tensor data and just naively assumes the client will manage the data correctly. In this case, a raw pointer to the client's data is used. Signed-off-by: Eric Schweitz <[email protected]> * Update the missing py_tensor code. Signed-off-by: Eric Schweitz <[email protected]> * Add handling for empty shape case. Signed-off-by: Eric Schweitz <[email protected]> * Add more python tests Signed-off-by: Anna Gringauze <[email protected]> * Add a take() with move semantics. Signed-off-by: Eric Schweitz <[email protected]> * fix product operator constructor issue and tests Signed-off-by: A.M. Santana <[email protected]> * fix more test more Signed-off-by: A.M. Santana <[email protected]> * cover all arithmetic Signed-off-by: A.M. Santana <[email protected]> * update before merging in tensor pr Signed-off-by: A.M. Santana <[email protected]> * Fix __init__ argument order so tests pass. The shape must come first. Signed-off-by: Eric Schweitz <[email protected]> * Remove StateTensor. (Not used.) Signed-off-by: Eric Schweitz <[email protected]> * Add more comments on how to use this stuff. Signed-off-by: Eric Schweitz <[email protected]> * Added python tests and fixed some issues * Merge with tensor Signed-off-by: Anna Gringauze <[email protected]> * DCO Remediation Commit for Anna Gringauze <[email protected]> I, Anna Gringauze <[email protected]>, hereby add my Signed-off-by to this commit: e78def4 Signed-off-by: Anna Gringauze <[email protected]> * Add some boilerplate for tensor operators. Signed-off-by: Eric Schweitz <[email protected]> * Make the compiler work a bit harder. Signed-off-by: Eric Schweitz <[email protected]> * Add move constructor. Signed-off-by: Eric Schweitz <[email protected]> * Make sure the return values for operators work as expected. Signed-off-by: Eric Schweitz <[email protected]> * clang-format Signed-off-by: Eric Schweitz <[email protected]> * Add override to dtor. Signed-off-by: Eric Schweitz <[email protected]> * Add forward decls. Signed-off-by: Eric Schweitz <[email protected]> * More fussy templates. Signed-off-by: Eric Schweitz <[email protected]> * Workaround warnings from g++. Signed-off-by: Eric Schweitz <[email protected]> * Fix typos. Signed-off-by: Eric Schweitz <[email protected]> * Support copy semantics for Numpy 2.0 * DCO Remediation Commit for Anna Gringauze <[email protected]> I, Anna Gringauze <[email protected]>, hereby add my Signed-off-by to this commit: 85fae37 Signed-off-by: Anna Gringauze <[email protected]> * Try fixing doc gen and c++ compilation errors Signed-off-by: Anna Gringauze <[email protected]> * Add compilation test for nvcc Signed-off-by: Anna Gringauze <[email protected]> * Remove temp file Signed-off-by: Anna Gringauze <[email protected]> * store changes Signed-off-by: A.M. Santana <[email protected]> * first pass of updating return types to cudaq tensor Signed-off-by: A.M. Santana <[email protected]> * store working version with tests before rebase Signed-off-by: A.M. Santana <[email protected]> * fix improper merge resolution issues Signed-off-by: A.M. Santana <[email protected]> * more issues with resolving merge Signed-off-by: A.M. Santana <[email protected]> * first pass of translation to matrix_2 with build errors fixed. now double checking tests Signed-off-by: A.M. Santana <[email protected]> * fix remaining artifacts from rebase Signed-off-by: A.M. Santana <[email protected]> * fix matrix checks for simple elementary op unit tests Signed-off-by: A.M. Santana <[email protected]> * first pass of implementing deeper matrix checks in tests. Have two files left to finish Signed-off-by: A.M. Santana <[email protected]> * fix copyright headers Signed-off-by: A.M. Santana <[email protected]> * minor change to check verified commit Signed-off-by: A.M. Santana <[email protected]> --------- Signed-off-by: A.M. Santana <[email protected]> Signed-off-by: Alex McCaskey <[email protected]> Signed-off-by: Eric Schweitz <[email protected]> Signed-off-by: Anna Gringauze <[email protected]> Co-authored-by: Sachin Pisal <[email protected]> Co-authored-by: cuda-quantum-bot <[email protected]> Co-authored-by: Alex McCaskey <[email protected]> Co-authored-by: Eric Schweitz <[email protected]> Co-authored-by: Ben Howe <[email protected]> Co-authored-by: Anna Gringauze <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
* Removing base_operator class, as operator_sum will act as a base class Signed-off-by: Sachin Pisal <[email protected]>
* Aggregating parameters * Extracting documentation * Extracting positional and keyword arguments * Generating all quantum states for given degrees and dimensions * Permuting a given matrix * Canonicalizing degrees * Adding test cases for the above functions * Formatting Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
* Adding unitests for Rydberg hamiltonian operator * Making evaluate function in scalar_operator const Signed-off-by: Sachin Pisal <[email protected]>
Signed-off-by: Sachin Pisal <[email protected]>
sacpis
force-pushed
the
dynamics_cpp_operators
branch
from
January 16, 2025 22:10
2b42628
to
8150d70
Compare
sacpis
requested review from
1tnguyen,
bmhowe23 and
schweitzpgi
as code owners
January 16, 2025 22:10
Signed-off-by: Sachin Pisal <[email protected]>
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.
Description
This is an initial commit to the experimental branch containing a first pass of work towards operator support in C++