From 822ce7a579844a4d821cee3ab03a12da4f547d1a Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Fri, 15 Nov 2024 14:46:24 +0000 Subject: [PATCH 1/2] docs: fix quickstart.md --- quickstart.md | 20 ++++++++++++-------- uv.lock | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/quickstart.md b/quickstart.md index 3cdca383..81c058df 100644 --- a/quickstart.md +++ b/quickstart.md @@ -4,22 +4,26 @@ flow and mid-circuit measurements using Pythonic syntax: ```python from guppylang import guppy -from guppylang.prelude.quantum import cx, h, measure, qubit, x, z +from guppylang.std.builtins import owned +from guppylang.std.quantum import cx, h, measure, qubit, x, z + @guppy -def teleport(src: qubit, tgt: qubit) -> qubit: +def teleport(src: qubit @ owned, tgt: qubit) -> None: """Teleports the state in `src` to `tgt`.""" # Create ancilla and entangle it with src and tgt tmp = qubit() - tmp, tgt = cx(h(tmp), tgt) - src, tmp = cx(src, tmp) + h(tmp) + cx(tmp, tgt) + cx(src, tmp) # Apply classical corrections - if measure(h(src)): - tgt = z(tgt) + h(src) + if measure(src): + z(tgt) if measure(tmp): - tgt = x(tgt) - return tgt + x(tgt) + guppy.compile_module() ``` diff --git a/uv.lock b/uv.lock index c3cca57d..46ad0e6c 100644 --- a/uv.lock +++ b/uv.lock @@ -541,7 +541,7 @@ wheels = [ [[package]] name = "guppylang" -version = "0.13.0" +version = "0.13.1" source = { editable = "." } dependencies = [ { name = "graphviz" }, From a8da3921dcc53a7595edbf8e1442be36665121ce Mon Sep 17 00:00:00 2001 From: Seyon Sivarajah Date: Fri, 15 Nov 2024 15:03:54 +0000 Subject: [PATCH 2/2] fix readme --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2cebec26..dd114e06 100644 --- a/README.md +++ b/README.md @@ -13,22 +13,25 @@ It allows you to write high-level hybrid quantum programs with classical control ```python from guppylang import guppy -from guppylang.prelude.quantum import cx, h, measure, qubit, x, z +from guppylang.std.builtins import owned +from guppylang.std.quantum import cx, h, measure, qubit, x, z + @guppy -def teleport(src: qubit, tgt: qubit) -> qubit: +def teleport(src: qubit @ owned, tgt: qubit) -> None: """Teleports the state in `src` to `tgt`.""" # Create ancilla and entangle it with src and tgt tmp = qubit() - tmp, tgt = cx(h(tmp), tgt) - src, tmp = cx(src, tmp) + h(tmp) + cx(tmp, tgt) + cx(src, tmp) # Apply classical corrections - if measure(h(src)): - tgt = z(tgt) + h(src) + if measure(src): + z(tgt) if measure(tmp): - tgt = x(tgt) - return tgt + x(tgt) guppy.compile_module() ```