2025-11-23T08:19:15.914309

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

Basic Information

  • Paper ID: 2510.11420
  • Title: HUGR: A Quantum-Classical Intermediate Representation
  • Authors: Mark Koch, Agustín Borgna, Seyon Sivarajah, Alan Lawrence, Alec Edgington, Douglas Wilson, Craig Roy, Luca Mondada, Lukas Heidemann, Ross Duncan (Quantinuum)
  • Classification: cs.PL (Programming Languages), quant-ph (Quantum Physics)
  • Publication Date: October 13, 2025 (arXiv preprint)
  • Paper Link: https://arxiv.org/abs/2510.11420

Abstract

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.

Research Background and Motivation

Problem Definition

Modern quantum computing applications typically involve interactions between quantum and classical processors, particularly algorithms requiring classical decisions within quantum coherence times. Examples include:

  1. Repeat-Until-Success Protocols: Classical control flow based on intermediate measurement results to determine subsequent quantum operations
  2. Quantum Error Correction Algorithms: Requiring complex classical logic for real-time error decoding and correction application
  3. Hybrid Quantum-Classical Optimization: Tight integration between quantum and classical processing

Problem Significance

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.

Limitations of Existing Approaches

  1. Traditional Frameworks (Cirq, Qiskit, TKET, etc.): Primarily represent quantum circuits as gate lists or graphs with limited support for dynamic quantum-classical programs
  2. QIR: Based on LLVM IR, treats qubits as opaque pointers, requiring global dataflow analysis to track qubits, lacking scalability
  3. OpenQASM 3: More resembles a high-level programming language than an intermediate representation

Research Motivation

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.

Core Contributions

  1. Proposed HUGR Framework: The first graph-based intermediate representation for unified representation of hybrid quantum-classical programs
  2. Hierarchical Graph Structure: Supports arbitrarily nested control flow and multi-level abstractions
  3. Type Safety Guarantees: Strict static type system and linear quantum types ensure program correctness
  4. Extensible Design: Modular operation and data type definition system, similar to MLIR's dialect system
  5. Efficient Optimization Support: Pattern-matching-based optimization techniques supporting parallelization and efficient composition
  6. Open-Source Implementation: Provides complete specification and Rust reference implementation

Methodology Details

Task Definition

HUGR aims to provide an intermediate representation capable of:

  • Input: High-level descriptions of hybrid quantum-classical programs
  • Output: Optimizable, analyzable graph structure representation
  • Constraints: Maintaining type safety, linear quantum type constraints, and program semantics

Model Architecture

1. Dataflow Graph Foundation

HUGR represents programs as dataflow graphs connecting input and output nodes:

  • Nodes: Quantum or classical operations
  • Edges: Directed connections carrying qubits or classical data
  • Ports: Explicitly numbered input/output interfaces on nodes
In → Addf64 → Rz → Out
      ↓      ↗
     f64   Rx

2. Type System

  • Static Typing: All edges have static types, node operations have static signatures
  • Linear Quantum Types: Quantum bit ports can only have one connecting edge, preventing qubit duplication
  • Classical Value Copying: Classical values can be copied and used multiple times

3. Hierarchical Structure

Nodes can contain nested subgraphs, supporting:

  • Conditional Operations: Branching between multiple execution graphs based on control input
  • TailLoop Operations: Structured loop subgraphs
  • CFG Nodes: Unstructured control flow graphs containing BasicBlock nodes

4. Functions and Higher-Order Types

  • FuncDef: Functions defined as dataflow graphs
  • FuncDecl: External function declarations
  • Constant Edges: Representing compile-time static values (dashed lines)
  • LoadFunction: Converting static function values to dynamic runtime values
  • Polymorphic Signatures: Supporting function definitions with type variables

Technical Innovations

1. Unified Quantum-Classical Representation

Unlike traditional separate processing, HUGR unifies quantum and classical operations in the same graph structure, supporting fine-grained quantum-classical interactions.

2. Linear Type Constraints

By enforcing single-connection constraints on quantum bit ports, HUGR prevents physically unrealizable operations like qubit duplication at compile time.

3. Modular Extension System

The core HUGR is decoupled from concrete operations, allowing users to define domain-specific operations and data types without modifying the core implementation.

4. Hierarchical Abstraction Support

Supports program representation and transformation across multiple abstraction levels, from high-level algorithm descriptions to hardware-specific instruction sets.

Experimental Setup

Implementation Details

  • Reference Implementation: Rust language implementation leveraging memory safety features
  • Open Source Availability: Complete specification and implementation at github.com/CQCL/hugr
  • MLIR Compatibility: Provides MLIR dialect prototype implementation (github.com/CQCL/hugr-mlir)

Example Programs

The paper provides multiple example programs validating HUGR's expressiveness:

1. Dynamic Angle Rotation

In → Add → Rz → Rx → Out
     ↓    ↗    ↗
    f64  f64  qubit

2. Conditional Quantum Gates

Programs conditionally executing H or X gates based on measurement results

3. Repeat-Until-Success Protocol

Complete example implementing the (I+i2X)/3(I + i\sqrt{2}X)/\sqrt{3} operation

Experimental Results

Expressiveness Verification

The paper validates through concrete examples that HUGR can express:

  1. Traditional Quantum Circuits: Static and parameterized circuits
  2. Hybrid Optimization Loops: Quantum-classical hybrid algorithms
  3. Real-Time Quantum-Classical Logic: Dynamic control based on intermediate measurements
  4. Structured Control Flow: Conditional branches and loops
  5. Unstructured Control Flow: Arbitrary control flow graphs

Optimization Performance

Pattern-matching-based optimization on graph structures offers the following advantages:

  • Efficient Matching: Port labels provide additional structure, more efficient than generic subgraph isomorphism checking
  • Parallelization Support: Pattern matching enables efficient rewrite rule composition
  • Scalability: Capable of simultaneously searching tens of thousands of patterns

Type Safety Guarantees

  • Compile-Time Checking: Static type system catches type errors at compile time
  • Linear Constraints: Prevents physically impossible operations like qubit duplication
  • Program Integrity: Continuously enforces constraints during optimization, preventing program invalidation

Comparison with Traditional Quantum Frameworks

FrameworkRepresentationDynamic SupportExtensibility
Cirq/QiskitGate list/graphLimitedLow
TKETCircuit graphControl flow unrollingMedium
OpenQASM 3Text languageSupportedLow

Comparison with QIR

  • QIR Advantages: Based on mature LLVM infrastructure
  • QIR Limitations:
    • Qubits as opaque pointers requiring global analysis
    • Lack of extensibility, difficulty adding high-level abstractions
    • Side-effect-based operation model complicates optimization

Relationship with MLIR

  • Similarities: Both adopt dialect systems supporting domain-specific abstractions
  • HUGR Advantages:
    • Quantum domain-specialized design
    • Linear types as first-class concepts
    • Rust implementation providing memory safety
    • Independence from rapidly evolving MLIR

Conclusions and Discussion

Main Conclusions

  1. HUGR successfully unifies quantum-classical program representation, supporting full spectrum expressiveness from traditional circuits to complex hybrid algorithms
  2. Hierarchical graph structure and strict type system provide solid foundation for compilation tool development
  3. Extensible design supports rapid development and integration of new abstractions in quantum computing
  4. Pattern-matching-based optimization framework provides new pathways for efficient program optimization

Limitations

  1. Learning Curve: HUGR's complexity compared to traditional circuit representations may increase developer learning costs
  2. Tool Ecosystem: As a new framework, establishing complete toolchain and community support requires time
  3. Performance Evaluation: Paper lacks quantitative performance comparisons with existing frameworks
  4. Practical Deployment: Has not yet demonstrated effectiveness on large-scale quantum programs

Future Directions

  1. Toolchain Refinement: Develop support for more frontend languages and backend targets
  2. Optimization Algorithms: Explore more quantum-computing-specific optimization techniques
  3. Formal Verification: Provide formal verification support for HUGR programs
  4. Hardware Integration: Deep integration with concrete quantum hardware platforms

In-Depth Evaluation

Strengths

  1. Strong Innovation: First unified quantum-classical graph representation, addressing important technical challenges
  2. Complete Design: Comprehensive design from type system to optimization framework, well-considered
  3. High Practical Value: Directly addresses actual quantum computing needs, likely to advance the field
  4. Open-Source Contribution: Complete open-source implementation lowers adoption barriers

Weaknesses

  1. Limited Experimental Validation: Primarily validates expressiveness through examples, lacking large-scale performance evaluation
  2. Missing Quantitative Comparisons: Lacks quantitative optimization effectiveness and compilation time comparisons with existing frameworks
  3. User Experience: User-friendliness evaluation insufficient for an intermediate representation
  4. Ecosystem Development: New framework's toolchain and community building require time

Impact

  1. Academic Value: Provides new theoretical foundation for quantum programming language and compiler research
  2. Industrial Application: Quantinuum's industrial background increases practical application potential
  3. Standardization Potential: May become standard representation for quantum-classical hybrid programs
  4. Field Advancement: May catalyze new quantum programming paradigms and optimization techniques

Applicable Scenarios

  1. Quantum Algorithm Research: Supporting representation and optimization of complex quantum algorithms
  2. Quantum Compiler Development: Providing unified intermediate representation for quantum compilers
  3. Hybrid Computing Applications: Particularly suitable for applications requiring tight quantum-classical interaction
  4. Quantum Software Engineering: Providing infrastructure for large-scale quantum software development

References

The paper cites 25 related references covering:

  • Quantum algorithms and protocols (repeat-until-success, quantum error correction, etc.)
  • Existing quantum programming frameworks (Cirq, Qiskit, TKET, PennyLane, etc.)
  • Compiler infrastructure (LLVM, MLIR)
  • Type system theory (linear types)
  • 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.