-
Notifications
You must be signed in to change notification settings - Fork 34
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
[Runtime][Frontend] Add support for custom QuantumDevices. #327
Conversation
9e34108
to
a1e0be2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #327 +/- ##
=======================================
Coverage 99.56% 99.56%
=======================================
Files 41 42 +1
Lines 7353 7404 +51
Branches 430 432 +2
=======================================
+ Hits 7321 7372 +51
Misses 16 16
Partials 16 16
☔ View full report in Codecov by Sentry. |
e91fb9d
to
de55ac9
Compare
Custom devices which implement the `QuantumDevice` class must also implement an ```cpp extern "C" Catalyst::Runtime::QuantumDevice* getCustomDevice() { return new CustomDevice(); } ``` PennyLane plugin devices should also implement ```python @staticmethod def get_c_interface(): return path_to_shared_lib ``` Then the following works: ```python @qjit @qml.qnode(qml.device("custom.device", wires=wires)) def circuit(): ... ```
See this error message: You are trying to dlopen a this-file-does-not-exist.so shared library with RTLD_DEEPBIND flag which is incompatible with sanitizer runtime (see google/sanitizers#611 for details). If you want to run this-file-does-not-exist.so library under sanitizers please remove RTLD_DEEPBIND from dlopen flags.
This reverts commit 854f7f0.
Co-authored-by: Ali Asadi <ali@xanadu.ai>
Co-authored-by: Ali Asadi <ali@xanadu.ai>
…talyst into eochoa/2023-10-17/loading
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.
Amazing work @erick-xanadu 🎉
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.
Thanks Erick, have only reviewed the docs, but looks good to me!
…talyst into eochoa/2023-10-17/loading
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.
Very cool 🦝
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Context: Changes needed to support third party devices.
Third party devices must implement the
Catalyst::Runtime::QuantumDevice
interface and add agetCustomDevice
method which returns an instance of their device.PennyLane plugin devices should also implement
Then the following works:
Description of the Change: Changes in the frontend to allow any devices that implement a
QuantumDevice
interface to be loaded into the runtime. Changes to the runtime as well.Benefits: Third party developers can implement their own devices as long as they follow the spec.
Possible Drawbacks: Benchmarks showed no impact.
Related GitHub Issues:
Note:
RTLD_DEEPBIND
is needed for allowing custom QuantumDevices to work. However,RTLD_DEEPBIND
is incompatible with sanitizers.[sc-46413]