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

Qubit allocation / discard. #104

Closed
aborgna-q opened this issue Jan 15, 2024 · 1 comment · Fixed by #107
Closed

Qubit allocation / discard. #104

aborgna-q opened this issue Jan 15, 2024 · 1 comment · Fixed by #107
Assignees
Labels
enhancement New feature or request

Comments

@aborgna-q
Copy link
Collaborator

I'm trying to modify the planqc examples to work with the current runner.

This is the original rx example (plus some imports and module definitions).

from guppy.decorator import guppy
from guppy.module import GuppyModule
import guppy.prelude.quantum as quantum
from guppy.prelude.quantum import Qubit, h, measure, rz

module = GuppyModule("module")
module.load(quantum)

@guppy(module)
def rx(q: Qubit, a: float) -> Qubit:
  # Implement Rx via Rz rotation
  return h(rz(h(q), a))

@guppy(module)
def main() -> bool:
  q = Qubit()
  r = rx(q,1.5)
  return measure(r)

This tries to allocate a qubit calling Qubit(), and assumes that measure is destructive.
We do not currently have a qubit allocation method, and measure is Qubit -> (bool, Qubit).

If we want to keep this structure, we need a pair of quantum alloc/free functions.

@aborgna-q aborgna-q added the enhancement New feature or request label Jan 15, 2024
@mark-koch mark-koch self-assigned this Jan 16, 2024
@ss2165
Copy link
Member

ss2165 commented Jan 16, 2024

Also blocked by: CQCL/tket2#283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants