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, z, 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)).read() | measure(h(b)).read()):
            output("rus_failed_attempts", i)
            return True
        z(q)
    output("rus_failed_attempts", attempts)
    return False
repeat_until_success.check() # type check

Features

A familiar set of modern language features.

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.

Qubit Safety

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

Fault Tolerant Compilation

Guppy FT extends Guppy with tools for fault-tolerant computing. This includes compiling programs with different QEC codes.

Algorithmic Primitives

The Guppy Algorithms package provides suite of reusable primitives for composing quantum algorithms.

Emulation

Guppy programs with complex control flow can be executed with the Selene emulator which also supports error models and different simulation modes.

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 the Guppy Language Guide ->

Toolkit

Tools for developing, compiling, simulating, and running quantum programs on quantum hardware.

Guppylang

Quantum-first programming language, embedded in Python.

Get Started
github icon

Guppy Algorithms

Reusable primitives for composing quantum algorithms.

Get Started
github icon

Selene

An emulation framework for running and verifying Guppy programs.

Get Started
github icon

Guppy FT

Tools for building runnable fault-tolerant programs from Guppy.

Get Started
github icon

Examples

Some novel use cases with guppy.

Magic State Distillation icon

Magic State Distillation

Guppy can express measurement dependent logic naturally which is crucial for QEC protocols like magic state distillation.

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
Encoding with Steane icon

Encoding with Steane

Logically encoded fault tolerant programming using the Steane code.

Open Notebook
Trotterised Hamiltonian Simulation icon

Trotterised Hamiltonian Simulation

Simulate the time evolution of a quantum system under a given Hamiltonian.

Open Notebook
More Examples ->

Open Source

The guppylang toolkit and compiler toolchain are open source, and welcome contributions!