arXiv:2609.06743cs.PLSep 2026

Manuscript Offprint

arXiv:2609.06743

Staged Hybrid Quantum-Classical Programming

Chuta Sano, Peng Fu, Ryan Kavanagh, Jennifer Paykin, Brigitte Pientka

CHUTA SANO, McGill University, Canada

PENG FU, University of South Carolina, USA

RYAN KAVANAGH, Université du Québec à Montréal, Canada

JENNIFER PAYKIN, University of Vermont, USA

BRIGITTE PIENTKA, McGill University, Canada

We capture hybrid quantum-classical computing. These systems consist of a classical control system that sends quantum circuits and receives measurement results from a quantum co-processor. Such systems allow us to model algorithms that require the classical control system to generate quantum circuits on the fly, potentially based on prior measurement results. This is challenging, as the classical control system must generate quantum circuits that manipulate live quantum states, e.g., for quantum error correction. In this setting, the classical control system is generating further quantum circuits while the quantum co-processor is internally maintaining the state of the live qubits; this is not ideal, since this is not only costly, in the sense of energy consumption, but also introduces additional sources of noise to the live qubits. Thus, we want to minimize the latency between receiving measurement results and sending the next quantum circuit to be executed by pre-computing quantum circuits.

We introduce HyQ (pronounced haiku), a multi-modal language based on adjoint logic that pre-generates quantum circuits before executing a hybrid quantum-classical program. We achieve this by separating our semantics into two distinct stages: 1) compile-time generation of quantum circuits and classical runtime code and 2) execution of the classical runtime code that instruments the quantum co-processor. This separation between stages allows us to formally guarantee that all circuit-generation logic occurs before the instrumentation logic, i.e., the actual runtime, and minimizes the idling of the quantum co-processor at runtime. We give a type system, a circuit-normalization semantics for the compile-time stage, which eagerly performs all circuit-generation logic, and a runtime semantics for HyQ that corresponds to the second stage. We prove type preservation and progress for both semantics. We further mechanize a superset of HyQ in the Beluga proof assistant.

1 Introduction

A promising style of quantum languages, such as Quipper [Green et al. 2013b] and QWIRE [Paykin et al. 2017], devise a functional language that generates and runs quantum circuits. This integration of a functional language, intended to run on a classical processor, with quantum circuits, intended to run on a quantum co-processor, falls in line with the well-studied QRAM model [Knill 1996]. In this model, a classical control system is responsible for performing “ordinary” computations and delegates quantum computations to a quantum co-processor by sending it quantum-specific instructions in the form of quantum circuits. The quantum co-processor then returns probabilistic measurement results to the classical system, which in turn may determine new circuits to pass to the quantum co-processor for execution, and so on. In its simplest form, each call to the quantum device starts from a blank slate, and newly generated circuits never depend on any existing quantum states from prior iterations.

Figure 1 depicts a simplified view of this model, where the classical control system cannot depend on any live quantum states from the quantum co-processor when generating subsequent circuits. In contrast, a challenge arises when an algorithm requires real-time hybrid quantum programs [Lubinski et al. 2022], also referred to as adaptive measurement [Raussendorf and Briegel

Authors' Contact Information: Chuta Sano, School of Computer Science, McGill University, Canada, chuta.sano@mail.mcgill.ca; Peng Fu, Computer Science and Engineering Department, University of South Carolina, USA, pfu@cse.sc.edu; Ryan Kavanagh, Département d'informatique, Université du Québec à Montréal, Montréal, QC, Canada, kavanagh.ryan@uqam.ca; Jennifer Paykin, Department of Computer Science, University of Vermont, USA, jennifer.paykin@uvm.edu; Brigitte Pientka, School of Computer Science, McGill University, Canada, bpientka@cs.mcgill.ca.

Figure

Fig. 1. The basic QRAM model of quantum computation. The classical control system generates quantum circuits and passes them to the quantum co-processor for execution. The quantum co-processor returns measurement results to the classical control system, which may in turn generate new circuits to pass to the quantum co-processor.

2001] or dynamic lifting [Fu et al. 2023; Green et al. 2013b]. These terms refer to when the choices of quantum operations depend on measurement results, all within the limited coherence lifetime of the quantum computer. An important example is quantum error correction and lattice surgery, where repeated measurements are used to detect and correct errors as they occur. Other examples include distributed quantum algorithms such as quantum teleportation; repeat-until-success circuits; and measurement-based quantum computing—all of which involve dynamic corrections to the state of a live quantum system.

The term dynamic lifting in particular is used in the context of quantum circuit generation and compilation, where a compiler must balance the expressivity of dynamic control with the cost of compiling and optimizing the resulting hybrid program. Past formulations of dynamic lifting [Fu et al. 2023] generate quantum circuits on-the-fly based on prior measurement results. However, this runtime circuit generation introduces a non-trivial runtime cost, and importantly, is a cost that is incurred on the quantum co-processor.

As an example, consider the following pseudocode that generates a quantum circuit based on the measurement result of some qubit q1q_1:

let q1, q2 = some_initialization_logic
if (measure q1) then % generate next circuit for the quantum co-processor
else % generate a different circuit for the quantum co-processor

In either branch of the conditional, the classical control system must generate a quantum circuit to pass to the quantum co-processor, and during this classical computation, the quantum co-processor must maintain the state of q2q_2 (and any other live qubits).

However, compiling quantum programs to executable quantum circuits is expensive. Compilation pipelines include aggressive optimization passes, transpilation to a target gateset, and placement and routing passes to ensure the circuit operations respect architecture connectivity constraints. As a result, compilation is orders of magnitude slower than the lifetime of qubits on state-of-the-art quantum computers. These algorithms are therefore challenging to implement and reliably execute, because qubits are noisy and can decohere over the time it takes for the classical processor to generate the next quantum circuit to execute.

Thus, we have a trade-off: on one hand, we can have smaller binaries that contain runtime circuit generation logic but incur a runtime cost that is indirectly paid by the quantum co-processor, and on the other hand, we can have larger binaries that pre-compute circuits at compile time but minimizes time that the quantum co-processor is “idling”. This is a trade-off that, we argue, is often worth making due to the fact that quantum co-processors are far more expensive and limited than classical resources such as memory. Thus, we are interested in a language that ensures that all quantum circuits are pre-generated at compile-time to minimize the idling of the quantum co-processor at runtime.

This idea of pre-generating quantum circuits heavily draws on quantum kernels in programming languages such as QCor [Mintz et al. 2020] and the Intel Quantum SDK [Khalate et al. 2022]. These systems compile high-level hybrid quantum-classical programs into separate quantum kernels representing the circuits to run on the quantum machine, which are selected between by classical logic to be run on the classical machine. As far as we are aware, no prior work has given a formal presentation of such programming paradigms, such as a formal semantics, proof of correctness, or type system. The Intel Quantum SDK, for instance, relies on users to syntactically separate quantum kernels but lacks complete compile-time checking; this results in subtle issues where the compiler incorrectly orders classical logic before its intended quantum logic [Intel Corporation 2025].

In this paper, we introduce HyQ, a multi-modal language based on adjoint logic [Jang et al. 2024; Pruiksa et al. 2018] where we separate our execution into two stages: (1) circuit-generation time, where quantum circuits are generated and normalized; and (2) runtime, where a minimalistic classical control program instruments the quantum computation. Broadly speaking, HyQ consists of a functional metaprogramming language, a quantum circuit description language, and a classical runtime language. The metaprogramming language allows programmers to programmatically generate quantum circuits and classical runtime code, which embeds these generated quantum circuits. The quantum circuit language is a first-order linear λ\lambda-calculus with uninterpreted gate constants where functionals correspond to quantum circuits and gates. The classical runtime language is a minimalistic functional language that (1) embeds quantum circuits; (2) request measurements on qubits; and (3) can branch based on measurement results.

From the design perspective, the major departing feature of HyQ from prior works is the language-level separation of “classical computation for circuit generation (stage 1),” which is run on a classical computer without restrictions, and “classical computation for runtime (stage 2),” which are run on a low-power classical control system. This two-staged separation enables us to cleanly distinguish between classical logic that generates quantum circuits and classical logic that instruments the quantum co-processor’s classical control, which notably enables us to enforce that all quantum circuit generation logic occurs entirely before the instrumentation logic, i.e., the runtime involving the quantum co-processor. This is formally captured through HyQ having two distinct operational semantics: a circuit-normalization semantics that performs all circuit generation logic, ensuring that all quantum circuits are pre-generated, and a runtime semantics that executes the classical control program that instruments the quantum co-processor.

Another advantage of our modular design is that we can easily extend each language with additional features without affecting the other languages. In particular, extensions to the (classical) metaprogramming language will not affect the available features of the (classical) runtime language, which is intended to be minimalistic to model realistic systems.

In short, we make the following contributions:

  • We introduce HyQ, a foundational calculus that captures the emerging paradigm of pre-generating quantum circuits before executing a hybrid quantum-classical program.

  • We formalize HyQ by providing its statics and two semantics corresponding to the two stages we explain previously. The first stage is formalized by a circuit-normalization semantics, and the second stage is formalized by a runtime semantics. We prove type preservation and progress for both semantics, and we also prove a normal-forms theorem for the circuit-normalization semantics, proving that our language indeed pre-generates all quantum circuits during circuit-generation time.

  • We mechanize a superset of HyQ, alongside its typing and two semantics, in the Beluga proof assistant. We use an intrinsically-typed encoding, thereby obtaining (partial) type preservation for free, and we fully mechanize the progress proofs of both semantics.

References (24)