HUGR: A Quantum-Classical Intermediate Representation
Koch, Borgna, Sivarajah et al.
We introduce the Hierarchical Unified Graph Representation (HUGR): a novel graph based intermediate representation for mixed quantum-classical programs. HUGR's design features high expressivity and extensibility to capture the capabilities of near-term and forthcoming quantum computing devices, as well as new and evolving abstractions from novel quantum programming paradigms. The graph based structure is machine-friendly and supports powerful pattern matching based compilation techniques. Inspired by MLIR, HUGR's extensibility further allows compilation tooling to reason about programs at multiple levels of abstraction, lowering smoothly between them. Safety guarantees in the structure including strict, static typing and linear quantum types allow rapid development of compilation tooling without fear of program invalidation. A full specification of HUGR and reference implementation are open-source and available online.
academic
HUGR: A Quantum-Classical Intermediate Representation
This paper introduces HUGR (Hierarchical Unified Graph Representation): a novel graph-based intermediate representation for hybrid quantum-classical programs. HUGR is designed with high expressiveness and extensibility to capture the capabilities of near-term and future quantum computing devices, as well as novel abstractions from emerging quantum programming paradigms. The graph-based structure is machine-friendly and supports powerful pattern-matching-based compilation techniques. Inspired by MLIR, HUGR's extensibility further allows compilation tools to reason about programs at multiple abstraction levels, with smooth lowering between them. Safety guarantees in the structure include strict static typing and linear quantum types, enabling rapid development of compilation tools without concerns about program invalidation. The complete specification and reference implementation of HUGR have been open-sourced and are available online.
Modern quantum computing applications typically involve interactions between quantum and classical processors, particularly algorithms requiring classical decisions within quantum coherence times. Examples include:
Repeat-Until-Success Protocols: Classical control flow based on intermediate measurement results to determine subsequent quantum operations
Quantum Error Correction Algorithms: Requiring complex classical logic for real-time error decoding and correction application
Hybrid Quantum-Classical Optimization: Tight integration between quantum and classical processing
Traditional quantum compilation frameworks are primarily based on static circuit models with limited support for dynamic quantum-classical programs, typically relying on control flow unrolling. This approach cannot effectively handle quantum algorithms requiring real-time classical decisions, limiting the practical application potential of quantum computing.
Traditional Frameworks (Cirq, Qiskit, TKET, etc.): Primarily represent quantum circuits as gate lists or graphs with limited support for dynamic quantum-classical programs
QIR: Based on LLVM IR, treats qubits as opaque pointers, requiring global dataflow analysis to track qubits, lacking scalability
OpenQASM 3: More resembles a high-level programming language than an intermediate representation
There is a need for a quantum program intermediate representation capable of natively capturing classical operations and transcending traditional circuit models to support tight integration of quantum and classical processors in quantum software stacks.
Unlike traditional separate processing, HUGR unifies quantum and classical operations in the same graph structure, supporting fine-grained quantum-classical interactions.
By enforcing single-connection constraints on quantum bit ports, HUGR prevents physically unrealizable operations like qubit duplication at compile time.
The core HUGR is decoupled from concrete operations, allowing users to define domain-specific operations and data types without modifying the core implementation.
Supports program representation and transformation across multiple abstraction levels, from high-level algorithm descriptions to hardware-specific instruction sets.
HUGR successfully unifies quantum-classical program representation, supporting full spectrum expressiveness from traditional circuits to complex hybrid algorithms
Hierarchical graph structure and strict type system provide solid foundation for compilation tool development
Extensible design supports rapid development and integration of new abstractions in quantum computing
Pattern-matching-based optimization framework provides new pathways for efficient program optimization
Graph optimization and pattern matching techniques
Overall Assessment: This is a high-quality systematic paper proposing a unified intermediate representation urgently needed in quantum computing. While experimental validation could be more comprehensive, its innovative design philosophy, complete technical solution, and open-source implementation provide significant academic value and practical potential. This work is likely to become important infrastructure for quantum-classical hybrid programming.