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

feat!: remove dirty_qubit #698

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 2 additions & 10 deletions guppylang/std/quantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@

@guppy.type(ht.Qubit, linear=True)
class qubit:
@guppy
@guppy.hugr_op(quantum_op("QAlloc"))
@no_type_check
def __new__() -> "qubit":
q = dirty_qubit()
reset(q)
return q
def __new__() -> "qubit": ...

@guppy
@no_type_check
Expand Down Expand Up @@ -121,11 +118,6 @@ def crz(control: qubit, target: qubit, angle: angle) -> None: ...
def toffoli(control1: qubit, control2: qubit, target: qubit) -> None: ...


@guppy.hugr_op(quantum_op("QAlloc"))
@no_type_check
def dirty_qubit() -> qubit: ...


@guppy.custom(InoutMeasureCompiler())
@no_type_check
def project_z(q: qubit) -> bool: ...
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_qalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
from guppylang.module import GuppyModule
from guppylang.std.quantum import qubit

from guppylang.std.quantum import dirty_qubit, measure
from guppylang.std.quantum import measure
from guppylang.std.quantum_functional import cx

import guppylang.std.quantum_functional as quantum_functional


def test_dirty_qubit(validate):
def test_qalloc(validate):
module = GuppyModule("test")
module.load_all(quantum_functional)
module.load(qubit, dirty_qubit, measure)
module.load(qubit, measure)

@guppy(module)
def test() -> tuple[bool, bool]:
q1, q2 = qubit(), dirty_qubit()
q1, q2 = qubit(), qubit()
q1, q2 = cx(q1, q2)
return (measure(q1), measure(q2))

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_quantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from guppylang.std.builtins import owned

from guppylang.std.quantum import dirty_qubit, discard, measure, qubit
from guppylang.std.quantum import discard, measure, qubit
from guppylang.std.quantum_functional import (
cx,
cy,
Expand Down Expand Up @@ -43,16 +43,16 @@ def compile_quantum_guppy(fn) -> ModulePointer:
), "`@compile_quantum_guppy` does not support extra arguments."

module = GuppyModule("module")
module.load(angle, qubit, dirty_qubit, discard, measure)
module.load(angle, qubit, discard, measure)
module.load_all(quantum_functional)
guppylang.decorator.guppy(module)(fn)
return module.compile()


def test_dirty_qubit(validate):
def test_alloc(validate):
@compile_quantum_guppy
def test() -> tuple[bool, bool]:
q1, q2 = qubit(), dirty_qubit()
q1, q2 = qubit(), qubit()
q1, q2 = cx(q1, q2)
return (measure(q1), measure(q2))

Expand Down
Loading