Skip to content

Commit

Permalink
feature: add ECR gate (#14)
Browse files Browse the repository at this point in the history
* feature: add ECR gate

* spacing

* fix: ECR as DoubleTarget

Co-authored-by: Cody Wang <speller26@gmail.com>
  • Loading branch information
virajvchaudhari and speller26 committed Feb 1, 2022
1 parent b449437 commit 0e46a0c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/braket/ir/jaqcd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CV,
CY,
CZ,
ECR,
XX,
XY,
YY,
Expand Down
20 changes: 20 additions & 0 deletions src/braket/ir/jaqcd/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,26 @@ class Type(str, Enum):
type = Type.cz


class ECR(DoubleTarget):
"""
An echoed RZX(pi/2) gate.
Attributes:
type (str): The instruction type. default = "ecr". (type) is optional.
This should be unique among all instruction types.
targets (List[int]): The target qubits.
This is a list with two items and all items are int >= 0.
Examples:
>>> ECR(targets=[0, 1])
"""

class Type(str, Enum):
ecr = "ecr"

type = Type.ecr


class XX(DoubleTarget, Angle):
"""
The Ising (XX) gate.
Expand Down
3 changes: 3 additions & 0 deletions src/braket/ir/jaqcd/program_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
CV,
CY,
CZ,
ECR,
XX,
XY,
YY,
Expand Down Expand Up @@ -88,6 +89,7 @@
CV.Type.cv: CV,
CY.Type.cy: CY,
CZ.Type.cz: CZ,
ECR.Type.ecr: ECR,
H.Type.h: H,
I.Type.i: I,
ISwap.Type.iswap: ISwap,
Expand Down Expand Up @@ -169,6 +171,7 @@ class Program(BraketSchemaBase):
CV,
CY,
CZ,
ECR,
Depolarizing,
GeneralizedAmplitudeDamping,
Pauli_channel,
Expand Down
2 changes: 2 additions & 0 deletions test/unit_tests/braket/ir/jaqcd/test_quantum_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
CV,
CY,
CZ,
ECR,
XX,
XY,
YY,
Expand Down Expand Up @@ -113,6 +114,7 @@
(CV, [SingleTarget, SingleControl], "cv"),
(CY, [SingleTarget, SingleControl], "cy"),
(CZ, [SingleTarget, SingleControl], "cz"),
(ECR, [DoubleTarget], "ecr"),
(V, [SingleTarget], "v"),
(Vi, [SingleTarget], "vi"),
(XX, [DoubleTarget, Angle], "xx"),
Expand Down

0 comments on commit 0e46a0c

Please sign in to comment.