We present ongoing work on Guppy, a domain-specific language embedded in Python that allows users to write high-level hybrid quantum programs with complex control flow in Pythonic syntax, aiming to run them on actual quantum hardware.
This paper introduces Guppy, a domain-specific language (DSL) embedded in Python that enables users to write high-level hybrid quantum programs with complex control flow using Pythonic syntax, with the goal of executing these programs on actual quantum hardware.
Python's Dominance in Quantum Computing: According to recent surveys, over 90% of quantum computing researchers and practitioners use Python, yet existing frameworks are limited by circuit-level abstractions and provide limited support for high-level control flow.
Real-time Quantum-Classical Computing Requirements: Algorithms such as repeat-until-success protocols require real-time classical data processing based on quantum measurement results, a need that will grow with next-generation quantum devices.
Limitations of Existing Approaches:
Most Python frameworks construct quantum program representations by tracing the Python interpreter, unable to capture native Python control flow syntax
Conditional statements and loops must be expressed through higher-order combinators or other syntactic structures
Lack of linear type systems to prevent quantum programming errors
Develop a programming language that maintains Python's friendly syntax and ecosystem advantages while supporting complex quantum-classical hybrid computation.
Proposed Guppy DSL: A domain-specific language embedded in Python supporting Pythonic syntax for writing quantum-classical hybrid programs
Implemented Linear Type System: Captures quantum programming errors (such as violations of the no-cloning theorem) at compile time through linear Qubit types
Support for Complex Control Flow: Native support for conditional statements, loops, and other control flow structures based on measurement results
Static Compilation to Hugr IR: Compiles to the novel quantum intermediate representation Hugr, supporting expression and optimization of quantum-classical programs
Python Interoperability: Seamless integration with the Python ecosystem through py(...) expressions
@guppy
def rus(q: Qubit, tries: int) -> Qubit:
for _ in range(tries):
a, b = h(Qubit()), h(Qubit())
b, a = cx(b, tdg(a))
if not measure(t(a)):
discard(b)
continue
q, b = cx(z(t(q)), b)
if measure(t(b)):
break
q = x(q)
return q
Quantum computing theory (linear types, quantum circuit optimization)
Summary: This is a high-quality systems paper proposing innovative quantum programming language design. Although still in early stages, it demonstrates strong technical potential and practical promise. Subsequent work should focus on large-scale validation, performance optimization, and user experience improvement.