Decompiling Quantum Assembly into Structured Programs
Pingchuan Ma, Zhantong Xue, Zongjie Li, Qixin Zhang, Yuxuan Du, Zhaoyu Wang, Yuguang Zhou, Shuai Wang, Xiaoqin Zhang
Abstract
Quantum compilers translate programs into native gates, insert SWAP gates to route interactions onto a device, and optimize the result. The output is quantum assembly, a flat gate list that hides the algorithm's structure (QFT, Grover iteration, QAOA layers). Understanding, auditing, porting, or reusing such assembly requires recovering a program that exposes this structure. We present Quelle, a decompiler that recovers structured programs (library calls, loops, functions, symbolic angles) from routed and optimized quantum assembly (OpenQASM) and checks every output for equivalence with its input. Quelle is built on one invariant: every step is either an exact rewrite, checked where it is applied, or a hypothesis, checked against the input before use. It first lifts the assembly into a circuit by removing compilation artifacts, notably un-routing, which recovers the SWAPs that routing inserted, including those merged into other gates. It then recovers algorithm templates (sketches) whose parameters are solved from quantities preserved by compilation, and, for algorithms without a template, library calls and loops by anti-unification. Failed hypotheses are rejected; the corresponding operations remain in gate-level form. On 816 assembly programs from 22 algorithm families and a random-circuit control, compiled at four routing and optimization levels with native two-qubit gates CX, ECR, or CZ, Quelle's output is equivalent to the input for 100% of the inputs, and it fully decompiles 94% of them; compared on the same inputs, it fully decompiles 1.7x as many as the best LLM-based decompiler, which spends 15K tokens per input. On nine algorithm families for which it has no template, the structure it recovers without templates explains 60% of the gates. It checks inputs of up to 2.3 million gates and emits no inequivalent output on 237 real-world QASMBench assembly files.
Create a lesson
Related papers
Irene: Equivalence Checking of Hybrid Quantum Programs via Structure-Preserving Symbolic Reduction
Shared title terminology · Jingyu Ke, Jingyang Li, Guoqiang Li
When Is Program Structure Required? Certificate-Grounded Calibration of Program-Induction Difficulty
Shared title terminology · Wenzhang Du
Simulating Quantum Computation Using Probabilistic Programming
Shared title terminology · Yafei Yang, Chung-chieh Shan
A Complete Calculus for Hamiltonian Quantum Programming
Shared title terminology · Jacques Carette, Chris Heunen, Robin Kaarsgaard et al.
Stochastic Summaries: Characterizing Structured Datasets Using Probabilistic Programs
Shared title terminology · Jack Stanek, Adithya Murali
ASAP: Assembly-Source Aligned Pseudocode Refinement For Binary Decompilation
Shared title terminology · Yujian Zhuang, Dehong Gao, Qichao Zhang et al.