arXiv:2611.02345cs.PLNov 2026

Manuscript Offprint

arXiv:2611.02345

MBUndo: Sound, Automatic, and Efficient Measurement-Based Uncomputation for Quantum Circuits

Shengyuan Yang, Charles Yuan

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

SHENGYUAN YANG and CHARLES YUAN, University of Wisconsin–Madison, USA

Quantum programs that use temporary values, known as ancilla qubits, must explicitly uncompute each ancilla back to zero to ensure that the program produces a correct output. Conventional uncomputation uses unitary quantum gates, whereas leading quantum algorithms now leverage measurement-based uncomputation (MBU), which replaces costly unitary TT gates with cheaper measurements and phase corrections on hardware.

Current quantum programming frameworks can use measurement to uncompute specific gates such as Toffoli. No automatic transformation, however, accepts an arbitrary circuit whose ancillas are computed and uncomputed via the standard approach and converts the circuit to use MBU. Researchers instead apply MBU to individual circuit designs by hand, which limits algorithm development and compiler optimization.

Such a transformation has not existed due to two fundamental unknowns: where MBU applies and which gates realize MBU for an arbitrary computation. This work answers both questions. First, we present a static analysis that identifies, for each ancilla qubit, each circuit position where measurement is sound – subsuming basic assumptions that MBU only applies at the end of a circuit. Next, we present circuit transformations that soundly turn unitary uncomputation gates into efficient phase corrections after measurement – generalizing rewrite rules from prior literature that are either limited to a single gate or not applicable to a general circuit.

We present MBUndo, an integrated compiler pass that automatically converts circuits to measurement-based uncomputation. It requires no user annotations other than which qubits are ancillas, the same as needed by existing uncomputation synthesizers, and can enhance their output circuits. We evaluate MBUndo on 22 benchmarks to reveal TT gate reductions of >36.5% over uncomputation synthesizers.

1 Introduction

Like classical programs, quantum programs that implement quantum algorithms generate temporary values as part of execution. These values are stored in ancilla qubits alongside the data qubits that store the ultimate output of the computation. Classically, any temporary value can simply be discarded and destroyed once used. But in a quantum program, ancilla qubits are entangled with the data qubits they are computed from, meaning that destroying a temporary value can also corrupt the program state and jeopardize correctness of the program [Nielsen and Chuang 2010, §4].

The remedy for this problem is uncomputation [Bennett 1973], the process of undoing the computation of a temporary value to explicitly return it to zero and thereby eliminate all entanglement with the data qubits. Writing uncomputation by hand is common yet tedious and error-prone for programmers. Thus, researchers have developed techniques to automatically uncompute variables in programming languages [Bichsel et al. 2020; Hirata and Heunen 2025; Venev et al. 2024] or qubits in the quantum circuits to which languages compile [Liu et al. 2026; Paradis et al. 2021b, 2024].

References (68)