QParallel: Explicit Parallelism for Programming
Quantum Computers
Thomas H¨
aner∗, Vadym Kliuchnikov†, Martin Roetteler†, Mathias Soeken∗and Alexander Vaschillo†
∗Microsoft Quantum, Switzerland
†Microsoft Quantum, USA
Abstract—We present a language extension for parallel quan-
tum programming to (1) remove ambiguities concerning paral-
lelism in current quantum programming languages and (2) fa-
cilitate space-time tradeoff investigations in quantum computing.
While the focus of similar libraries in the domain of classical
computing (OpenMP, OpenACC, etc.) is to divide a computation
into multiple threads, the main goal of QParallel is to keep the
compiler and the runtime system from introducing parallelism-
inhibiting dependencies, e.g., through reuse of qubits in automatic
qubit management. We describe the syntax and semantics of the
proposed language extension, implement a prototype based on
Q#, and present several examples and use cases to illustrate
its performance benefits. Moreover, we introduce a tool that
guides programmers in the placement of parallel regions by
identifying the subroutines that profit most from parallelization,
which is especially useful if the programmer’s knowledge of the
source code is limited. Support for QParallel can be added to
any multithreading library and language extension, including
OpenMP and OpenACC.
Index Terms—quantum computing parallel quantum comput-
ing space-time tradeoffs
I. INTRODUCTION
Quantum computers promise exponential speedups for cer-
tain computational tasks, including problems in chemistry [1]
and cryptography [2]. This applications require the use of
thousands of (error-corrected) qubits and millions of gates.
Multiple software frameworks and programming languages for
quantum computing have emerged [3]–[9] to assess whether
such speedups translate to an advantage of quantum computers
over classical supercomputers in practice.
These frameworks allow users to implement, test, and debug
quantum algorithms, before using the resulting implementation
to obtain estimates, e.g., for the number of quantum bits
(qubits) or operations required by the algorithm. Such resource
estimates are then used to focus algorithmic optimizations on
computational bottlenecks.
The compiler must make several choices when mapping the
high-level quantum program to the instruction set architecture
(ISA) of the target device. Examples are which quantum error
correction (QEC) procedure to employ and how many magic-
state factories to use. In particular, these choices result in
space-time tradeoffs, since (1) a longer computation requires
a larger-distance QEC code and therefore a larger physical-
per-logical qubit ratio, and (2) using more factories (to reduce
runtime) limits the space that is left on the quantum chip to
place algorithmic qubits. Moreover, since the rate at which
magic states are consumed is not constant throughout the
execution of a quantum program a priori, additional space-
time optimizations are necessary to ensure proper usage of
available resources.
For example, while peaks in magic state consumption rate
may be handled by magic state buffers, the buffer size required
may severely reduce the number of available algorithmic
qubits which, in turn, may prohibit other optimizations. In
such cases, it would thus be preferable to modify the quantum
program such that the magic state consumption rate is (closer
to) constant. Given these constraints, automatic parallelization
is a hard task and convenient mechanism for manual control
are preferable. This has also been observed in classical com-
puting which motivated solutions such as OpenMP [10].
Quantum programming languages should therefore make
space-time tradeoffs as straightforward as possible. In addition,
they have to work for applications that require thousands
of qubits and millions of gates. This is a challenge for
frameworks that first create a data-structure describing a full
quantum circuit and run various optimizations on such data
structure. To this end, we propose an extension for quantum
programming languages that gives programmers fine-grained
control over which parts of the quantum program run in
parallel and works for large scale applications.
Contributions: We introduce a language extension akin
to OpenMP that allows quantum programmers to investigate
various space-time tradeoffs more efficiently through explicit
parallelization. We implement our proposal as a Q# [3]
preprocessor and present several algorithmic benchmarks to
illustrate the benefits of our language extension. Specifically,
our contributions are as follows.
•We introduce the QParallel language extension for
explicitly-parallel quantum programming. QParallel al-
lows programmers to remove ambiguities concerning
parallelism in current quantum programming languages
(see related work below).
•We provide a detailed description of the syntax and
semantics of our proposed language extension.
•We implement a prototype of QParallel in Q# to allow
programmers to define parallel regions explicitly based
on a language feature proposal [11].
•We present several examples and use cases that leverage
our language extension to achieve improvements in space-
time volume.
•We show how to improve the integration of our language
extension with the quantum software stack using a tool
arXiv:2210.03680v1 [quant-ph] 7 Oct 2022