arXiv:2609.01037cs.PLSep 2026

Manuscript Offprint

arXiv:2609.01037

A Dynamic Intermediate Representation for Hybrid Quantum-Classical Programs

Alex Rice, Chris Heunen, Tobias Grosser

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

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

Quantum circuits are the dominant representation of quantum computations [13]. However, the circuit model is inherently static and too restrictive for many important applications, which are more naturally expressed as hybrid quantum-classical programs combining quantum operations with classical data and control flow [8, 35, 38, 40]. Established quantum toolkits have begun extending support for classical computation within quantum compilers, such as IBM's OpenQASM 3.0 [10] and Quantinuum's t|ket⟩ [43], emphasising the importance of representing subcircuits that depend on external classical or probabilistic computations.

Consider noisy quantum channels, which are essential for modelling real hardware [36]. The phase-flip channel, a common form of noise, probabilistically applies a Z gate to a qubit. As the choice of gate depends on a classical random variable, the circuit model can only represent this behaviour by generating a fresh circuit for each random sample.

A more general representation of quantum computation should support optimisation across the quantum-classical boundary, be expressive enough to encode diverse hybrid techniques, and remain simple enough for efficient compilation and transformation. Unlike classical hardware—like

Figure

(a) With control flow

Figure

(b) With arith.select

Figure

(c) With XZ gadgets

Figure 1. Graphical representations of two sequential phase flip channels using control flow in (a), and dynamic gates in (b) and (c), with the gate value being generated by arith.select and our XZ gadget respectively. The dataflow is vastly simplified in (b) and (c), where the quantum component retains its circuit structure. The XZ gadgets in (c) remove the need for the selection operation, allowing the dynamic gates to be fused.

in an ASIC or FPGA, where circuit structure is fixed at runtime [29, 44]—quantum programs are executed dynamically, allowing circuit layout to change during execution. Thus there is no fundamental reason to adhere to a static circuit model, and instead we can adopt a dynamic representation better suited for optimising hybrid programs.

In this work, we introduce dynamic gates, a representation for hybrid quantum-classical computation that treats gates as runtime values. Rather than defining a separate operation for each quantum gate, a gate value can be created, manipulated by classical code, and applied dynamically during execution.

Listing 1 illustrates this concept using two consecutive phase-flip noise channels. The key construct, qssa dyn_gate, takes as input a dynamically chosen gate value %, determined by a classical selection that yields a Z gate if the random variable %p is true and the identity otherwise. In contrast

Listing 1 Our dynamic gates can represent two concatenated probabilistic phase flip channels without requiring control flow. Quantum-classical transformations can then reduce this to a single phase flip with updated probability, using the self-invertibility of the quantum Z gate.

%id = gate.constant #gate.id %z = gate.constant #gate.z %p_1 = prob.bernoulli 0.1 %g_1 = arith.select %p_1, %z, %id : !gate.type<1> %q_1 = qssa dyn_gate<%g_1> %q %p_2 = prob.bernoulli 0.1 %g_2 = arith.select %p_2, %z, %id : !gate.type<1> %q_2 = qssa dyn_gate<%g_2> %q_1

to traditional circuits, the gate applied by qssa dyn_gate is only determined at runtime.

Dynamic gates make the boundary between quantum and classical computation porous, enabling optimisations that cross this boundary while preserving the familiar circuit structure. They can be viewed as a natural generalisation of the circuit model, and can replace instances of more explicit control flow necessary in other IRs [10, 37].

Our contributions are:

  • A dynamic gate model for tightly coupled hybrid quantum-classical programs, instantiated as a compiler Intermediate Representation (IR) that enables optimisations across the quantum-classical interface (Section 2, Section 4).
  • The XZ gadget, a dynamic gate representing conditional combination of X and Z Pauli gates allowing an elegant way to realise optimisations (Section 4.1).
  • A curated benchmarking suite of hybrid programs that is representative of current demands on quantum-classical interaction.

We show that this IR advances the state of the art in representing and optimising hybrid quantum-classical programs in two ways (Section 5):

  • Depth: Through case studies in randomised compilation (Section 5.1), quantum error correction (Section 5.2), and measurement-based quantum computing (Section 5.3), we demonstrate how complex hybrid transformations become simple local rewrites.
  • Breadth: Through evaluation on our new benchmark suite, covering nontrivial quantum-classical interactions and scalable program sizes, we demonstrate that our IR compactly expresses hybrid programs and enables comparative analysis across representations (Section 5.4).

References (34)