Skip to content

feat: add some tests for guppy 1q squashing - #1221

Open
CalMacCQ wants to merge 11 commits into
mainfrom
cm/1q_squash_test
Open

CalMacCQ wants to merge 11 commits into
mainfrom
cm/1q_squash_test

Conversation

@CalMacCQ

@CalMacCQ CalMacCQ commented Nov 3, 2025

Copy link
Copy Markdown
Contributor
  1. Added some simple test cases for 1q squashing... See (the guppy_optimization/1q_squash directory)
  2. I've also updated the minimal guppy version to 0.21.6 and updated the syntax accordingly (.compile() -> .compile_function()).
  3. Finally I've regenerated the hugrs for all files with the new Guppy version. Let me know if I should break up these changes.

@CalMacCQ
CalMacCQ requested a review from a team as a code owner November 3, 2025 17:49
@CalMacCQ
CalMacCQ requested a review from doug-q November 3, 2025 17:49
@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
Copy Markdown
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

@CalMacCQ
CalMacCQ requested a review from aborgna-q November 3, 2025 17:54
@CalMacCQ

CalMacCQ commented Nov 3, 2025

Copy link
Copy Markdown
Contributor Author

Had some issues generating the HUGRs in my local env. Will try again tomorrow.

@ferbetanzo ferbetanzo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see the lines at the bottom of the .py files to generate the hugr, like in the other test_files/ examples (see below). Was this on purpose?

program = main.compile()
Path(argv[0]).with_suffix(".hugr").write_bytes(program.to_bytes())

@ferbetanzo

Copy link
Copy Markdown
Contributor

Oh, and also the lines to specify the dependencies to the uv script:

# /// script
# requires-python = ">=3.13"
# dependencies = [
#     "guppylang >=0.21.3",
# ]
# ///

@CalMacCQ

CalMacCQ commented Nov 4, 2025

Copy link
Copy Markdown
Contributor Author

I don't see the lines at the bottom of the .py files to generate the hugr, like in the other test_files/ examples (see below). Was this on purpose?

program = main.compile()
Path(argv[0]).with_suffix(".hugr").write_bytes(program.to_bytes())

Ah thanks Fernando, I missed that

@acl-cqc

acl-cqc commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

@CalMacCQ I have indeed pulled out the regeneration of existing examples into #1249 because, erm, the old versions were broken (guppy has since been fixed)...thanks!

github-merge-queue Bot pushed a commit that referenced this pull request Nov 12, 2025
The first part here is identical to examples from #1221 but I also
needed myself. The second part....well, revealed why we need the first
(I think updating to include Quantinuum/guppylang#1311
is particularly important) - DCE was taking out the gates because we
were not doing anything to keep the `result` ops (!).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants