Skip to content

docs: add qsystem gate definitions #912

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

docs: add qsystem gate definitions #912

wants to merge 7 commits into from

Conversation

CalMacCQ
Copy link
Contributor

@CalMacCQ CalMacCQ commented Apr 8, 2025

Testing out adding some gate definitions and doctests to the qsystem docs

Couple things

  • potentially quite a pain to add defintions for all gates across std.qsystem and std.quantum.
  • We would also have to duplciate content across qsystem and qsystem_functional (also quantum and qauntum_functional)
  • Need to ensure the doctests are working properly

Screenshot 2025-04-08 at 18 07 44

Screenshot 2025-04-08 at 18 07 51

@CalMacCQ CalMacCQ requested a review from a team as a code owner April 8, 2025 17:07
@CalMacCQ CalMacCQ requested a review from tatiana-s April 8, 2025 17:07
@CalMacCQ CalMacCQ marked this pull request as draft April 8, 2025 17:07
@codecov-commenter
Copy link

codecov-commenter commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.18%. Comparing base (d39b51c) to head (311af2c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #912   +/-   ##
=======================================
  Coverage   93.18%   93.18%           
=======================================
  Files          84       84           
  Lines        9628     9628           
=======================================
  Hits         8972     8972           
  Misses        656      656           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

f1 = float(angle)
_rz(q, f1)


@guppy.hugr_op(quantum_op("Measure", ext=QSYSTEM_EXTENSION), module=qsystem)
@no_type_check
def measure(q: qubit @ owned) -> bool: ...
def measure(q: qubit @ owned) -> bool:
"""Measure a qubit destructively."""
Copy link
Member

Choose a reason for hiding this comment

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

It's worth noting that this version of measure is blocking unlike quantum.measure that is lazy. I am unsure if that should be documented here or now.

Copy link
Member

Choose a reason for hiding this comment

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

Never mind, I am wrong. Both of the variants of measure are lazy.

@ss2165
Copy link
Member

ss2165 commented Apr 17, 2025

  1. Increasingly it looks like it would be handy to have a utility that defines and compiles a single function. To be used in exmamples, doc tests, prototyping, etc. @mark-koch are you opposed to adding a dedicated decorator for this? (prompted by having to call compile() at the end of the doctest)
  2. Don't duplicate docs, cross-link to the non-functional one in each case. e.g. "Functional variant of zz_phase, see guppylang.std.qsystem.zz_phase"

@mark-koch
Copy link
Collaborator

are you opposed to adding a dedicated decorator for this?

If we use this in all examples then that's what people will copy and use themselves. So I think we have to be careful that this doesn't become an anti-pattern. In particular, it would be bad if people slapped that decorator on every function.

Also, where would you get the compiled Hugr from? Returning it from the decorator would make it hard to use those functions for comptime

@ss2165
Copy link
Member

ss2165 commented Apr 17, 2025

we have to be careful that this doesn't become an anti-pattern

yes good point, what about a kwarg to @guppy that makes it clear that this is a thing you shouldn't do normally? Or a check kwarg that only does the checking stage and not compilation to hugr?

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.

5 participants