Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
10 changes: 10 additions & 0 deletions test_files/guppy_optimization/1q_squash/qsystem_chain.opt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from guppylang import guppy
from guppy.std.quantum import qubit
from guppylang.std.qsystem import rz, phased_x
from guppylang.std.builtins import angle


@guppy
def qsystem_chain(q: qubit) -> None:
phased_x(q, angle(0.368713), angle(1.66415))
rz(q, angle(0.870616))
33 changes: 33 additions & 0 deletions test_files/guppy_optimization/1q_squash/qsystem_chain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from guppylang import guppy
from guppy.std.quantum import qubit
from guppylang.std.qsystem import rz, phased_x
from guppylang.std.builtins import angle


@guppy
def qsystem_chain(q: qubit) -> None:
phased_x(q, angle(0.91), angle(0.5))
phased_x(q, angle(0.53), angle(0))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I should make these angles a bit friendlier. I have included the pytket code below though.

The argument order for the phased X gate should be the same as pytket

phased_x(q, angle(3.29), angle(0.5))
phased_x(q, angle(0.81), angle(0))
rz(q, angle(0.62))


# pytket code to generate this example.
# For the optimised version replace the call to AutoRebase with AutoSquash.

# from pytket import Circuit, OpType
# from pytket.passes import AutoSquash, AutoRebase
#
# circ = Circuit(1)
#
# circ.Ry(0.91, 0)
# circ.Rx(0.53, 0)
# circ.Ry(-0.71, 0)
# circ.Rx(0.81, 0)
# circ.Rz(0.62, 0)
#
# When you switch to AutoSquash, remove ZZPhase from the set
# AutoRebase({OpType.Rz, OpType.PhasedX, OpType.ZZPhase}).apply(circ)
#
# print(circ.get_commands())
8 changes: 8 additions & 0 deletions test_files/guppy_optimization/1q_squash/rz_chain.opt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from guppylang import guppy
from guppylang.std.quantum import rz, qubit
from guppylang.std.builtins import angle


@guppy
def rz_chain(q: qubit) -> None:
rz(q, angle(3 / 2))
10 changes: 10 additions & 0 deletions test_files/guppy_optimization/1q_squash/rz_chain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from guppylang import guppy
from guppylang.std.quantum import rz, qubit
from guppylang.std.builtins import angle


@guppy
def rz_chain(q: qubit) -> None:
rz(q, angle(1 / 2))
rz(q, angle(1 / 2))
rz(q, angle(1 / 2))
Loading