-
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 all 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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
r""" | ||
Experimental simulator plugin based on tensor network contractions | ||
""" | ||
# pylint: disable=too-many-instance-attributes | ||
import warnings | ||
from itertools import product | ||
|
||
|
@@ -101,7 +102,6 @@ class DefaultTensor(Device): | |
pennylane_requires = "0.12" | ||
version = "0.12.0" | ||
author = "Xanadu Inc." | ||
_capabilities = {"model": "qubit", "tensor_observables": True} | ||
|
||
_operation_map = { | ||
"BasisState": None, | ||
|
@@ -164,6 +164,20 @@ def __init__(self, wires, shots=1000, representation="exact", contraction_method | |
self._rep = representation | ||
self._contraction_method = contraction_method | ||
self.reset() | ||
self.analytic = False | ||
mariaschuld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@classmethod | ||
def capabilities(cls): | ||
capabilities = super().capabilities().copy() | ||
capabilities.update( | ||
model="qubit", | ||
supports_analytic_computation=True, | ||
supports_finite_shots=False, | ||
supports_tensor_observables=True, | ||
returns_state=False, | ||
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. Thanks for this! 👍 |
||
returns_probs=False, | ||
) | ||
return capabilities | ||
mariaschuld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def reset(self): | ||
"""Reset the device.""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -656,8 +656,6 @@ class DefaultGaussian(Device): | |
version = "0.12.0" | ||
author = "Xanadu Inc." | ||
|
||
_capabilities = {"model": "cv"} | ||
mariaschuld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_operation_map = { | ||
"Beamsplitter": beamsplitter, | ||
"ControlledAddition": controlled_addition, | ||
|
@@ -695,6 +693,19 @@ def __init__(self, wires, *, shots=1000, hbar=2, analytic=True): | |
|
||
self.reset() | ||
|
||
@classmethod | ||
def capabilities(cls): | ||
capabilities = super().capabilities().copy() | ||
capabilities.update( | ||
model="cv", | ||
supports_analytic_computation=True, | ||
supports_finite_shots=True, | ||
returns_probs=False, | ||
returns_state=False, | ||
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. Perhaps we could set 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. The reason why I reduced the default values in the base device is that not having the value is better than misreporting. Also, it would set this value for all devices, and it would be better to go through them one by one... |
||
supports_reversible_diff=False, | ||
) | ||
return capabilities | ||
|
||
def pre_apply(self): | ||
self.reset() | ||
|
||
|
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,18 @@ def _get_unitary_matrix(self, unitary): # pylint: disable=no-self-use | |
|
||
return unitary.matrix | ||
|
||
@classmethod | ||
def capabilities(cls): | ||
capabilities = super().capabilities().copy() | ||
capabilities.update( | ||
model="qubit", | ||
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, | ||
supports_analytic_computation=True, | ||
returns_state=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"