Getting Started with Guppy
If you’ve ever been curious about quantum computing but didn’t know where to start, Guppy is one of the most approachable entry points — especially if you already know Python.
What is Guppy?
Guppy is a quantum-first programming language that runs on real quantum computers. The language is open source and built by the quantum computing company, Quantinuum.
Features
- Embedded in Python: integration with existing Python workflows makes adoption smoother.
- Familiar syntax: learning is simpler, since writing Guppy programs is familiar to those who understand Python.
- Compiler and Qubit Safety: the compiler can detect potential runtime errors that would be expensive if they ran on quantum hardware.
- Hybrid Compute: real-time classical compute and quantum programming logic can exist in the same program.
- Quantum Emulation: Guppy can run simulations through an emulator known as “Selene” without needing to use real (and expensive) quantum computers.
When writing a Python function, using the @guppy decorator can make a function run as a quantum circuit.
# An example of a Guppy Function
@guppy
def circuit() -> qubit:
q = qubit()
h(q)
return q
Here’s a more complete example — a Bell state circuit:
# Python host
from guppylang import guppy
# Quantum kernel
@guppy
def bell() -> tuple[qubit, qubit]:
q0, q1 = qubit(), qubit()
h(q0)
cx(q0,q1)
return q0, q1
@guppy
def main() -> None:
q0, q1 = bell()
c0 = measure(q0)
c1 = measure(q1)
# Compile
hugr = main.compile()
# Run
main.emulator(n_qubits=2).run()
A Bell state is one of the simplest examples of quantum entanglement — measuring one qubit instantly determines the state of the other, no matter how far apart they are.
The Guppy Compiler
Guppy is strongly-typed, which makes it possible to catch and report compilation errors during development. This helps developers find bugs early and can save time and avoid costly quantum resources.
The compiler can recognize linearity violations on qubits. Linearity is a critical part of quantum computing — it’s an essential concept that makes quantum algorithms work.
The compiler goes through a series of steps to translate Guppy code into runnable code on quantum hardware. The goal of this series is to explain how this works for the benefit of future Guppy developers.
In the next parts of the series, I will explain more about why linearity matters and how the Guppy compiler works to enforce this.
For more details on Guppy, explore the official documentation: docs.quantinuum.com/guppy