-
Notifications
You must be signed in to change notification settings - Fork 612
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
Resource methods for adjoints, controlls, and pows. #6648
base: master
Are you sure you want to change the base?
Changes from 250 commits
a3a7c81
3d1df63
cc55a41
27e7950
d72838b
1720416
2159b91
940287d
a9c6fcd
90ebacb
9266ec1
d3fb559
13b164e
52f3ebc
4eebd8a
09e1d47
3b18bb8
37bb422
a2786df
6323074
f775d37
4d43c39
60ae243
2d153db
ffc2e91
cbc2fec
93c86e9
75cc679
19791b8
142b7b2
8adc1b4
5c242c2
905c210
86dd9e5
a616fa5
be1498f
6161f91
dcea65b
fb15a83
216f9f2
f739a14
4f182e3
d28eb18
9e42ab8
9c0f999
e562813
5d7fe42
7ad4e2a
02658cb
836c866
ceab03c
b3cd555
c532bea
7a94752
c789e95
fc0b865
c616158
4956bc2
15cd778
f92d17e
e4a7331
54b6636
8ef2c3d
cfd2902
43f9891
4c9bc44
861509c
66b49d5
d5ae48a
6adb131
54d2e9c
cef11ed
6902315
92dbe72
d7e1dbb
50385db
d4e5a1a
3699385
a664175
1269e11
66dba38
9c22b30
99faf1a
c643656
b793798
756e4c9
0f733aa
67f7f3e
195f489
6b70bb9
854b822
ffb4c8c
f2ab502
fb27854
54dd010
321ff0f
d8f8fba
68536bb
dea8747
3769f8a
88a6af0
dfecfc6
078464b
60c08e2
e2b98b0
6177e54
5723ae4
0a7ca0e
854d9e5
f58da1d
0c2d237
c7d5ca1
6d61b19
877da46
24e65f2
8c640f1
fb3b14e
e6b10d9
eaed86b
f7c1ac6
0201f0f
5843551
7093c5e
220dfd9
0f6563a
f3773b0
f30236f
35e7f11
2984553
743d15e
9b3a486
d8e36a2
af8fb92
c7585b5
20f348d
8d24077
046c02e
4866a63
e266b89
af89ccc
d35d063
eb0a13e
0bce904
b2882c6
1882649
6ea2b70
3acd1fe
052c39f
ee4b59a
fe1a247
ecacf47
6081471
8a40ecc
9071111
a8aac38
b1a8711
45613b1
9e03409
e305474
114cbcd
dcf2630
6cc4003
9a199c8
87d9a8e
6e17ff5
1a10660
1ac7191
27b436c
a00b55c
5e78717
29b9cb2
b299cc0
ca9df50
7189792
9ef2304
83f1dff
ce84834
725f8b8
a0e73f9
c181add
8fbf724
5d79d3b
27adf31
1f0e85b
5f0df95
512b9c1
edca839
debf812
097e7bf
922a89e
cfbb28a
1766820
b79b903
8ed270c
7684deb
66f0ba7
036e114
79ccec6
70b92aa
19798e9
7c3bfec
6f80147
226b70e
66e6384
81286ed
364b5cc
f8b3b58
2c6c8e7
76b9fce
bbc0a84
5cb4155
1a1bd4d
94d5ebf
5e9af77
978f864
8ef340c
3418df7
907aac4
b75f4cf
ae6fb97
e170b6f
5268cd3
4624819
3018ddc
42e3bf1
8484026
851aa91
82a9269
46ba719
c39ffe1
34c2a20
3dbe71d
b6a0e35
2294a6e
990cfaa
17da0d0
13efda9
f4d013f
c7b8a41
af3e755
c3a5425
1f88813
b49aecb
cab45a8
416e8df
da61e3a
51115aa
40b693d
25d2f4a
79ed9ed
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 |
---|---|---|
|
@@ -34,6 +34,20 @@ def resource_params(self) -> dict: | |
def resource_rep(cls, **kwargs) -> re.CompressedResourceOp: | ||
return re.CompressedResourceOp(cls, {}) | ||
|
||
@staticmethod | ||
def adjoint_resource_decomp() -> Dict[re.CompressedResourceOp, int]: | ||
return {} | ||
|
||
@staticmethod | ||
def controlled_resource_decomp( | ||
num_ctrl_wires, num_ctrl_values, num_work_wires | ||
) -> Dict[re.CompressedResourceOp, int]: | ||
return {} | ||
|
||
@staticmethod | ||
def pow_resource_decomp(z) -> Dict[re.CompressedResourceOp, int]: | ||
return {} | ||
|
||
|
||
class ResourceGlobalPhase(qml.GlobalPhase, re.ResourceOperator): | ||
"""Resource class for the GlobalPhase gate.""" | ||
|
@@ -48,3 +62,19 @@ def resource_params(self) -> dict: | |
@classmethod | ||
def resource_rep(cls, **kwargs) -> re.CompressedResourceOp: | ||
return re.CompressedResourceOp(cls, {}) | ||
|
||
@staticmethod | ||
def adjoint_resource_decomp() -> Dict[re.CompressedResourceOp, int]: | ||
return {} | ||
|
||
@staticmethod | ||
def controlled_resource_decomp( | ||
num_ctrl_wires, num_ctrl_values, num_work_wires | ||
) -> Dict[re.CompressedResourceOp, int]: | ||
if num_ctrl_values == 0: | ||
return {re.ResourcePhaseShift.resource_rep(): 1} | ||
raise re.ResourcesNotDefined | ||
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. Do we not need to check 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. I modified the decomposition to be general now |
||
|
||
@staticmethod | ||
def pow_resource_decomp(z) -> Dict[re.CompressedResourceOp, int]: | ||
return {} |
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.
I think these should return
{cls.resource_rep(): 1}
. This comment applies to the rest of the codebase as well. I think only the identity's resource decomposition should return{}
and anything else currently returning{}
should be changed to return{re.ResourceIdentity.resource_rep(): 1}
. Users might want to track how many times the identity operator shows up in their circuit, but this can't happen withreturn {}
. The performance gain in returning{}
is probably negligible.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.
Changed 👍🏼