Table of Contents
Fetching ...

Qrisp: A Framework for Compilable High-Level Programming of Gate-Based Quantum Computers

Raphael Seidel, Sebastian Bock, René Zander, Matic Petrič, Niklas Steinmann, Nikolay Tcholtchev, Manfred Hauswirth

TL;DR

Qrisp tackles the lack of high-level quantum programming abstractions by introducing a Python-based eDSL centered on QuantumVariables and automated uncomputation, enabling compilation to circuit-level backends. It offers a suite of abstractions—QuantumSession, QuantumArray, QuantumDictionary, and QuantumEnvironments—that let developers encode algorithms at a high level while the compiler exploits structure for resource savings, including MCX-based optimizations. The framework demonstrates practical gains with examples like Shor’s algorithm, showing reduced qubit counts and gate-depth through context-informed compilation and automated qubit management. This work suggests a scalable path for pragmatic quantum software engineering, bridging programming paradigms and hardware constraints, and provides open-source tooling to accelerate adoption and experimentation.

Abstract

While significant progress has been made on the hardware side of quantum computing, support for high-level quantum programming abstractions remains underdeveloped compared to classical programming languages. In this article, we introduce Qrisp, a framework designed to bridge several gaps between high-level programming paradigms in state-of-the-art software engineering and the physical reality of today's quantum hardware. The framework aims to provide a systematic approach to quantum algorithm development such that they can be effortlessly implemented, maintained and improved. We propose a number of programming abstractions that are inspired by classical paradigms, yet consistently focus on the particular needs of a quantum developer. Unlike many other high-level language approaches, Qrisp's standout feature is its ability to compile programs to the circuit level, making them executable on most existing physical backends. The introduced abstractions enable the Qrisp compiler to leverage algorithm structure for increased compilation efficiency. Finally, we present a set of code examples, including an implementation of Shor's factoring algorithm. For the latter, the resulting circuit shows significantly reduced quantum resource requirements, strongly supporting the claim that systematic quantum algorithm development can give quantitative benefits.

Qrisp: A Framework for Compilable High-Level Programming of Gate-Based Quantum Computers

TL;DR

Qrisp tackles the lack of high-level quantum programming abstractions by introducing a Python-based eDSL centered on QuantumVariables and automated uncomputation, enabling compilation to circuit-level backends. It offers a suite of abstractions—QuantumSession, QuantumArray, QuantumDictionary, and QuantumEnvironments—that let developers encode algorithms at a high level while the compiler exploits structure for resource savings, including MCX-based optimizations. The framework demonstrates practical gains with examples like Shor’s algorithm, showing reduced qubit counts and gate-depth through context-informed compilation and automated qubit management. This work suggests a scalable path for pragmatic quantum software engineering, bridging programming paradigms and hardware constraints, and provides open-source tooling to accelerate adoption and experimentation.

Abstract

While significant progress has been made on the hardware side of quantum computing, support for high-level quantum programming abstractions remains underdeveloped compared to classical programming languages. In this article, we introduce Qrisp, a framework designed to bridge several gaps between high-level programming paradigms in state-of-the-art software engineering and the physical reality of today's quantum hardware. The framework aims to provide a systematic approach to quantum algorithm development such that they can be effortlessly implemented, maintained and improved. We propose a number of programming abstractions that are inspired by classical paradigms, yet consistently focus on the particular needs of a quantum developer. Unlike many other high-level language approaches, Qrisp's standout feature is its ability to compile programs to the circuit level, making them executable on most existing physical backends. The introduced abstractions enable the Qrisp compiler to leverage algorithm structure for increased compilation efficiency. Finally, we present a set of code examples, including an implementation of Shor's factoring algorithm. For the latter, the resulting circuit shows significantly reduced quantum resource requirements, strongly supporting the claim that systematic quantum algorithm development can give quantitative benefits.
Paper Structure (26 sections, 19 equations, 4 figures)

This paper contains 26 sections, 19 equations, 4 figures.

Figures (4)

  • Figure 1: The circuit generated by calling sqrt_oracle on qf. Note that the qubits named sbp_anc are ancillae utilized by the multiplication algorithm. These ancillae are successively computed and uncomputed, such that after compilation (invoked via qf.qs.compile()) they are allocated and deallocated on the same physical qubit, which will (temporarily) also hold the value of eq_qbl. The quantum circuit resulting from the compile method therefore contains 12 qubits.
  • Figure 2: \ref{['grover_circ']} The circuit for Grover's algorithm, which is generated after executing the source code snippet in Section \ref{['grovers_alg']}. To improve readability, we hide the circuit displayed in Fig. \ref{['sqrt_oracle_circ']} behind the box sqrt_oracle. \ref{['mes_plot']} A plot of the simulated measurement results of the QuantumFloat qf.
  • Figure 3: \ref{['fig:custom_controlled_circuit']} An example call tree as implemented in a circuit construction framework. Displayed is the situation that the developer implements a function $f_0$ that calls a circuit construction procedure hidden below several subroutines $f_1 .. f_n$. To implement a controlled version of $f_0$ using the custom controlled circuit compilation procedure, the developer essentially needs to rewrite every function within the stack in order to accommodate for the appropriate treatment of the control qubit. Users need to be aware that a custom controlled version $cf_0$ is available. \ref{['fig:custom_controlled_function']} The same situation but using the custom_control decorator. The tracking of the control qubit is automated, implying only the lowest level needs to be adjusted. Within this approach the custom controlled version of $f_0$ is automatically used (if called within a ControlEnvironment), implying users can be oblivious of the custom control procedure.
  • Figure 4: Several KPIs of the Shor implementation as described within section \ref{['sec:shor']}. The utitlized adder is the one described in gidney2018. For the quantum fourier transformation we used the technique as described in park2023 to reduce the amount of arbitrary angle RZ gates. Note that the competing implementations made heavy use of Fourier basis addition, which trades resources such as gate count and circuit depth for arbitrary angle RZ gates. In the Clifford+T gate set, these rotations have to be synthesized using algorithms such as selinger_2014. This renders the resource estimation of such algorithms rather difficult since it is unclear to which precision the RZ angle gates need to approximated. In this plot, we take the extremely conservative assumption, that any arbitrary angle gate has T-count/depth 1. A more realistic estimate would give the Qrisp implementation an edge of approximately 3 orders of magnitude.