0% found this document useful (0 votes)
16 views11 pages

Reducing The Compilation Time of Quantum Circuits Using Pre-Compilation On The Gate Level

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views11 pages

Reducing The Compilation Time of Quantum Circuits Using Pre-Compilation On The Gate Level

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Reducing the Compilation Time of Quantum

Circuits Using Pre-Compilation on the Gate Level


Nils Quetschlich∗ Lukas Burgholzer∗ Robert Wille∗†
∗ Chairfor Design Automation, Technical University of Munich, Germany
† SoftwareCompetence Center Hagenberg GmbH (SCCH), Austria
[email protected] [email protected] [email protected]
https://www.cda.cit.tum.de/research/quantum

Abstract—In order to implement a quantum computing ap- ing platform providers that offer access to various quantum
arXiv:2305.04941v2 [quant-ph] 31 Jul 2023

plication, problem instances must be encoded into a quantum devices such as AWS Braket [13], and Microsoft’s Azure
circuit and then compiled for a specific platform. The lengthy Quantum [14] which implicitly take care of the compilation
compilation process is a key bottleneck in this workflow, es-
pecially for problems that arise repeatedly with a similar yet when executing quantum circuits.
distinct structure (each of which requires a new compilation run Compilation, i.e., making sure that a particular quantum
thus far). In this paper, we aim to overcome this bottleneck by
proposing a comprehensive pre-compilation technique that tries circuit can actually be executed on a targeted device, is an
to minimize the time spent for compiling recurring problems essential part of these workflows that involves many com-
while preserving the solution quality as much as possible. The putationally hard problems such as gate synthesis [15]–[20]
following concepts underpin the proposed approach: Beginning or qubit routing/mapping [21]–[28]. It is crucial to perform
with a problem class and a corresponding quantum algorithm, a this task as efficiently as possible, since the possible overhead
predictive encoding scheme is applied to encode a representative
problem instance into a general-purpose quantum circuit for introduced by compilation directly correlates with the quality
that problem class. Once the real problem instance is known, of the compiled circuit. However, this takes time. Time that in
the previously constructed circuit only needs to be adjusted— existing workflows is spent almost exclusively at “runtime”,
with (nearly) no compilation necessary. Experimental evaluations i.e., at the moment the entire problem instance is known.
on QAOA for the MaxCut problem as well as a case study Furthermore, every single instance of a particular problem
involving a satellite mission planning problem show that the
proposed approach significantly reduces the compilation time by class is compiled from scratch—although its instances have
several orders of magnitude compared to Qiskit’s compilation a similar yet distinct structure and are frequently recurring,
schemes while maintaining comparable compiled circuit quality. such as problems in scheduling [29] and finance [30].
All implementations are available on GitHub (https://github.com/
cda-tum/mqt-problemsolver) as part of the Munich Quantum In this work, we propose a pre-compilation technique that
Toolkit (MQT). aims to drastically reduce the time spent on compilation at
runtime while maintaining comparable quality of the compiled
I. I NTRODUCTION circuits. The proposed approach is based on the following
Quantum computing is an emerging technology that is con- ideas: Starting with a problem class (e.g., the MaxCut prob-
stantly improving both in software and hardware—sparking in- lem) and a quantum algorithm to solve the problem (e.g., the
terest in academia and industry. As a result, many approaches Quantum Approximate Optimization Algorithm, QAOA [31]),
have emerged that try to use quantum computing to solve a predictive encoding scheme is applied that encodes the
problems from various application domains such as finance classes’ structure (e.g., a QAOA circuit for fully connected
(e.g., [1]), machine learning (e.g., [2]), optimization (e.g., [3]), graphs) into a general-purpose quantum circuit for the whole
and chemistry (e.g., [4]). Dedicated workflows to describe the class of problems. This circuit is then (pre-) compiled to yield
necessary steps from an initial problem to a solution using a generic circuit for solving problems in the respective class
quantum computing are starting to emerge (e.g., [5]–[8]). that can be executed on a certain device. At runtime, when
These workflows usually include several steps: A suitable the actual problem instance is known, the resulting circuit
quantum algorithm has to be chosen for the respective problem only needs to be adjusted for the particular instance (e.g.,
and a quantum circuit needs to be constructed that encodes by removing gates corresponding to edges not present in
it. Then, this circuit must be compiled and executed on a the graph instance)—without requiring any compilation. As
targeted quantum device before the solution can be decoded the general-purpose circuits have to subsume a wide variety
from the results of the execution. Many Software Development of instances, their compilation is likely to induce a higher
Kits (SDKs) have been developed for conducting these steps overhead compared to just compiling one particular problem
(or at least some of them). Prominent examples are IBM’s instance. To counteract this potential loss in quality, some
Qiskit [9], Quantinuum’s TKET [10], Google’s Cirq [11], lightweight optimizations are performed at runtime in addition
and BQSKit [12]. Additionally, there are quantum comput- to adjusting the circuit.
Compilation at runtime

0.5

Relative Frequency
q0 0.4
q0 q0
0 1 0.3 0 1
Enc. q1 Synth. q1 M ap. q1 M eas. Dec.
−−−→ q2
−−−−→ q2
−−−→ q2 −−−−→ 0.2
−−−→
0.1
2 3 2 3
q3 q3 q3 0

|0000⟩

|0100⟩
|0101⟩
|0110⟩

|1111⟩
... ...

(a) Problem instance. (b) Encoded circuit. (c) Synth. circuit. (d) Mapped circuit. (e) Result. (f) Solution.
Runtime
Fig. 1: Established quantum computing workflow from a (MaxCut) problem to its solution.

Experimental evaluations on QAOA for the MaxCut prob- is encoded as a qubit and each edge between two nodes
lem as well as a real-world satellite mission planning use-case is encoded as a certain interaction between the respective
demonstrate the benefits of the proposed approach. For in- qubits—as sketched in Fig. 1b.
stances ranging from 5 to 100 qubits, the compilation time
at runtime is reduced by several orders of magnitudes with
a similar compiled circuit quality compared to the estab-
Once encoded as a quantum circuit, the circuit must be com-
lished workflow with all implementations available on GitHub
piled to be executable on a particular quantum device. This is
(https://github.com/cda-tum/mqt-problemsolver) as part of the
similar to classical programming, where a high-level program
Munich Quantum Toolkit (MQT).
(e.g., written in C++) needs to be compiled into low-level
The remainder of this work is structured as follows: The
machine instructions that are supported by the CPU on which
currently established quantum computing workflow from a
the program should run. Quantum computers generally offer
problem to a solution is reviewed in Section II. Subsequently,
a small but universal set of gates that is natively supported
Section III motivates the proposed pre-compilation scheme and
by the device. In the following, this is referred to as native
reviews related work. Based on that, Section IV describes the
gate-set. Every quantum computation that shall be executed
proposed compilation scheme in detail before it is evaluated
on a certain device must first be broken down into sequences
in Section V. Afterwards, the proposed scheme is applied to a
of native gates—a process frequently referred to as synthesis
real-world industry use-case from satellite mission planning in
with many respective methods proposed, e.g., in [15]–[20].
Section VI and discussed in Section VII. Finally, Section VIII
concludes this work.

II. T HE Q UANTUM C OMPUTING W ORKFLOW Example 2. Consider again the circuit from Fig. 1b and
Quantum computing can be used to solve classical problems assume that one of its five gates (the one marked in red)
from various domains as discussed in Section I. Although the is not a native gate on the targeted quantum device. Then,
problems to be solved obviously vary, the general workflow Fig. 1c sketches what a synthesized circuit might look like,
from the problem to a solution is commonly structured as where that gate has been decomposed into three (native) gates
shown in Fig. 1. (now marked in green).
Given a classical problem instance of a certain problem
class, the first step to solve the problem with quantum comput-
ing is to encode the problem into a quantum circuit that shall
Now that the circuit consists only of native gates, the
afterwards be executed on a quantum computer. This encoding
circuit’s (logical) qubits need to be mapped to the device’s
step is highly non-trivial and constitutes a whole research area
(physical) qubits—a process frequently referred to as qubit
on its own (e.g., [32]–[34]). It requires the problem description
placement, qubit allocation, or qubit layout. Many quantum
to be transformed in a way that is suitable as an input for a
computers, such as those based on superconducting qubits
certain quantum algorithm—with many degrees of freedom in
or neutral atoms, have a limited connectivity between their
the choice of an encoding and a particular algorithm.
qubits, i.e., multi-qubit gates may only be applied to qubits that
Example 1. Consider the graph shown in Fig. 1a and assume are connected on the device. As a result, the qubit mapping
that we want to solve the well-known MaxCut problem on generally has to be adapted dynamically throughout the circuit.
this graph, i.e., the goal is to find a partition of the graph’s This is typically achieved by inserting SWAP operations in a
nodes so that the number of edges between these partitions is process referred to as qubit routing. The whole process of
maximal. The Quantum Approximate Optimization Algorithm determining an initial qubit placement and then routing the
(QAOA, [31]) has been proposed as a candidate to tackle circuit is commonly referred to as mapping with methods
this problem on a quantum computer. For this, each node proposed, e.g., in [21]–[28].
Compilation at runtime

0.5

Relative Frequency
0.4
q0 q0 q0 q0
0 1 0 1 0.3 0 1
q1 q1 q q1
→ q2 → q2
→ 1
q2 → → q2 → 0.2
0.1

2 3 q3 q3 q3 2 3 q3 0
2 3

|0000⟩

|0100⟩
|0101⟩
|0110⟩

|1111⟩
... ...

(a) Generalized (b) Predictive encoding. (c) Pre-compilation. (d) Problem (e) Circuit adjustment. (f) Result. (g) Solution.
problem. instance.

Compile-Time Runtime

Fig. 2: Proposed workflow including pre-compilation.

Example 3. Consider the synthesized circuit shown in Fig. 1c technique that aims to drastically reduce the time spent on
and assume that each of the qubits is connected to its neigh- compilation at runtime while maintaining comparable solution
bors on the targeted device. Then, all but one gate (the one quality. This is illustrated in Fig. 2 and described next.
marked in blue) already adhere to the connectivity constraints.
A. Motivation
To resolve the remaining conflict, a single SWAP gate is
inserted in front of the last gate as shown in Fig. 1d. For a particular problem class and a selected quantum
algorithm, the process of taking a classical problem description
The circuit is now executable on the targeted device— and encoding it as a quantum circuit comes with an inherent
marking the end of the compilation step considered in this structure that is independent of the specific instance to be
work1 . It is essential to keep the overhead introduced by solved. This can be turned into a predictive encoding that
compiling the original circuit as low as possible, since each captures the structure of the whole problem class at once in
added gate decreases the fidelity of the overall result. The the form of a general-purpose quantum circuit.
complexity of the underlying problems (e.g., mapping being
NP-complete [38]) makes compilation a time- and resource- Example 5. In case of the MaxCut problem to be solved with
intensive task that is, nevertheless, crucial for reliably execut- QAOA (as considered throughout Section II), the problem can
ing quantum circuits. be generalized to a problem class by making some kind of
For the actual execution, the circuit is usually sent to a quan- assumption on the properties of the graphs that are expected
tum device provider over the cloud and the result is sent back as input. The simplest case, essentially assuming that there
in the form of a histogram of measurement outcomes. These are no restrictions, is to consider the complete graph as
measurement outcomes are then post-processed (decoded) to shown in Fig. 2a. Any MaxCut problem on four nodes can
reveal the solution to the problem. be derived from this generalized description. The predictive
encoding is generated by applying the same encoding process
Example 4. An execution of the quantum circuit sketched in to the generalized description as would have been applied to a
Fig. 1d might yield a distribution of measurement outcomes specific instance. More precisely, a qubit is allocated for each
as shown in Fig. 1e. There, the measurement result (|0101⟩) of the nodes and a dedicated gate is added to the circuit for
occurred with a significantly higher frequency than all other each connection between nodes. Fig. 2b figuratively sketches
results—marking it as the solution. Since each qubit was what such a all-to-all circuit might look like.
chosen to encode one node of the graph, the value of each
qubit indicates to which partition a particular node belongs. Since the predictive encoding is, per definition, independent
In this case, the solution groups {0, 2} and {1, 3} as shown in of the particular problem instance, it can be pre-compiled, i.e.,
Fig. 1f, which, indeed, are a solution to the MaxCut problem determined at compile-time as opposed to at runtime once the
on this graph. particular instance is known. This creates a general-purpose,
executable circuit for the problem class considered.
III. G ENERAL I DEA
Example 6. Consider again the predictive encoding circuit
The established workflow described in Section II and illus-
shown in Fig. 2b. Using pre-compilation, the entire compi-
trated in Fig. 1 comes with a major bottleneck: The crucial and
lation process is conducted and yields a pre-compiled and
expensive compilation step is conducted from scratch during
ready-to-execute circuit at compile-time as sketched in Fig. 2c.
runtime for every single problem instance—leading to long
runtimes for determining a solution for a particular problem At runtime, once the problem instance is known, the previ-
instance. In the following, we propose a pre-compilation ously compiled circuit needs to be adjusted to reflect the actual
problem instance before being sent to the device provider for
1 Before a circuit can really be executed on a particular device, several
execution. This is significantly cheaper than a full compilation
more low-level steps such as pulse-level compilation and scheduling need to
be conducted (using SDKs such as proposed in, e.g., [35]–[37]). These steps pass as the necessary adjustments frequently boil down to
will not be considered in further detail in this work and are assumed to occur simple gate removals.
once the circuit is sent to the device provider for execution.
Example 7. Assume that, at runtime, the same problem ×Repetitions
instance previously considered as the starting point in Fig. 1a State Prep.
Cost Layer
Mixer Layer
should be solved. The respective graph (shown again in 0 1
q0 H RX
Fig. 2d) misses two edges compared to the complete graph q1 H RX
that was used for the predictive encoding (shown in Fig. 2a). q2 H RX
2 3
Therefore, the pre-compiled quantum circuit must be traversed q3 H RX
and all compiled quantum gates involved in the anticipated
but now non-present edges must be removed as shown in Fig. 3: Predictive Encoding for the MaxCut problem using
Fig. 2e (insinuated in red). Afterwards, the altered compiled QAOA assuming that all interactions are present.
quantum circuit can be sent for execution and the solution
can be decoded as before—leading to the same histogram and
solution—again visualized in Fig. 2f and Fig. 2g, respectively.
phase, the database of pre-compiled pulses is searched for
Following this approach, much of the heavy burden of suitable pulses. If there are no pre-compiled pulses for all
compilation can be shifted from runtime to compile-time. groups, the respective pulses are generated in the dynamic
Furthermore, heavy and compute-intensive optimizations can phase, before they are concatenated with the pulses of the
be applied at compile-time, where it is not so critical to be static phase.
fast as this has to be done only once.
However, there is no free lunch: The predictive encoding has
to subsume a variety of instances which is likely to increase
the compilation overhead as compared to compiling a single IV. P ROPOSED C OMPILATION S CHEME
problem instance. As demonstrated by experimental evalua-
tions (summarized later in Section V), this can be mitigated
to some extent by performing lightweight optimizations after In this section, the proposed compilation scheme is ex-
the circuit adjustment at runtime. plained in more detail—again using MaxCut as a running
example. More specifically, the proposed compile-time and
B. Related Work circuit adjustment steps are described.
So far, pre-compilation has hardly been explored—
presumably, because compiling everything at runtime has
been “good enough” for the scale of problems considered A. Compile-time Steps
today. Existing works focus on Variational Quantum Algo-
rithms (VQAs) and mostly rely on the concept of lookup tables The compile-time steps comprise the (predictive) encoding
that map uncompiled (sequences of) gates to their compiled and the (pre-) compilation, which in turn entails native gate-set
equivalent. synthesis and mapping as reviewed in Section II. So far, these
In [39], already a decade ago, an approach to pre-compile steps have mostly been conducted at runtime after the problem
certain rotation angles of single-qubit gates was proposed. instance is known. In contrast, a different approach has been
Whenever a single-qubit with an arbitrary rotation angle chosen in the proposed scheme: instead of encoding the actual
occurs, it is compiled by concatenating a sequence of the problem instance, a specific problem instance is anticipated—
pre-compiled rotation angles. exploiting the inherent structure of the problem class and the
After years of no active research in this domain, further selected quantum algorithm.
works have examined pre-compilation on the pulse level—
describing how each quantum gate is translated into a sequence Example 8. To illustrate the proposed predictive encoding,
of electro-magnetic pulses when executed on the actual quan- assume a MaxCut problem with four nodes, and therefore,
tum device. In [40], an approach has been proposed targeting six possible edges shall be solved using QAOA as already
VQAs by exploiting their general circuit structure consisting mentioned in Example 5. The general structure of the al-
of parameterized and non-parameterized gates. The authors gorithm (shown in Fig. 3) consists of a sequence of three
pre-compile the non-parameterized gates to the pulse level and different building blocks: the state preparation, the cost layer,
optimize them extensively. At runtime, only the parameterized and the mixer layer—with the last two blocks being repeated
gates need to be compiled and stitched together with the a certain number of times. To this end, only the cost layer
pre-compiled pulses. depends on the actual problem instance. It models the graph
Similarly, the authors of [41] focus on the pulse level and by representing each node as a qubit and applying RZZ gates
propose a static/dynamic hybrid workflow. This approach is between connected nodes, e.g., an edge between nodes 0 and
based on storing pre-compiled pulses for certain groups of 1 translates to a RZZ gate between qubits q0 and q1 . By
quantum gates in a database. Whenever a new quantum circuit anticipating that all possible edges are present, the cost layer
is compiled, it is decomposed into groups and during the static can be fully encoded.
0 1 2 q2 →
7 Q0 RZ RZ
0 1
q0 →7 Q1 State Mixer
3 q3 → 7 Q2 Prep. RZ RZ RZ Layer
4 q1 7→ Q3 RZ 2 3

(a) imbq_quito. (b) Mapped quantum circuit. The state preparation and mixer layer are problem-independent and their compiled gate (c) MaxCut prob-
sequences (as shown in Example 9) are encapsulated in respective blocks. Each SWAP gate (compiled to three CNOT lem instance.
gates) is denoted in a blue box, each anticipated and also actually present edge is denoted in a black box while the
to-be-removed edges are denoted in red boxes.

Fig. 4: Mapping.

After the predictive encoding, all further compilation steps actual problem instance must be determined. Subsequently, the
can be conducted in the same fashion as before—just with already compiled quantum circuit must be adjusted based on
the difference that the resulting compiled quantum circuit the determined difference.
does not represent the actual problem instance (which is
not known yet) but an anticipated one. Using the predictive Example 10. Consider the same MaxCut instance as in
encoding scheme, pre-compilation is no longer restricted to the Example 7. It comprises four of the six anticipated edges as
problem-independent parts of a general quantum algorithm (as illustrated in Fig. 4c (missing edges are denoted as dashed
in the existing techniques reviewed in Section III-B), but can red lines). Consequently, the pre-compiled quantum circuit
be applied to the entire quantum circuit. (shown in Fig. 4b) needs to be adjusted and the (compiled)
quantum gates representing the two missing edges must be
Example 9. Assume that the encoded quantum circuit from removed—as highlighted by red boxes each representing one
Example 8 shall be executed
√ on the five-qubit ibmq_quito of the to-be-removed edges (while the black boxes represent
device that offers RZ , X, X, and CX gates as its native the actual present edges). The easiest way to accomplish
gates and whose layout is shown in Fig. 4a. Then, each of this—requiring only a linear traversal of the circuit—is by
the QAOA building blocks—state preparation (consisting of simply setting the angles of all RZ gates corresponding to
H gates), cost (RZZ gates), and mixer layers (RX gates)— the to-be-removed edges to zero. This adjustment effectively
is first compiled to native gates using the following circuit makes the corresponding RZ gates no-ops and hence leads
identities: to the applications of the remaining CX gates to cancel
H = RZ (π/2) X RZ (π/2) each other out. The resulting circuit is executable and solves
α the underlying problem—with barely any modifications to the
pre-compiled circuit necessary at runtime.
=
RZ (α)
All these benefits do not come for free. As stated previously,
√ √ not only is it important for a circuit to be executable and
RX (α) = RZ (π/2) X RZ (α + π) X
solve the problem, but the overhead introduced by compilation
After that, the circuit’s qubits can be assigned to the device should be as low as possible. For most systems, this overhead
qubits as shown on the left-hand side of Fig. 4b. Consider can be quantified by the number of two-qubit gates in the
a single repetition of the cost and mixer layer. Then, two resulting circuit. Since predictive encoding anticipates many
SWAP gates (which are, in turn, decomposed into sequences different problem instances, it is highly likely that its compi-
of three CX gates) are necessary to satisfy the connectivity lation induces a larger overhead compared to compiling a sin-
constraints imposed by the architecture throughout the entire gle problem instance. As such, the proposed pre-compilation
circuit. Eventually, this results in the mapped circuit shown in scheme offers a trade-off between the time spent during
Fig. 4b with the compiled SWAP gates denoted in the blue compilation at runtime and the quality of the resulting circuit.
boxes. Applying optimizations at runtime allows making this trade-
off almost continuous. The heavier optimizations are applied
After these steps have been executed, a fully executable at runtime, the closer the performance will typically get to the
general-purpose quantum circuit has been created—while the established workflow—at the cost of longer runtimes.
actual problem instance is not known yet.
Example 11. Consider again the circuit from Example 10.
B. Circuit Adjustment Step Instead of only setting the angles of the RZ gates to zero
At runtime, the problem instance is known and the goal is during circuit adjustment, a lightweight optimization removes
to make sure that the fully encoded, compiled, and mapped these gates entirely from the circuit and tries to cancel
circuit is altered such that it actually solves the problem subsequent CX gates that act on the same qubits. Considering
instance. For that, the difference between the encoded and the Fig. 4b, this completely eliminates the gates in the red boxes.
Compared to directly compiling the circuit for the problem B. Results
instance (as in the established workflow shown in Fig. 1), The findings of this study are summarized in Fig. 5. For each
the proposed scheme results in a circuit containing one more combination of e and p values—four combinations in total—
SWAP gate. Note that some parts of the introduced SWAP the compilation time at runtime and the resulting compiled
gates can be further canceled with parts of some RZZ gates circuit quality have been evaluated and denoted side-by-side,
via the lightweight gate optimization—bringing the overhead e.g., in Fig. 5a and Fig. 5b for the combination e = 1, p = 0.3.
down to a bare minimum. The results show that the proposed compilation scheme is
faster than all Qiskit compilations for all the combinations
As shown by experimental evaluations, which are summa-
evaluated of e and p as indicated in the left figures of
rized next, this can reduce the compilation time at runtime
Fig. 5. When comparing the time reduction depending on the
by several orders of magnitude while maintaining comparable
sample probability p, it is noteworthy that the improvement
compiled circuit quality.
is higher for both p = 0.7 cases compared to p = 0.3 cases.
V. E XPERIMENTAL E VALUATION The higher p is, the closer the predicted encoding is to the
actual problem instances, and consequently, less compilation
This section evaluates the proposed compilation scheme overhead is induced.
for varying problem instances and compares both the com- The respective qualities of the compiled circuits are indi-
pilation time at runtime and the quality of the compiled cated on the right of Fig. 5. The proposed approach, again,
quantum circuits. All implementations are available on GitHub outperforms Qiskit’s O0 and is on par or only slightly worse
(https://github.com/cda-tum/mqt-problemsolver) as part of the than the most optimized Qiskit compilation O3 in most cases.
Munich Quantum Toolkit (MQT). When again comparing the p = 0.7 cases to the p = 0.3 cases,
p = 0.7 leads to a smaller overhead in terms of the number of
A. Setup two-qubit gates and even outperforms Qiskit’s O3 for many
For the evaluation, the MaxCut problem described through- evaluated problem instances for e = all (as shown in Fig. 5h).
out all examples is implemented based on Qiskit (v0.41.1) in The evaluations demonstrate that the proposed compilation
Python with various parameters: scheme achieves a promising trade-off between compilation
• Number of nodes considered (and therefore qubits): 5 to time and compiled circuit quality. For scenarios where the
100 with a step size of 5. compilation time at runtime is of prime importance, Qiskit’s
• Chosen algorithm: QAOA with 3 repetitions. fastest compilations are the baselines to beat—which the pro-
• Targeted devices: ibmq_quito, ibmq_montreal, and posed approach is strictly doing for all problem instances. On
ibmq_washington with 5, 27, and 127 qubits, respectively. top of that, the compiled circuit quality is always better than
Each problem instance is compiled to the smallest but Qiskit’s O0 and in the vast majority of cases comparable to
sufficiently large device. Qiskit’s most optimized O3 compilation—which comes with
• Predictive encoding assumption: Edges are possible be- an inferior compilation time by several orders of magnitude
tween all qubit pairs (e = all) (as shown in the example and, by that, is often not a viable option in those scenarios.
in Example 11) or each node can have at most one VI. A PPLICATION :
possible edge to its immediate successor (e = 1). S ATELLITE M ISSION P LANNING P ROBLEM
• Problem instance creation: With sample probability So far, the benefits of the proposed compilation scheme
p ∈ {0.3, 0.7} a possible edge is actually present. The have been shown and evaluated based on the rather academic
higher p, the more anticipated interactions will be present MaxCut problem. In this section, an application from the space
after the problem instance is revealed. industry (taken from [43]) is introduced and the proposed
All problem instances evaluated are assessed by two criteria: compilation scheme is applied to highlight the benefit it offers
1) Compilation time at runtime and for a real-world use-case.
2) Compiled circuit quality—determined by the number A. Motivation
of present two-qubit gates representing the compilation Currently, there are hundreds of satellites orbiting the Earth
overhead induced by the proposed approach with lower with the goal of photographing certain locations. However,
being better. each satellite usually has only a very narrow field-of-view
For comparison, IBM’s Qiskit compiler is used with opti- and, therefore, needs to physically rotate its optics between
mization levels O0 to O3 following the quantum workflow capturing different locations while it is moving on its orbit
(mentioned in Fig. 1) while the compile-time steps of the with constant speed. As a consequence, it may not be possible
proposed approach have been conducted with Qiskit’s highest to take images of all to-be-captured locations. Additionally,
optimization level O3. Additionally, it is spot-checked (using the time to determine which locations to select is critical and
MQT QCEC [42]) that the compiled and adjusted quantum must stay within a fixed time budget—otherwise the result
circuits created by the proposed approach are equivalent to is worthless, since the satellite may already passed the first
the created circuits of the baselines. location.
102

Number of two-qubit gates


101
102
Time [s]

100
10 1
Proposed Scheme Proposed Scheme
Qiskit's O0 Qiskit's O0
10 2 Qiskit's O1 Qiskit's O1
Qiskit's O2 Qiskit's O2
Qiskit's O3 Qiskit's O3
10 3
20 40 60 80 100 20 40 60 80 100
Qubits Qubits
(a) Compilation time at runtime: e = 1 and p = 0.3. (b) Compiled circuit quality: e = 1 and p = 0.3.

104
103

Number of two-qubit gates


102

100
Time [s]

10 2
Proposed Scheme Proposed Scheme
102
Qiskit's O0 Qiskit's O0
Qiskit's O1 Qiskit's O1
10 4
Qiskit's O2 Qiskit's O2
Qiskit's O3 Qiskit's O3
20 40 60 80 100 20 40 60 80 100
Qubits Qubits
(c) Compilation time at runtime: e = 1 and p = 0.7. (d) Compiled circuit quality: e = 1 and p = 0.7.

105
101
Number of two-qubit gates

104
100
Time [s]

103
10 1
Proposed Scheme Proposed Scheme
Qiskit's O0 Qiskit's O0
Qiskit's O1 Qiskit's O1
10 2
Qiskit's O2 102 Qiskit's O2
Qiskit's O3 Qiskit's O3
20 40 60 80 100 20 40 60 80 100
Qubits Qubits
(e) Compilation time at runtime: e = all and p = 0.3. (f) Compiled circuit quality: e = all and p = 0.3.

102
105
Number of two-qubit gates

101

100 104
Time [s]

10 1
Proposed Scheme 103 Proposed Scheme
Qiskit's O0 Qiskit's O0
10 2
Qiskit's O1 Qiskit's O1
Qiskit's O2 Qiskit's O2
Qiskit's O3 102 Qiskit's O3
10 3
20 40 60 80 100 20 40 60 80 100
Qubits Qubits
(g) Compilation time at runtime: e = all and p = 0.7. (h) Compiled circuit quality: e = all and p = 0.7.

Fig. 5: Experimental evaluation of the proposed approach for various parameter choices.
×Repetitions

L1 State Prep. Weight Factor Cost Layer Mixer Layer


L3
q0 H RZ (θ0 · 2αi ) RX (2βi )
L4
γ · 2αi
q1 H RZ (θ1 · 2αi ) RX (2βi )
γ · 2αi
q2 H RZ (θ2 · 2αi ) RX (2βi )
q3 H RZ (θ3 · 2αi ) RX (2βi )

L2 q4 H RZ (θ4 · 2αi ) RX (2βi )

L0 Fig. 7: Satellite problem encoded using QAOA.

Fig. 6: Satellite mission planning problem with five to be


imaged locations (L0 to L4) with two infeasible location pairs: C. Experimental Evaluation
L1/L2 and L2/L3.
The satellite mission planning problem is evaluated with
similar parameters as the MaxCut problem:
Example 12. Consider a satellite that is tasked to take photos • Number of locations considered (and, therefore, qubits):
of five locations (L0 to L4) as shown in Fig. 6. While the 5 to 100 with a step size of 5.
locations L0 and L1 are distant and provide enough time for • Chosen algorithm: QAOA with 3 repetitions.
the physical rotation of the optics, there is a selection problem • Targeted devices: ibmq_quito, ibmq_montreal, and
for locations L1 to L3: If the location L1 is selected, it is in- ibmq_washington with 5, 27, and 127 qubits, respectively.
feasible to also select the location L2. Furthermore, if location Each problem instance is compiled to the smallest but
L2 is selected, location L3 becomes infeasible. Therefore, the sufficiently large device.
maximum number of feasible locations is achieved by selecting • Predictive encoding assumption: Each pair of subsequent
all except L2—resulting in four captured locations. locations is either feasible or infeasible (e = 1).
• Problem instance creation: With sample probability
p = 0.4 a pair of to-be-captured locations is infeasible.
B. Quantum Computing Approach
Using the compilation scheme proposed in Section IV
In [43], this problem has already been approached using a results in a significantly reduced compilation time at run-
quantum annealing ansatz. Therefore, a problem formulation time compared to Qiskit’s compilation schemes (as depicted
as a Quadratic Unconstrained Binary Optimization (QUBO) in Fig. 8a) while maintaining comparable compiled circuit
problem was proposed. quality (as depicted in Fig. 8b)—similar to the results of the
In addition to the quantum annealing approach, this problem experimental evaluations described in Section V. The proposed
can also be solved using gate-based quantum computing, approach is almost always faster than all baselines while the
e.g., using QAOA. For that, a simplified problem formulation difference becomes even more distinct with an increasing
compared to [43] has been chosen where each location can be number of qubits. Regarding the compiled circuit quality, the
captured from one position on the orbit. By that, each location proposed compilation scheme always outperforms Qiskit’s O0
is encoded as one qubit representing if that location has been and is only slightly worse than Qiskit’s most optimized O3
selected for capturing or not—with the goal of capturing as compilation—which is inferior by several orders of magnitude
many locations as possible while still being physically feasible. in compilation time.
Since QAOA is used—similar as in Fig. 3—also the circuit
structure for the satellite mission planning problem is similar:
Whenever two locations cannot be feasibly selected, there is a VII. D ISCUSSION
RZZ gate (similar to the edges between nodes in the MaxCut
problem). The main difference to the MaxCut QAOA example All those mentioned benefits do not come for free. For
is a weight factor for every qubit (encoded by a RZ gate) to the predictive encoding, a suitable quantum algorithm and a
represent the dependencies between selecting varies locations respective encoding of the problem class must be determined
as shown in Fig. 7 in its uncompiled form for the problem and applied. This alone is challenging and requires expert
instance depicted in Fig. 6. Additionally, all RZZ gates in knowledge in both quantum computing and the problem
the problem layer are multiplied by a factor γ determined domain—constituting a whole research domain on its own.
by the specific problem instance and its translation to an Ising The closer the anticipated problem instance comes to the actual
Hamiltonian. problem instance, the better will be the compilation quality.
103

Number of two-qubit gates


102
Proposed Scheme
101 Qiskit's O0
Time [s]

Qiskit's O1
Qiskit's O2 102
100 Qiskit's O3 Proposed Scheme
Qiskit's O0
Qiskit's O1
10 1 Qiskit's O2
Qiskit's O3
20 40 60 80 100 20 40 60 80 100
Qubits Qubits
(a) Compilation time at runtime: p = 0.4. (b) Compiled circuit quality: p = 0.4.

Fig. 8: Experimental evaluation for the satellite use-case.

Additionally, the encoding scheme must be chosen so that In this paper, we proposed a comprehensive pre-compilation
the circuit adjustment step—which adjusts the already fully scheme to reduce the compilation time at runtime based on
executable pre-compiled quantum circuit to represent the ac- predictive encoding at compile-time and a respective circuit
tual problem instance and not the anticipated one—can be adjustment at runtime. For that, a general-purpose quantum
conducted efficiently. Therefore, it is recommended to only circuit is created—subsuming a wide variety of problem
delete quantum gates from the pre-compiled circuit. Inserting instances—and pre-compiled. As soon as the actual problem
new gates could, in the worst case, destroy the mapping so instance becomes known, the pre-compiled circuit is adjusted
that this compilation step needs to be re-done—impairing the to represent the actual problem and not the anticipated one.
desired compilation time at runtime improvement. Hence, it Experimental evaluations on QAOA for the MaxCut prob-
heavily influences the trade-off between reduced compilation lem as well as a case study involving a satellite mission
time and compiled circuit quality—if it is either slow or planning problem show that this reduces the compilation time
ineffective, the benefits of the proposed compilation scheme at runtime by several orders of magnitude compared to Qiskit’s
dissolves. compilation schemes while maintaining comparable compiled
To adapt the proposed scheme for arbitrary problems, some circuit quality. All implementations are available on GitHub
one-time manual effort is required to setup the predictive (https://github.com/cda-tum/mqt-problemsolver) as part of the
encoding based on the assumptions made. The degree of Munich Quantum Toolkit (MQT).
required work needed depends very much on the selected However, implementing this proposed pre-compilation
quantum algorithm. For some algorithms such as the Vari- scheme comes with a considerable one-time effort, since a suit-
ational Quantum Eigensolver (VQE, [4]) it is simple since able predictive encoding scheme to create the general-purpose
the whole quantum circuit is problem-independent and can circuit is highly dependent on the problem class and the se-
be pre-compiled already by the approaches mentioned in Sec- lected quantum algorithm to solve it. In addition, the encoding
tion III-B. For other algorithms such as Grover [44] or Quan- scheme must be chosen so that the circuit adjustment step can
tum Phase Estimation (QPE, [45]) it is less straight-forward to be conducted efficiently. Therefore, this work constitutes a first
find efficient assumptive problem instances, since it is harder step towards a general comprehensive pre-compilation scheme,
to find an overarching anticipated problem instance that can be but further steps are necessary.
encoded as a general-purpose circuit where all other possible
problem instances can be derived from. ACKNOWLEDGMENTS
This work received funding from the European Re-
VIII. C ONCLUSIONS search Council (ERC) under the European Union’s Horizon
2020 research and innovation program (grant agreement No.
Compilation is an essential—but time-consuming—part of 101001318), was part of the Munich Quantum Valley, which is
quantum workflows solving problems from any kind of appli- supported by the Bavarian state government with funds from
cation domain and is currently almost exclusively conducted the Hightech Agenda Bayern Plus, and has been supported
at runtime. Additionally, every single problem instance is by the BMWK on the basis of a decision by the German
compiled from scratch, even though they share a similar struc- Bundestag through project QuaST, as well as by the BMK,
ture. This becomes even more severe for frequently recurring BMDW, and the State of Upper Austria in the frame of the
problems. COMET program (managed by the FFG).
R EFERENCES [17] D. M. Miller, R. Wille, and Z. Sasanian, “Elementary
[1] N. Stamatopoulos et al., “Option pricing using quantum quantum gate realizations for multiple-control Toffoli
computers,” Quantum, 2020. gates,” in Int’l Symp. on Multi-Valued Logic, 2011.
[2] C. Zoufal, A. Lucchi, and S. Woerner, “Quantum Gen- [18] A. Zulehner and R. Wille, “One-pass design of re-
erative Adversarial Networks for learning and loading versible circuits: Combining embedding and synthesis
random distributions,” npj Quantum Information, 2019. for reversible logic,” IEEE Trans. on CAD of Integrated
[3] S. Harwood, C. Gambella, D. Trenev, A. Simonetto, Circuits and Systems, 2018.
D. Bernal Neira, and D. Greenberg, “Formulating and [19] P. Niemann, R. Wille, and R. Drechsler, “Advanced
Solving Routing Problems on Quantum Computers,” exact synthesis of Clifford+T circuits,” Quantum Infor-
IEEE Transactions on Quantum Engineering, 2021. mation Processing, 2020.
[4] A. Peruzzo et al., “A variational eigenvalue solver on a [20] T. Peham, N. Brandl, R. Kueng, R. Wille, and L.
photonic quantum processor,” Nature Communications, Burgholzer, “Depth-optimal synthesis of Clifford cir-
2014. cuits with SAT solvers,” in Int’l Conf. on Quantum
[5] N. Quetschlich, L. Burgholzer, and R. Wille, “Towards Computing and Engineering, 2023.
an Automated Framework for Realizing Quantum Com- [21] M. Y. Siraichi, V. F. dos Santos, S. Collange, and
puting Solutions,” in Int’l Symp. on Multi-Valued Logic, F. M. Q. Pereira, “Qubit allocation,” in Int’l Symp. on
2023. Code Generation and Optimization, 2018.
[6] B. Poggel, N. Quetschlich, L. Burgholzer, R. Wille, and [22] A. Zulehner, A. Paler, and R. Wille, “An efficient
J. M. Lorenz, “Recommending Solution Paths for Solv- methodology for mapping quantum circuits to the IBM
ing Optimization Problems with Quantum Computing,” QX architectures,” IEEE Trans. on CAD of Integrated
in Int’l Conf. on Quantum Software, 2023. Circuits and Systems, 2019.
[7] N. Quetschlich, L. Burgholzer, and R. Wille, “Predict- [23] A. Matsuo and S. Yamashita, “An efficient method for
ing Good Quantum Circuit Compilation Options,” in quantum circuit placement problem on a 2-D grid,” in
Int’l Conf. on Quantum Software, 2023. Int’l Conf. of Reversible Computation, 2019.
[8] N. Quetschlich, L. Burgholzer, and R. Wille, “Compiler [24] R. Wille, L. Burgholzer, and A. Zulehner, “Mapping
Optimization for Quantum Computing Using Reinforce- quantum circuits to IBM QX architectures using the
ment Learning,” in Design Automation Conf., 2023. minimal number of SWAP and H operations,” in Design
[9] Qiskit contributors, “Qiskit: An open-source framework Automation Conf., 2019.
for quantum computing,” 2023. [Online]. Available: [25] G. Li, Y. Ding, and Y. Xie, “Tackling the qubit mapping
https://doi.org/10.5281/zenodo.2573505. problem for NISQ-era quantum devices,” in Int’l Conf.
[10] S. Sivirajah, S. Dilkes, A. Cowtan, W. Simmons, A. on Architectural Support for Programming Languages
Edgington, and R. Duncan, “TKET: A Retargetable and Operating Systems, 2019.
Compiler for NISQ devices,” Quantum Science and [26] T. Peham, L. Burgholzer, and R. Wille, “On Optimal
Technology, 2020. Subarchitectures for Quantum Circuit Mapping,” ACM
[11] C. Developers, Cirq, version v1.2.0, 2023. [Online]. Transactions on Quantum Computing, 2023.
Available: https://doi.org/10.5281/zenodo.8161252. [27] S. Hillmich, A. Zulehner, and R. Wille, “Exploiting
[12] E. Younis, C. C. Iancu, W. Lavrijsen, M. Davis, Quantum Teleportation in Quantum Circuit Mapping,”
E. Smith, and USDOE, “Berkeley quantum synthesis in Asia and South Pacific Design Automation Conf.,
toolkit (bqskit) v1,” 2021. [Online]. Available: https : 2021.
//www.osti.gov/biblio/1785933. [28] A. Zulehner and R. Wille, “Compiling SU(4) quantum
[13] Amazon Braket Python SDK, Amazon Web Services, circuits to IBM QX architectures,” in Asia and South
2022. [Online]. Available: https : / / github . com / aws / Pacific Design Automation Conf., 2019.
amazon-braket-sdk-python. [29] H. Mohammadbagherpoor et al., “Exploring airline
[14] Azure Quantum documentation, Microsoft, 2022. [On- gate-scheduling optimization using quantum comput-
line]. Available: https : / / learn . microsoft . com / en - us / ers,” 2021. arXiv: 2111.09472.
azure/quantum/. [30] R. Orús, S. Mugel, and E. Lizaso, “Quantum comput-
[15] B. Giles and P. Selinger, “Exact synthesis of multiqubit ing for finance: Overview and prospects,” Reviews in
Clifford+T circuits,” Physical Review A, 2013. Physics, 2019.
[16] M. Amy, D. Maslov, M. Mosca, and M. Roetteler, [31] E. Farhi, J. Goldstone, and S. Gutmann, “A quantum ap-
“A meet-in-the-middle algorithm for fast synthesis of proximate optimization algorithm,” 2014. arXiv: 1411.
depth-optimal quantum circuits,” IEEE Trans. on CAD 4028.
of Integrated Circuits and Systems, 2013. [32] F. Dominguez, J. Unger, M. Traube, B. Mant, C. Ertler,
and W. Lechner, “Encoding-independent optimization
problem formulation for quantum computing,” 2023. [40] P. Gokhale et al., “Partial compilation of variational
arXiv: 2302.03711. algorithms for noisy intermediate-scale quantum ma-
[33] M. Weigold, J. Barzen, F. Leymann, and M. Salm, “En- chines,” in Int’l Symposium on Microarchitecture, 2019.
coding patterns for quantum algorithms,” IET Quantum [41] J. Cheng, H. Deng, and X. Qian, “Accqoc: Accelerating
Communication, 2021. quantum optimal control based pulse generation,” 2020.
[34] M. Schuld and F. Petruccione, “Machine learning with arXiv: 2003.00376.
quantum computers.” Springer, 2021. [42] T. Peham, L. Burgholzer, and R. Wille, “Equivalence
[35] T. Alexander et al., “Qiskit pulse: Programming quan- checking of parameterized quantum circuits: Verifying
tum computers through the cloud with pulses,” Quantum the compilation of variational quantum algorithms,” in
Science and Technology, 2020. Asia and South Pacific Design Automation Conf., 2023.
[36] B. Li et al., “Pulse-level noisy quantum circuits with [43] T. Stollenwerk, V. Michaud, E. Lobe, M. Picard, A.
QuTiP,” Quantum, 2022. Basermann, and T. Botter, “Image acquisition plan-
[37] H. Silvério et al., “Pulser: An open-source package for ning for earth observation satellites with a quantum
the design of pulse sequences in programmable neutral- annealer,” 2020. arXiv: 2006.09724.
atom arrays,” Quantum, 2022. [44] L. K. Grover, “A fast quantum mechanical algorithm
[38] A. Botea, A. Kishimoto, and R. Marinescu, “On the for database search,” Proc. of the ACM, 1996.
complexity of quantum circuit compilation,” in Sympo- [45] A. Y. Kitaev, “Quantum measurements and the Abelian
sium on Combinatorial Search, 2018. Stabilizer Problem,” 1995. arXiv: arXiv : quant - ph /
[39] D. Kudrow et al., “Quantum rotations: A case study 9511026.
in static and dynamic machine-code generation for
quantum computers,” SIGARCH Comput. Archit. News,
2013.

You might also like