Skip to content
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

Open
wants to merge 548 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
548 commits
Select commit Hold shift + click to select a range
a3a7c81
format
Jaybsoni Nov 18, 2024
3d1df63
format
Jaybsoni Nov 19, 2024
cc55a41
Merge branch 'master' into resource_symbolic_ops
willjmax Nov 19, 2024
27e7950
fixing init files
willjmax Nov 19, 2024
d72838b
fixing init again
willjmax Nov 19, 2024
1720416
codefactor
willjmax Nov 19, 2024
2159b91
Merge branch 'master' into resource_single_qubit
willjmax Nov 19, 2024
940287d
formatting
willjmax Nov 19, 2024
a9c6fcd
reverting changes
willjmax Nov 19, 2024
90ebacb
Apply suggestions from code review
Jaybsoni Nov 19, 2024
9266ec1
Merge branch 'resource_single_qubit' into resource_tracking
Jaybsoni Nov 19, 2024
d3fb559
Merge branch 'master' into resource_single_qubit
Jaybsoni Nov 19, 2024
13b164e
merge master
Jaybsoni Nov 19, 2024
52f3ebc
adjoint/pow methods for QFT dependencies
willjmax Nov 19, 2024
4eebd8a
update controlled
willjmax Nov 20, 2024
09e1d47
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 20, 2024
3b18bb8
Merge branch 'master' into resource_single_qubit
willjmax Nov 20, 2024
37bb422
soran's comments
willjmax Nov 20, 2024
a2786df
adding phase shift to docs
willjmax Nov 20, 2024
6323074
fix controlled to pass unit test
willjmax Nov 20, 2024
f775d37
Merge branch 'master' into resource_symbolic_ops
willjmax Nov 20, 2024
4d43c39
formatting
willjmax Nov 20, 2024
60ae243
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 20, 2024
2d153db
add CRY to init
willjmax Nov 20, 2024
ffc2e91
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 20, 2024
cbc2fec
adding resource methods
willjmax Nov 20, 2024
93c86e9
raise resources not implemented
willjmax Nov 20, 2024
75cc679
Merge branch 'resource_multi_qubit' into resource_symbolic_ops
willjmax Nov 20, 2024
19791b8
Merge branch 'master' into resource_single_qubit
willjmax Nov 20, 2024
142b7b2
Merge branch 'resource_single_qubit' of github.com:PennyLaneAI/pennyl…
willjmax Nov 20, 2024
8adc1b4
merge
willjmax Nov 20, 2024
5c242c2
merge
willjmax Nov 20, 2024
905c210
revert changes from merge conflict
willjmax Nov 20, 2024
86dd9e5
more merge conflict issues
willjmax Nov 20, 2024
a616fa5
final revert
willjmax Nov 20, 2024
be1498f
formatting
willjmax Nov 20, 2024
6161f91
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 20, 2024
dcea65b
formatting
willjmax Nov 20, 2024
fb15a83
Merge
willjmax Nov 20, 2024
216f9f2
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 20, 2024
f739a14
Merge branch 'master' into resource_tracking
Jaybsoni Nov 21, 2024
4f182e3
unused argument
willjmax Nov 21, 2024
d28eb18
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 21, 2024
9e42ab8
fixing merge error
willjmax Nov 21, 2024
9c0f999
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 21, 2024
e562813
docstring
willjmax Nov 21, 2024
5d7fe42
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 21, 2024
7ad4e2a
formatting and syntax error
willjmax Nov 21, 2024
02658cb
double excitation
willjmax Nov 21, 2024
836c866
Merge branch 'master' into resource_controlled_gates
willjmax Nov 21, 2024
ceab03c
add ResourceCY to init
willjmax Nov 21, 2024
b3cd555
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 21, 2024
c532bea
tests for parametric_ops_multi_qubit
willjmax Nov 21, 2024
7a94752
qchem tests and formatting
willjmax Nov 21, 2024
c789e95
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 21, 2024
fc0b865
formatting and doc fixes for CI
willjmax Nov 21, 2024
c616158
merge
willjmax Nov 21, 2024
4956bc2
filled in TODOs from resource_multi_qubit
willjmax Nov 21, 2024
15cd778
add global phase to FermionicSWAP
willjmax Nov 21, 2024
f92d17e
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 21, 2024
e4a7331
update multiX
willjmax Nov 22, 2024
54b6636
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 22, 2024
8ef2c3d
add multix to init
willjmax Nov 22, 2024
cfd2902
merge
willjmax Nov 22, 2024
43f9891
merge
willjmax Nov 22, 2024
4c9bc44
Merge branch 'resource_controlled_gates' into resource_multi_qubit
willjmax Nov 22, 2024
861509c
resource decomps for nested adjoints and pows, some fixes for controlled
willjmax Nov 25, 2024
66b49d5
nested controlled operations
willjmax Nov 25, 2024
d5ae48a
adding some resource methods
willjmax Nov 25, 2024
6adb131
Merge branch 'master' into resource_tracking
Jaybsoni Nov 25, 2024
54d2e9c
Merge branch 'master' into resource_controlled_gates
Jaybsoni Nov 25, 2024
cef11ed
adjoint resource methods for RX,RY,RZ
willjmax Nov 25, 2024
6902315
Merge branch 'resource_controlled_gates' into resource_multi_qubit
Jaybsoni Nov 25, 2024
92dbe72
merge master
Jaybsoni Nov 25, 2024
d7e1dbb
add CH to init
willjmax Nov 26, 2024
50385db
merge
willjmax Nov 26, 2024
d4e5a1a
merged master
Jaybsoni Nov 26, 2024
3699385
Merge branch 'resource_controlled_gates' into resource_multi_qubit
Jaybsoni Nov 26, 2024
a664175
merged base
Jaybsoni Nov 26, 2024
1269e11
add cswap to init
willjmax Nov 26, 2024
66dba38
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 26, 2024
9c22b30
merge
willjmax Nov 26, 2024
99faf1a
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 26, 2024
c643656
add ccz to init
willjmax Nov 26, 2024
b793798
merge
willjmax Nov 26, 2024
756e4c9
adjoint/control methods for non parametric ops
willjmax Nov 26, 2024
0f733aa
add crx,crz to init
willjmax Nov 26, 2024
67f7f3e
merge
willjmax Nov 26, 2024
195f489
add CRot to init
willjmax Nov 26, 2024
6b70bb9
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 26, 2024
854b822
controlled/adjoint resources methods for parametric ops
willjmax Nov 26, 2024
ffb4c8c
formatting
willjmax Nov 26, 2024
f2ab502
merge
willjmax Nov 26, 2024
fb27854
merge
willjmax Nov 26, 2024
54dd010
type annotations
willjmax Nov 26, 2024
321ff0f
Merge branch 'resource_multi_qubit' into resource_symbolic_ops
willjmax Nov 26, 2024
d8f8fba
add accidentally removed part of dcostring
willjmax Nov 26, 2024
68536bb
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 26, 2024
dea8747
add tracking_name static method and update tests
willjmax Nov 26, 2024
3769f8a
formatting
willjmax Nov 26, 2024
88a6af0
documentation updates
willjmax Nov 27, 2024
dfecfc6
update documentation
willjmax Nov 27, 2024
078464b
more resource methods
willjmax Nov 27, 2024
60c08e2
more resource methods
willjmax Nov 27, 2024
e2b98b0
tests for cnot
willjmax Nov 28, 2024
6177e54
tests for resource decomps
willjmax Nov 28, 2024
5723ae4
update controlled decomps
willjmax Nov 28, 2024
0a7ca0e
revert identity
willjmax Nov 28, 2024
854d9e5
revert identity changes
willjmax Nov 28, 2024
f58da1d
for rebasing
willjmax Nov 28, 2024
0c2d237
revert identity
willjmax Nov 28, 2024
c7d5ca1
undo
willjmax Nov 28, 2024
6d61b19
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 28, 2024
877da46
trying again
willjmax Nov 28, 2024
24e65f2
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 28, 2024
8c640f1
revert again
willjmax Nov 28, 2024
fb3b14e
again
willjmax Nov 28, 2024
e6b10d9
identity
willjmax Nov 28, 2024
eaed86b
Merge branch 'resource_symbolic_ops' into resource_symbolic_decomps
willjmax Nov 28, 2024
f7c1ac6
move changes
willjmax Nov 28, 2024
0201f0f
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 28, 2024
5843551
reverting qubit
willjmax Nov 28, 2024
7093c5e
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 28, 2024
220dfd9
moving qubit changes
willjmax Nov 28, 2024
0f6563a
revert change
willjmax Nov 28, 2024
f3773b0
revert test changes
willjmax Nov 28, 2024
f30236f
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 28, 2024
35e7f11
move tests
willjmax Nov 28, 2024
2984553
remove controlled_ops
willjmax Nov 28, 2024
743d15e
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 28, 2024
9b3a486
add controlled ops
willjmax Nov 28, 2024
d8e36a2
move controlled tests
willjmax Nov 28, 2024
af8fb92
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 28, 2024
c7585b5
move controlled tests
willjmax Nov 28, 2024
20f348d
update nested symbolic ops
willjmax Nov 28, 2024
8d24077
remove unused import
willjmax Nov 28, 2024
046c02e
remove nested tests
willjmax Nov 28, 2024
4866a63
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 28, 2024
e266b89
add nested tests
willjmax Nov 28, 2024
af89ccc
add docstrings back
willjmax Nov 28, 2024
d35d063
formatting
willjmax Nov 28, 2024
eb0a13e
formatting
willjmax Nov 28, 2024
0bce904
tracking name test
willjmax Nov 29, 2024
b2882c6
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 29, 2024
1882649
Apply suggestions from code review
Jaybsoni Nov 29, 2024
6ea2b70
Merge branch 'master' into resource_tracking
Jaybsoni Nov 29, 2024
3acd1fe
fix ctrl_values
willjmax Nov 29, 2024
052c39f
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 29, 2024
ee4b59a
code review comments
Jaybsoni Nov 29, 2024
fe1a247
add kwargs
willjmax Nov 29, 2024
ecacf47
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 29, 2024
6081471
fix docs + format
Jaybsoni Nov 29, 2024
8a40ecc
fix failing tests after ctrl value change
willjmax Nov 29, 2024
9071111
fixed comments
Jaybsoni Nov 29, 2024
a8aac38
Merge branch 'master' into resource_tracking
willjmax Nov 29, 2024
b1a8711
remove resource config and DefaultGateSet from docs
Jaybsoni Nov 29, 2024
45613b1
Merge branch 'master' into resource_tracking
Jaybsoni Nov 29, 2024
9e03409
Merge branch 'resource_tracking' into resource_controlled_gates
Jaybsoni Nov 29, 2024
e305474
redo control decomposition logic
willjmax Nov 29, 2024
114cbcd
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 29, 2024
dcf2630
formatting
willjmax Nov 29, 2024
6cc4003
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 29, 2024
9a199c8
fix control value error
willjmax Nov 29, 2024
87d9a8e
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Nov 29, 2024
6e17ff5
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Nov 29, 2024
1a10660
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Nov 29, 2024
1ac7191
Merge branch 'master' into resource_controlled_gates
Jaybsoni Nov 29, 2024
27b436c
update CY
willjmax Nov 29, 2024
a00b55c
Added tests and docs
Jaybsoni Nov 30, 2024
5e78717
changelog
Jaybsoni Nov 30, 2024
29b9cb2
Update pennylane/ops/op_math/controlled_ops.py
Jaybsoni Nov 30, 2024
b299cc0
Merge branch 'master' into resource_controlled_gates
Jaybsoni Nov 30, 2024
ca9df50
format
Jaybsoni Nov 30, 2024
7189792
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Dec 2, 2024
9ef2304
merge
willjmax Dec 2, 2024
83f1dff
Apply suggestions from code review
Jaybsoni Dec 2, 2024
ce84834
Format
Jaybsoni Dec 2, 2024
725f8b8
fix tests
willjmax Dec 2, 2024
a0e73f9
fix test
willjmax Dec 2, 2024
c181add
update docstring and foramt
Jaybsoni Dec 2, 2024
8fbf724
Merge branch 'master' into resource_controlled_gates
Jaybsoni Dec 2, 2024
5d79d3b
Apply suggestions from code review
Jaybsoni Dec 2, 2024
27adf31
fix docs
Jaybsoni Dec 2, 2024
1f0e85b
fix formatting
Jaybsoni Dec 2, 2024
5f0df95
some updates
willjmax Dec 2, 2024
512b9c1
fixing some tests
willjmax Dec 2, 2024
edca839
Merge branch 'resource_controlled_gates' of github.com:PennyLaneAI/pe…
willjmax Dec 2, 2024
debf812
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Dec 2, 2024
097e7bf
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Dec 2, 2024
922a89e
__repr__ returns tracking name
willjmax Dec 2, 2024
cfbb28a
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Dec 2, 2024
1766820
update tests
willjmax Dec 2, 2024
b79b903
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Dec 2, 2024
8ed270c
Merge branch 'master' of github.com:PennyLaneAI/pennylane into resour…
willjmax Dec 2, 2024
7684deb
remove TODOs
willjmax Dec 2, 2024
66f0ba7
merge
willjmax Dec 2, 2024
036e114
merge
willjmax Dec 2, 2024
79ccec6
remove tests
willjmax Dec 2, 2024
70b92aa
more merge stuff
willjmax Dec 2, 2024
19798e9
remove orbital
willjmax Dec 2, 2024
7c3bfec
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Dec 2, 2024
6f80147
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Dec 2, 2024
226b70e
fix tests after merge
willjmax Dec 2, 2024
66e6384
fix another test
willjmax Dec 2, 2024
81286ed
remove orbital
willjmax Dec 2, 2024
364b5cc
remove orbit test
willjmax Dec 2, 2024
f8b3b58
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Dec 2, 2024
2c6c8e7
add orbital stuff
willjmax Dec 2, 2024
76b9fce
review changes
willjmax Dec 2, 2024
bbc0a84
adding circuit diagrams to docstrings
willjmax Dec 3, 2024
5cb4155
remove trailing whitespace
willjmax Dec 3, 2024
1a1bd4d
doc fixes
willjmax Dec 3, 2024
94d5ebf
Merge branch 'master' into resource_multi_qubit
willjmax Dec 3, 2024
5e9af77
changelog
willjmax Dec 3, 2024
978f864
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Dec 3, 2024
8ef340c
Apply suggestions from code review
willjmax Dec 3, 2024
3418df7
Merge branch 'resource_multi_qubit' of github.com:PennyLaneAI/pennyla…
willjmax Dec 3, 2024
907aac4
remove tests from qchem
willjmax Dec 3, 2024
b75f4cf
merge
willjmax Dec 3, 2024
ae6fb97
some review changes
willjmax Dec 3, 2024
e170b6f
formatting
willjmax Dec 3, 2024
5268cd3
add tracking_name_from_op
willjmax Dec 3, 2024
4624819
tests
willjmax Dec 3, 2024
3018ddc
pylint
willjmax Dec 3, 2024
42e3bf1
Merge branch 'resource_symbolic_ops' into resource_symbolic_decomps
willjmax Dec 3, 2024
8484026
one more test
willjmax Dec 3, 2024
851aa91
chagelog
willjmax Dec 3, 2024
82a9269
Merge branch 'resource_symbolic_ops' of github.com:PennyLaneAI/pennyl…
willjmax Dec 3, 2024
46ba719
formatting
willjmax Dec 3, 2024
c39ffe1
controlled S and T
willjmax Dec 4, 2024
34c2a20
fix tests
willjmax Dec 4, 2024
3dbe71d
merge
willjmax Dec 6, 2024
b6a0e35
Merge branch 'master' into resource_symbolic_decomps
Jaybsoni Dec 9, 2024
2294a6e
fixing resource methods
Jaybsoni Dec 10, 2024
990cfaa
format
Jaybsoni Dec 10, 2024
17da0d0
fix globalphase decomp
Jaybsoni Dec 10, 2024
13efda9
modified resources
Jaybsoni Dec 12, 2024
f4d013f
Merge branch 'master' into resource_symbolic_decomps
Jaybsoni Dec 12, 2024
c7b8a41
fix qchem ops
Jaybsoni Dec 12, 2024
af3e755
added tests for identity and controlled ops
Jaybsoni Dec 13, 2024
c3a5425
finish tests for controlled
Jaybsoni Dec 13, 2024
1f88813
Merge branch 'master' into resource_symbolic_decomps
Jaybsoni Dec 13, 2024
b49aecb
Merge branch 'master' into resource_symbolic_decomps
Jaybsoni Dec 13, 2024
cab45a8
Merge branch 'master' into resource_symbolic_decomps
Jaybsoni Dec 16, 2024
416e8df
fixing up the single qubit parameteric ops and tests
Jaybsoni Dec 18, 2024
da61e3a
added multi-control decomps for non-parameteric ops and tests
Jaybsoni Dec 18, 2024
51115aa
fixed docstrings
Jaybsoni Dec 18, 2024
40b693d
finished adding tests
Jaybsoni Dec 19, 2024
25d2f4a
Merge branch 'master' into resource_symbolic_decomps
Jaybsoni Dec 19, 2024
79ed9ed
address comments
Jaybsoni Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pennylane/labs/resource_estimation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
~ResourceCY
~ResourceCZ
~ResourceDoubleExcitation
~ResourceDoubleExcitationMinus
~ResourceDoubleExcitationPlus
~ResourceFermionicSWAP
~ResourceGlobalPhase
~ResourceHadamard
Expand All @@ -72,6 +74,10 @@
~ResourceIsingZZ
~ResourceMultiControlledX
~ResourceMultiRZ
~ResourceMultiControlledX
~ResourceOrbitalRotation
~ResourcePauliRot
~ResourcePhaseShift
~ResourcePauliRot
~ResourcePhaseShift
~ResourcePSWAP
Expand All @@ -80,6 +86,7 @@
~ResourceRY
~ResourceRZ
~ResourceS
~ResourceSingleExcitation
~ResourceSingleExcitationMinus
~ResourceSingleExcitationPlus
~ResourceSWAP
Expand Down Expand Up @@ -152,6 +159,8 @@
ResourceCY,
ResourceCZ,
ResourceDoubleExcitation,
ResourceDoubleExcitationMinus,
ResourceDoubleExcitationPlus,
ResourceFermionicSWAP,
ResourceGlobalPhase,
ResourceHadamard,
Expand All @@ -162,6 +171,7 @@
ResourceIsingZZ,
ResourceMultiControlledX,
ResourceMultiRZ,
ResourceOrbitalRotation,
ResourcePauliRot,
ResourcePow,
ResourcePSWAP,
Expand All @@ -171,6 +181,7 @@
ResourceRY,
ResourceRZ,
ResourceS,
ResourceSingleExcitation,
ResourceSingleExcitationMinus,
ResourceSingleExcitationPlus,
ResourceSWAP,
Expand Down
4 changes: 4 additions & 0 deletions pennylane/labs/resource_estimation/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@

from .qubit import (
ResourceDoubleExcitation,
ResourceDoubleExcitationMinus,
ResourceDoubleExcitationPlus,
ResourceFermionicSWAP,
ResourceHadamard,
ResourceIsingXX,
ResourceIsingXY,
ResourceIsingYY,
ResourceIsingZZ,
ResourceMultiRZ,
ResourceOrbitalRotation,
ResourcePauliRot,
ResourcePhaseShift,
ResourcePSWAP,
Expand All @@ -35,6 +38,7 @@
ResourceRY,
ResourceRZ,
ResourceS,
ResourceSingleExcitation,
ResourceSingleExcitationMinus,
ResourceSingleExcitationPlus,
ResourceSWAP,
Expand Down
30 changes: 30 additions & 0 deletions pennylane/labs/resource_estimation/ops/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Copy link
Contributor Author

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 with return {}. The performance gain in returning {} is probably negligible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed 👍🏼


class ResourceGlobalPhase(qml.GlobalPhase, re.ResourceOperator):
"""Resource class for the GlobalPhase gate."""
Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to check if num_ctrl_wires == 1? or do all multi controlled global phases decompose to the same phase shift operator?

Copy link
Contributor

Choose a reason for hiding this comment

The 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 {}
Loading
Loading