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

Arbitrary gate set conversion transpiler #341

Merged
merged 39 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
52d76dc
wip: add gateset trans
lqtmirage Oct 25, 2023
f7ca6da
wip: update gateset trans
lqtmirage Oct 26, 2023
80de330
wip: separate rot conversion
lqtmirage Oct 26, 2023
32bdfe6
wip: rot conversion trans
lqtmirage Oct 26, 2023
b8d2d0f
wip: add rot decomp
lqtmirage Oct 26, 2023
4fe13b3
wip: test frame for gateset
lqtmirage Oct 30, 2023
6ff8c86
wip: update gateset decomp
lqtmirage Oct 30, 2023
0570598
wip: refactor gateset decomp
lqtmirage Nov 6, 2023
9976533
wip: refactor rot set convert
lqtmirage Nov 6, 2023
da31b3e
wip: refactor rot set convert
lqtmirage Nov 6, 2023
9364f0d
wip: refactor rot set convert
lqtmirage Nov 6, 2023
94c2001
wip: fix gateset decomp
lqtmirage Nov 6, 2023
17cacec
wip: fix validation for rot gate decomp
lqtmirage Nov 6, 2023
1b4f6cd
wip: fix type annotations for gateset
lqtmirage Nov 6, 2023
b55d5f8
wip: refactor rot conv trans
lqtmirage Nov 6, 2023
a56d085
wip: add tests for simple rot conversion
lqtmirage Nov 6, 2023
c0abd5c
wip: cleanup file
lqtmirage Nov 6, 2023
a2eac87
wip: add tests for clifford rot trans
lqtmirage Nov 7, 2023
f7ab626
wip: cleanup file
lqtmirage Nov 7, 2023
a685209
wip: fix type annotations for gateset
lqtmirage Nov 7, 2023
5bc691a
add tests for gateset
lqtmirage Nov 7, 2023
48242e5
wip: error check, add docs in gateset trans
lqtmirage Nov 14, 2023
d8ae4e3
add docs for gateset trans
lqtmirage Nov 14, 2023
414a72c
update docs
lqtmirage Nov 20, 2023
693b817
fix rot conversion, reformat'
lqtmirage Dec 6, 2023
daa5399
fix redundant angle in gate decomp
lqtmirage Dec 6, 2023
03c3167
cleanup unused import
lqtmirage Dec 6, 2023
cbf6cd9
update comments
lqtmirage Jan 9, 2024
90b3509
update comments
lqtmirage Jan 9, 2024
10e9b43
fix clifford table
lqtmirage Jan 10, 2024
4add073
fix clifford table
lqtmirage Jan 10, 2024
9dff969
Merge branch 'main' into arb-gateset-decomp
lqtmirage Jan 10, 2024
c5d76fb
update clifford table
lqtmirage Jan 10, 2024
b329e78
update clifford table
lqtmirage Jan 10, 2024
2d091c8
refactor collection abc
lqtmirage Mar 1, 2024
60e2cf4
cache clifford trans
lqtmirage Mar 5, 2024
1525823
refactor code
lqtmirage Mar 5, 2024
900a847
fix type annotations
lqtmirage Mar 6, 2024
4a44f38
fix type annotations
lqtmirage Mar 6, 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
20 changes: 20 additions & 0 deletions packages/circuit/quri_parts/circuit/transpile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .fuse import (
FuseRotationTranspiler,
NormalizeRotationTranspiler,
Rotation2NamedTranspiler,
RX2NamedTranspiler,
RY2NamedTranspiler,
RZ2NamedTranspiler,
Expand Down Expand Up @@ -54,6 +55,16 @@
Z2HXTranspiler,
Z2RZTranspiler,
)
from .gateset import (
CliffordConversionTranspiler,
GateSetConversionTranspiler,
RotationConversionTranspiler,
RX2RYRZTranspiler,
RX2RZHTranspiler,
RY2RXRZTranspiler,
RY2RZHTranspiler,
RZ2RXRYTranspiler,
)
from .identity_manipulation import (
IdentityEliminationTranspiler,
IdentityInsertionTranspiler,
Expand Down Expand Up @@ -205,6 +216,14 @@ def __init__(self, epsilon: float = 1.0e-9):


__all__ = [
"CliffordConversionTranspiler",
"GateSetConversionTranspiler",
"RotationConversionTranspiler",
"RX2RYRZTranspiler",
"RX2RZHTranspiler",
"RY2RXRZTranspiler",
"RY2RZHTranspiler",
"RZ2RXRYTranspiler",
"CircuitTranspiler",
"CircuitTranspilerProtocol",
"GateDecomposer",
Expand All @@ -228,6 +247,7 @@ def __init__(self, epsilon: float = 1.0e-9):
"H2RXRYTranspiler",
"H2RZSqrtXTranspiler",
"QubitRemappingTranspiler",
"Rotation2NamedTranspiler",
"RX2RZSqrtXTranspiler",
"RY2RZSqrtXTranspiler",
"RX2NamedTranspiler",
Expand Down
17 changes: 16 additions & 1 deletion packages/circuit/quri_parts/circuit/transpile/fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
gates,
)

from .transpiler import CircuitTranspilerProtocol, GateKindDecomposer
from .transpiler import (
CircuitTranspilerProtocol,
GateKindDecomposer,
SequentialTranspiler,
)


class TwoGateFuser(CircuitTranspilerProtocol, ABC):
Expand Down Expand Up @@ -206,3 +210,14 @@ def decompose(self, gate: QuantumGate) -> Sequence[QuantumGate]:
return [gates.Tdag(target)]
else:
return [gate]


class Rotation2NamedTranspiler(SequentialTranspiler):
def __init__(self, epsilon: float = 1.0e-9):
super().__init__(
[
RX2NamedTranspiler(epsilon),
RY2NamedTranspiler(epsilon),
RZ2NamedTranspiler(epsilon),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def decompose(self, gate: QuantumGate) -> Sequence[QuantumGate]:
gates.SqrtX(target),
gates.RZ(target, theta + np.pi),
gates.SqrtX(target),
gates.RZ(target, 5.0 * np.pi / 2.0),
gates.RZ(target, np.pi / 2.0),
]


Expand All @@ -150,7 +150,7 @@ def decompose(self, gate: QuantumGate) -> Sequence[QuantumGate]:
gates.SqrtX(target),
gates.RZ(target, theta + np.pi),
gates.SqrtX(target),
gates.RZ(target, 3.0 * np.pi),
gates.RZ(target, np.pi),
]


Expand Down Expand Up @@ -428,7 +428,7 @@ def decompose(self, gate: QuantumGate) -> Sequence[QuantumGate]:
gates.SqrtX(target),
gates.RZ(target, theta + np.pi),
gates.SqrtX(target),
gates.RZ(target, phi + 3.0 * np.pi),
gates.RZ(target, phi + np.pi),
]


Expand All @@ -448,7 +448,7 @@ def decompose(self, gate: QuantumGate) -> Sequence[QuantumGate]:
gates.RX(target, np.pi / 2.0),
gates.RZ(target, theta + np.pi),
gates.RX(target, np.pi / 2.0),
gates.RZ(target, phi + 3.0 * np.pi),
gates.RZ(target, phi + np.pi),
]


Expand Down
Loading
Loading