|
Documentation

guppy logo

Quantum-first programming
language, embedded in Python.

Get Started
guppy logo

Expressive

Write code that reads like the problem you’re solving. Guppy’s syntax is clear, concise, and flexible enough to capture complex quantum and classical logic without unnecessary boilerplate.

Safe

Guppy’s type system catches costly mistakes before they happen — including quantum-specific hazards.

Pythonic

If you can read Python, you can read Guppy. Its design is inspired by Python’s readability and simplicity, making it easy to learn. Guppy also lives inside Python, allowing seamless inter-op.

from guppylang import guppy
from guppylang.std.quantum import qubit, toffoli, s, measure
from guppylang.std.quantum.functional import h

@guppy
def repeat_until_success(q: qubit, attempts: int) -> bool:
    """
    Repeat-until-success circuit for Rz(acos(3/5))
    from Nielsen and Chuang, Fig. 4.17.
    """
    for i in range(attempts):
        a, b = h(qubit()), h(qubit())
        toffoli(a, b, q)
        s(q)
        toffoli(a, b, q)
        if not (measure(h(a)) | measure(h(b))):
            result("rus_attempts", i)
            return True
        return False
repeat_until_success.check() # type check

Features

Everything you'd expect from a modern programming language.

Arbitrary Control Flow

Full quantum measurement-dependent control flow: write if-else conditions, for and while loops, all in Python style.

Strongly Typed

The guppylang compiler uses a powerful but unobtrusive type system to provide helpful error messages.

Linear Qubits

Qubits have a linear type, following an intuitive ownership model that prevents no-cloning errors and memory leaks.

Metaprogramming

Generate and transform Guppy code at compile time to automate patterns, optimise circuits, and reduce repetition.

Classical Compute

Perform classical calculations and data manipulation alongside quantum operations seamlessly.

Data Structures

Work with arrays, tuples, and user-defined types in both classical and quantum contexts.

First-class Functions

Define functions to write structured quantum software, and pass them just like any other value.

Legacy Support

Easily integrate with existing quantum toolchains like pytket — bridging the gap with legacy circuit-building tools.

Read Language Guide ->

Examples

Some novel use cases with guppy.

Magic State Distillation icon

Magic State Distillation

Crucial protocols for Quantum Error Correction like magic state distillation require complex measurement dependent logic - Guppy expresses these naturally.

Open Notebook
Post-selection icon

Post-selection

Exit a shot when an error is detected without running any more operations.

Open Notebook
N-qubit Graph States icon

N-qubit Graph States

Use Python metaprogramming and Guppy polymorphism to write scalable and type safe state preparation.

Open Notebook
More Examples ->

Open Source

The guppylang compiler and the target HUGR intermediate representation are open source, and welcome contributions!