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

docs: fix README.md and quickstart.md #654

Merged
merged 2 commits into from
Nov 15, 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
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
Expand Down
20 changes: 12 additions & 8 deletions quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading