-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add some tests for guppy 1q squashing #1221
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
Open
CalMacCQ
wants to merge
11
commits into
main
Choose a base branch
from
cm/1q_squash_test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
431502e
add some test case for 1q squashing
CalMacCQ ffe898c
update comment
CalMacCQ 3e41e53
add missing file export
CalMacCQ fb6efb2
generate hugrs for simple test cases
CalMacCQ bb99d96
regenerate everything with the latest guppy version
CalMacCQ 0d98516
Merge branch 'main' into cm/1q_squash_test
CalMacCQ ecc335f
Merge branch 'main' into cm/1q_squash_test
CalMacCQ 468d11e
try calling squash in tests
CalMacCQ 02831b9
fix string
CalMacCQ ab7359a
fix name
CalMacCQ 627bdef
fix quotes
CalMacCQ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
test_files/guppy_optimization/1q_squash/qsystem_chain.opt.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) | ||
| 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()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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