-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add adjoint method to Python frontend #137
Conversation
Hello. You may have forgotten to update the changelog!
|
Test Report (C++) on Ubuntu 1 files ±0 1 suites ±0 0s ⏱️ ±0s For more details on these failures, see this check. Results for commit 5f0e331. ± Comparison against base commit f154807. ♻️ This comment has been updated with latest results. |
Codecov Report
@@ Coverage Diff @@
## 7072_adj_diff #137 +/- ##
================================================
Coverage ? 92.15%
================================================
Files ? 4
Lines ? 153
Branches ? 0
================================================
Hits ? 141
Misses ? 12
Partials ? 0 Continue to review full report at Codecov.
|
ops_serialized = _serialize_ops(tape, self.wire_map) | ||
|
||
jac = adj.adjoint_jacobian( | ||
*obs_serialized, *ops_serialized, tape.trainable_params, tape.num_params |
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.
This is still up for debate, but I think we can pass in the tuples directly to CPP, without incurring the expansion overhead.
*obs_serialized, *ops_serialized, tape.trainable_params, tape.num_params | |
obs_serialized, ops_serialized, tape.trainable_params, tape.num_params |
and I can unpack them in CPP. I have already made some helper struct to simplify data passing around here, so this might just be tidier. I'll let you know once I have it bound up.
Thanks Tom! Looks good to merge into the C++ branch. I'll tidy up the testing once there. |
* Add inner product routine with STL and BLAS options * Add prelim adj diff implementation * Refactor build-system structure to enable better extensibility * Add explicit build support for algorithms * Clean Util cmake * Add explicit overload resolution to innerProd * Add build support for AdjointDiff * Update testing for new utils * Ensure formatting is run in nested dirs * Add cout functionality for StateVector * Add dot for conjugated and non conjugated data * Begin dev of adjoint diff tests * Add additional tests to util suite * Attempt debugging of multi-obs issues * Ensure FPIC on for generated .a libs * Fix native flag in CMake * Ensure propagation of flags to lower dirs * Update build flags * Add additional testing * Update tests * Encapsulate ops and obs data for Python serialization * Restructure the obs and ops data for adjoint calcs * Lint and add defines * Fix testing binary location * Attempt to appease codefactor * Fix memory alignment errors on output for adj * Fix broken tests due to MVP * Add adjoint method to Python frontend (#137) * Add observable serialization * Add to lightning * Update * Add operation serialization * add framework * Apply black * Add tests for obs_has_kernel * Add tests for _serialize_obs * Add wires * Add * Rename to _obs_has_kernel_ * Add tests * Adapt tests to lightning * Update obs * Update serialization * Potential facepalm moment * Revert "Potential facepalm moment" This reverts commit 4230615. * Revert "Update serialization" This reverts commit 38352c2. * Revert "Update obs" This reverts commit ee7a377. * Update * Update * Add support for statevector with own managed memory * Add param gateset tests for SVM * Fixed memory access issues with memory managed statevector * Fix C++ adjoint calls * Update parallelisation using OpenMP * Update Python and run black * Fix serialisation for tensor expvals * Ensure statevector is linear 1D array before offloading to C++ * Add repr bindings for improved debugging * Enable OpenMP for observables * Ensure OpenMP is optional requirement * Fix vector stream formatting * Move and format bindings * Aim to appease codefactor * Offload StateVectorManaged to separate file * Readd missing file * Avoid loading cmath before math defines for Windows * Add defines to compiler rather than source * Add guards for C++ binding utility modules import * Add comments to AdjointDiff to silence codefactor * Add ostream for statevectors * Add ostream for vector and sets * Improve performance of Adj method * Ensure set passed to C++ layer * Simplify call structure * Tidy loop structure * Update Obs class for float and complex data * Track updated Obs structure * Add variant support for observables from Python * Allow support for "Hermitian" observables * Add support for mixing of observable types * Fix serialization tests for adjoint method (#141) * Update tests * Add problematic statements * Fix tests * Fix type hinting * Make function as expected * Add quick return for no jacobian * Move position * Add raise for non supported ops * Ensure jacobian shape formatted as expected * Return jacobian directly as numpy array * Ensure correct return type of jacobian * Ensure param number tracking is correct for adjjac * Fix CRY gate index * All tests passing * Calculate parametric ops when creating opsdata object * Apply formatting * Ensure MacOS wheel builder uses a more modern compiler toolchain * Fix mac wheel builder Co-authored-by: Lee J. O'Riordan <loriordan@gmail.com> * Fix compilation * Add new integration test for adjoint jacobian (#142) * Add test for dev pl * Add test * Move to original tests * Add additional ops creation method * Fix QFT errors * Reformat * Revert "Fix QFT errors" This reverts commit f62a763. * Preclude certain gates * Update test * Add double comments * Update test * Add tests for standard and custom wire labels * Remove print * Extend tests for RX,RY * Prevent trainable params from going negative * Ensure correct coef applied when using generator * Update Ops repr * Reenable tests * Update CI for non compiled builds * Add exception for Projector observable * Add Hermitian in tensor product * Ensure data is passed as complex128 to cpp * Run black * Ensure serialisation of numpy data is cast correctly * Remove redundant methods * Add support to get obs data * Fix serialize test array structures * Add hermitian checks * Ensure testing complete for current requirements * Reformat bindings * Skip test for Hermitian on default * Ensure bin available passed as class param * Skip for non binary tests Co-authored-by: Lee J. O'Riordan <loriordan@gmail.com> * Update pennylane_lightning/src/algorithms/AdjointDiff.hpp Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com> * Update pennylane_lightning/src/simulator/StateVectorManaged.hpp Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com> * Update pennylane_lightning/src/util/Error.hpp Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com> * Update pennylane_lightning/src/algorithms/AdjointDiff.hpp Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com> * Update pennylane_lightning/src/algorithms/AdjointDiff.hpp Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com> * Fix typos and remove comments * Update changelog * Fix codecov reduction * Trigger build * CodeCov fix Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
No description provided.