Source-linked AI summary

A Dynamic Intermediate Representation for Hybrid Quantum-Classical Programs

Alex Rice, Chris Heunen, Tobias Grosser

arXiv:2609.01037v1cs.PLquant-ph

TL;DR

Hybrid quantum-classical programs expose limitations in static circuit representations because runtime classical data can determine quantum gates. The paper introduces an IR in which gates are runtime values, then shows that it compactly expresses hybrid programs and enables compiler optimisations across the quantum-classical boundary. Its case studies and benchmark suite demonstrate local simplifications, compact representation, and comparative analysis across representations.

  • Problem

    Static circuit models are too restrictive for hybrid programs whose quantum operations depend on classical data, probabilistic computation, or runtime choices.

  • Method

    The paper introduces dynamic gates, an IR that treats gates as runtime values manipulable by classical computation and applied dynamically during execution.

  • Results

    Case studies and benchmark evaluation show that the IR compactly expresses hybrid programs and enables optimisations and comparative analysis across representations.

  • Takeaways & Limitations

    Dynamic gates provide a unified representation for hybrid quantum-classical techniques while preserving circuit structure and enabling optimisations across their interface.

  • Takeaways & Limitations

    The evaluation considers higher-level quantum-program representations and leaves the effect of longer-lived random variables in the compilation pipeline out of scope.

Abstract

from arXiv · show

Quantum compilers typically follow the circuit model, representing programs as fixed sequences of gates. This static view breaks down in hybrid quantum-classical applications, where gate choices depend on runtime data or measurement results. We introduce a new Intermediate Representation (IR) that elevates gates to first-class values, enabling their dynamic creation, composition, and control. This unified representation allows classical computation to steer quantum behaviour, capturing phenomena including stochastic gate selection, adaptive error correction, and measurement-driven computation within a single framework. Case studies in noise modelling, randomised compilation, error correction, and measurement-based quantum computing show that our IR expresses these programs compactly and supports optimisations that were not possible in the circuit model. Evaluation on a benchmark suite of hybrid quantum-classical programs indicates that our IR represents programs compactly and facilitates compiler analysis and transformation.

1 Introduction

The paper introduces dynamic gates as runtime-valued gates for hybrid quantum-classical programs, addressing limitations of static circuit representations. The IR preserves circuit-like quantum structure while enabling cross-boundary optimisations such as phase-flip fusion.

  • Motivation: Static circuit representations struggle with hybrid programs whose quantum operations depend on classical data, probabilistic computation, or runtime choices.This includes probabilistic phase-flip channels, which require generating a fresh circuit for each random sample in the circuit model.
  • Representation: Dynamic gates retain the quantum component’s circuit structure while simplifying its interaction with classical dataflow.The representation avoids adding complexity to quantum dataflow when classical choices determine applied gates.
  • Dynamic gates: Dynamic gates treat gates as runtime values that classical code can create, manipulate, and apply during execution.The dynamic gate operation receives its gate through an operand, allowing arbitrary classical computation to determine the quantum operation.
  • Example: Two sequential probabilistic phase-flip channels can be represented without control flow and reduced to one phase flip with an updated probability.The reduction uses the self-invertibility of the quantum Z gate.
  • Contributions: The dynamic gate model enables optimisations across the quantum-classical interface, including local rewrites and comparative analysis across representations.The paper presents an XZ gadget and a benchmark suite covering nontrivial interactions and scalable program sizes.

2 Dynamic Gates

Dynamic gates bridge classical control and quantum dataflow by supplying gates as operands rather than static circuit elements. XZ gadgets further simplify conditional Pauli operations, enabling consecutive phase-flip channels to fuse into one channel.

  • Design challenge: A naive combination of classical and quantum IRs represents hybrid interaction poorly, even though that interaction is central to modern quantum applications.The resulting representation can obscure the relationship between classical choices and quantum operations.
  • Phase-flip example: Sequential phase-flip channels are equivalent to one phase-flip channel with an updated probability because pairs of Z gates cancel.The compiler transformation combines quantum self-invertibility with classical probability calculations.
  • Design challenge: Classical-control-flow representations complicate optimisation and quantum dataflow analysis because the same qubit may appear across multiple execution branches.Checking linear qubit use can require global control-flow analysis, and the property is undecidable in general.
  • Dynamic gate model: Dynamic gates supply the operation through a gate-valued operand, allowing arbitrary classical computation to determine which gate runs.This creates an interface through which classical data affects quantum computation while retaining explicit quantum dataflow.
  • XZ gadgets: XZ gadgets represent conditional combinations of Pauli X and Z gates and can replace selection operations through operand-wise transformations.Arithmetic simplification yields a canonical XZ representation for the double phase flip.
  • XZ gadgets: Fusing XZ gadgets by exclusive disjunction of their parameters reduces the double phase flip to a single phase-flip channel.The same reduction sequence can also simplify compositions involving bit-flip and depolarising channels.

3 Background

Quantum computing uses circuits to compose gates and measurements, while hybrid programs require runtime classical control over quantum operations. Compiler IRs and SSA value semantics make dataflow and optimization more explicit, but translating hybrid behavior beyond static circuits remains challenging.

  • Quantum circuits: Quantum circuits compose gates in parallel and sequence, forming a hardware-agnostic low-level representation of quantum computations.Parallel composition uses tensor products, while sequential composition uses matrix multiplication.
  • Quantum measurement: Measurements probabilistically convert qubits into classical bits, with outcome probabilities determined by amplitudes in the measurement basis.For state αv_1 + βv_2, outcomes 0 and 1 occur with probabilities |α|^2 and |β|^2, respectively.
  • Quantum gadgets: Quantum gadgets represent recurring subcircuits or patterns that compilers can simplify more easily than equivalent primitive-gate sequences.Phase gadgets are identified, fused, and then lowered back to primitive gates.
  • Hybrid programs: Hybrid quantum programs combine classical and quantum computation, selecting runtime operations possibly from measurement results, which complicates circuit-based optimization.Optimizations from static circuits do not translate trivially to these programs.
  • Compiler IRs and SSA: SSA assigns each identifier once, making value origins and uses explicit; quantum value semantics therefore expose qubit dataflow for optimization.Under value semantics, a gate consumes input qubits and produces fresh outputs, unlike reference semantics that mutates inputs.
  • MLIR: The paper’s IR is implemented as MLIR dialects on xDSL, whose operations use SSA values, types, attributes, and dialect-specific extensions.MLIR dialects provide reusable data structures and optimization machinery.

4 A Hybrid Quantum-Classical IR

The IR represents static and dynamic quantum operations in SSA form, treating runtime-selected gates as typed values that classical code can create and manipulate. XZ/XZS gadgets and compiler passes then simplify, fuse, propagate, and lower conditional Pauli and phase operations while controlling rewrite growth.

  • IR design: The IR uses SSA quantum operations with value-semantic qubits and MLIR dialects, providing explicit dataflow for hybrid-program transformations.Its dialects define the types, attributes, and operations used by the paper and benchmarks.
  • Static and dynamic gates: A single qssa.gate operation executes static gates specified by attributes rather than introducing a separate operation for each gate.Gate attributes encode qubit arity, enabling operand and output verification.
  • Static and dynamic gates: Gate attributes are extensible and reusable, allowing custom gates to cooperate with qssa.gate transformations and supporting parallel qssa and reference-semantic qref dialects.The same gate-attribute infrastructure supports the dynamic-gate system.
  • Static and dynamic gates: Dynamic gates take typed runtime gate values as operands, which can be constants, classically selected gates, or gates generated from runtime parameters.gate.constant creates values from attributes, while operations such as gate.dyn_rx use runtime angles.
  • Optimisation pipelines: The xzs-simplify pipeline fuses adjacent XZS gadgets, while xz-propagation moves Pauli gates toward program end and fuses them.Both pipelines convert gates to gadgets, transform them, and lower them to selections between constant gates.
  • Gadgets: XZS and XZ gadgets encode conditional compositions of X, Z, and phase gates using Boolean SSA inputs, with XZ omitting the phase component.The XZS gadget represents X^xZ^zS^s, and XZ can represent all Pauli gates up to global phase.
  • Gadget transformations: Selection between XZ(S) gadgets becomes one gadget whose parameters are selected independently, enabling conditional-gate simplification.The resulting parameters are formed with classical arith.select operations.
  • Gadget transformations: Pauli propagation uses gate-specific Clifford commutation rules, including custom user-specified gates, and can support other applications such as stabilizer simulation.The pass commutes XZ gadgets through quantum gates toward the program end.

5 Evaluation

The evaluation applies the dynamic-gate IR to randomised compilation, quantum error correction, and measurement-based quantum computing, then benchmarks its compactness against QIR. Across these evaluations, the IR supports optimisation before instantiation, local rewrites, and reduced representation complexity.

  • Randomised Compilation: Dynamic gates encode random padding gates before random-variable instantiation, allowing them to be fused with XZS gadgets during compilation.The randomised-comp pass inserts conditional padding and correction gates, which the xzs-simplify pipeline then converts, fuses, and lowers.
  • Randomised Compilation: The dynamic-gate pipeline performs fusion once before cloning, whereas the naive pipeline clones and optimises each instantiated circuit separately.The dynamic pipeline runs xzs-simplify before cloning and applies fusion once rather than once per iteration.
  • Randomised Compilation: Up to 20% faster generation was observed for greater instantiation counts on randomised circuits from a 10-qubit GHZ-state circuit.The naive pipeline remains faster for small iteration counts, but the dynamic pipeline overtakes it as the number of instantiations grows.
  • Quantum Error Correction: The xz-propagation pass reduces quantum operations in the 5-qubit QEC representation while causing a small increase in classical operations.The accompanying table separates quantum operations from other operations before and after the pass.
  • Measurement-Based Quantum Computing: The IR converts circuit-based programs to measurement-based quantum computing programs through local rewrites and avoids extra signal-shifting operations.Explicit classical dataflow tracks measurement-result negations without requiring the signal-shifting operations used in previous standardisation procedures.
  • Benchmarking Suite: Across the benchmark suite, dynamic gates used 47% fewer lines and 52% fewer words than QIR, while the IR outperformed QIR in every analysis.The reported geometric means also include 24% fewer quantum operations and additional reductions in control-flow complexity.

6 Related and Future Work

The paper situates dynamic gates among quantum IRs and optimisation gadgets, while identifying extensions needed for broader hybrid-program support.

  • Related quantum intermediate representations: The discussion compares the dynamic-gate IR with OpenQASM, QIR, MLIR dialects, QIRO, Ensemble IR, and t|ket⟩2.These representations differ in their treatment of classical computation, qubit semantics, extensibility, and probabilistic or hybrid workloads.
  • Related quantum intermediate representations: Dynamic gates generalise circuit representations by allowing hybrid-level optimisations, while Ensemble IR is more specialised to probabilistic scenarios.The paper presents dynamic gates as a general hybrid framework rather than a representation limited to ensembles of related circuits.
  • Quantum gadgets for optimisation: Existing gadgets including phase polynomials, ZX spiders, phase gadgets, and Pauli gadgets suggest candidates for extending optimisation beyond the current dynamic-gate gadgets.The paper specifically identifies ZX spiders as nontrivial to integrate because they do not distinguish inputs from outputs.
  • Future work: Current optimisations focus largely on Clifford-related operations, although the paper demonstrates applications to Clifford+T randomised compilation and universal MBQC programs.Future work includes targeting hybrid non-Clifford operations and adapting phase-polynomial techniques.
  • Future work: The current work does not discuss subprocedures or subcircuits, motivating future support for operations that produce gate values from circuits and apply them dynamically.A complete solution would also interact with reference/value semantics, Pauli propagation, and unitary inversion.
  • Future work: Future extensions include quantum data types beyond qubits and more developed noise-aware compilation using native dynamic-gate representations of noise channels.The paper notes that noise-channel use within a noise-aware compilation pipeline remains relatively unexplored.

A Dynamic Gate IR Specification

The Dynamic Gate IR defines extensible types, attributes, and operations for representing gates and measurements as values alongside conventional quantum operations.

  • Design: The IR combines dynamic-gate constructs with common MLIR dialects and allows users to define new gate attributes or gate-creating operations.Its open design supports extensibility while retaining the listed core operations.
  • Types and attributes: The type system includes qubits, n-qubit gates, n-qubit measurements, and angles.These types distinguish quantum values from dynamically constructed gate and measurement values.
  • Types and attributes: Gate attributes include standard and parameterised gates such as X, Z, H, rotations, controlled gates, Toffoli, and RZZ.Measurement attributes cover computational, X-basis, and parameterised XY-basis measurements; allocation attributes include zero and plus states.
  • SSA operations: The SSA operations allocate qubits, apply constant or dynamic gates, and measure qubits into integer bit results.Dynamic operations consume gate or measurement types together with qubit values and preserve the required qubit arity.
  • Reference operations: The reference-semantics operations provide corresponding constant and dynamic gate application and measurement operations.They return unit results for gate application while retaining measurement results as integer bit values.
  • Constructors: Gate constructors create constant, XZ, XZS, and angle-dependent gate values, while measurement constructors create constant or angle-dependent measurement values.The specification includes one- and two-qubit dynamic gates and parameterised measurement construction.
Loading 2609.01037v1…