-
Notifications
You must be signed in to change notification settings - Fork 615
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
[WIP] Redesign capabilities dictionary #781
Changes from 39 commits
c365ff5
d0b2435
fae2c75
b118948
8f8c05a
48915e5
511710e
ffdf851
36e2300
d48d568
db44760
a433006
0251a3e
1bf5d3b
1a2b9cd
37050ee
a3c8166
12e7efd
909a775
ec2ec7a
45498d9
455bb89
e5b0b18
0a6c28c
9a3376a
106c719
2f0ba49
a7159b6
b168253
a3acad7
aba06fe
f22737a
09a983a
227d4d4
9b277a9
0b78eeb
5d01545
48c4bae
34c4bfe
b9b5a60
0cc5b10
21b9726
3c7b9eb
f9ee3d0
1d8cef9
fc86431
6cecd28
5b0925a
35413ec
1b4e97c
b5aa8b2
73be770
d658563
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,15 +101,35 @@ as well as potential further capabilities, by providing the following class attr | |
conversion between the two conventions takes place automatically | ||
by the plugin device. | ||
|
||
* :attr:`.Device._capabilities`: a dictionary containing information about the capabilities of | ||
the device. Keys currently supported include: | ||
* :func:`.Device.capabilities`: A class method which returns the dictionary of capabilities of a device. A | ||
new device should override this method to retrieve the parent classes' capabilities dictionary, make a copy | ||
and update and/or add capabilities before returning the copy. | ||
|
||
Examples of capabilities are: | ||
|
||
* ``'model'`` (*str*): either ``'qubit'`` or ``'CV'``. | ||
|
||
* ``'inverse_operations'`` (*bool*): ``True`` if the device supports | ||
* ``'supports_exact'`` (*bool*): ``True`` if the device is a simulator that returns analytic results. | ||
|
||
* ``'supports_sampled'`` (*bool*): ``True`` if outputs are estimates computed from samples of measurement outcomes. | ||
|
||
* ``'supports_inverse_operations'`` (*bool*): ``True`` if the device supports | ||
applying the inverse of operations. Operations which should be inverted | ||
have the property ``operation.inverse == True``. | ||
|
||
* ``'supports_tensor_observables'`` (*bool*): ``True`` if the device supports observables composed from tensor | ||
products such as ``PauliZ(wires=0) @ PauliZ(wires=1)``. | ||
|
||
* ``'executes_in_remote'`` (*bool*): ``True`` if the device runs computations on remote servers or devices. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my own understanding: what would be a use case for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example when devices are advertised on our homepage, and their capabilities automatically searched through... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Not quite sure if it's best to add an entry in the code itself for documentation purposes (just because it gives the impression that specific logic would follow), although I agree that this seems to be a brief enough solution. |
||
|
||
* ``'takes_fixed_number_of_wires'`` (*bool*): ``True`` if the device's number of wires are fixed. | ||
|
||
* ``'runs_noisy_computations'`` (*bool*): ``True`` if the device's results are stochastic due to | ||
physical or simulated noise. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Would that mean that hardware devices would have this attribute be set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and some simulators... |
||
|
||
Capabilities are queried by PennyLane core to make decisions on how to best run computations, | ||
and by external apps build on top of the device ecosystem. | ||
mariaschuld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Adding arguments to your device | ||
-------------------------------- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,6 @@ class DefaultQubit(QubitDevice): | |
pennylane_requires = "0.12" | ||
version = "0.12.0" | ||
author = "Xanadu Inc." | ||
_capabilities = {"inverse_operations": True, "reversible_diff": True} | ||
|
||
operations = { | ||
"BasisState", | ||
|
@@ -360,6 +359,15 @@ def _get_unitary_matrix(self, unitary): # pylint: disable=no-self-use | |
|
||
return unitary.matrix | ||
|
||
@classmethod | ||
def capabilities(cls): | ||
capabilities = super().capabilities().copy() | ||
capabilities.update( | ||
supports_reversible_diff=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come this would not be defined among the capabilities in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is set to False in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh not sure how I missed that, my bad! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for my understanding, how do we know if something supports reversible diff? |
||
supports_inverse_operations=True, | ||
) | ||
return capabilities | ||
|
||
def _create_basis_state(self, index): | ||
"""Return a computational basis state over all wires. | ||
|
||
|
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.
Just wondering if it would make sense to update the subsection title to make it more capability focused, e.g., "Defining capabilities"