automate their approach the Remez algorithm [5] can be
used to determine a piecewise polynomial approximation
given as input an L∞-error on the respective domain.
The precision of the fixed-point numbers rely on the
coefficients in the polynomial approximation and the
implementation of arithmetic operations to evalaute the
polynomial. The approach works well for functions in
which the function values of the function in the evaluated
input domain are contained in a small interval.
In [6], the authors presented an algorithm that creates
a quantum implementation based on a classical Boolean
function, which can be provided symbolically in terms of
a classical logic network. Such and similar so-called hier-
archical reversible synthesis methods can be used given
as input an approximation of a single-variabled fixed-
point function. For these algorithms, the effort is shifted
towards classical optimization of the logic network for
which existing automatic optimization algorithms can be
leveraged.
II. IMPLEMENTATION AND OF A QUANTUM LOOKUP
TABLE CIRCUIT IN Q#
In this section, we will first discuss the the imple-
mentation of a LUT in Q# for arithmetic functions.
In Subsection II-A we introduce the fixed-point SE-
LECTSWAP network which is at the crux of the imple-
mentation, and discuss its implementation in Q#. Then,
in Subsection II-B we will discuss how the function
that implements this quantum circuit (such functions are
referred to as operations in Q#) can be used within
a wrapper function to allow the user to easily create
a quantum LUT operator for any desired arithmetic
function.
A. The fixed-point representation implementation of a
LUT
To implement the generic fixed-point representation
LUT, we use the SELECTSWAP network [7], for which
we present a running example in Figure 1. To understand
the network, we can start by looking at the standalone
SELECT network [8]. This network is a series of Xgates
on the output qubits controlled on the input qubits. For
example, with a two qubit input of |00iand a desired
two qubit output of |10i, the first layer of the SELECT
network would be an Xgate on the first output qubit
controlled on all 3 input qubits being 0. The next layer
of the network is constructed using the desired output
for the input |01iand so on. In general, this requires
a T-depth of 2nwhere nis the number input qubits.
However we can create a trade-off between T-depth and
width of the circuit by adding a SWAP network. To do
this, we first compute several outputs in parallel based
on the least significant input qubits, and then swap in the
desired output based on the most significant input qubits.
Building upon on the previous example, let us look at
the case where we have a three qubit input and two qubit
output, with the input |000ihaving a desired output of
|10iand the input |100ihaving a desired output of |01i.
We proceed by selecting on the 2 least significant qubits
and then using the most significant qubit as the swap
qubit. To implement this, we first construct a 4 qubit
output SELECT network which would output |10i |01i
(constructed using controlled-Xgates) conditioned the
last two input qubits being 0. The last step is to ensure
that the first 2 qubits of our output state ends up begin
the register containing f(x). In this example, if the first
input qubit is also |0i, then we don’t have to do anything.
But if it is |1i, then we would like to swap the output
registers. So to implement the first layer of the SWAP
network, we swap the last two output qubits with the
first two output qubits controlled on the most significant
input qubit being 1.
In general, the SELECTSWAP network requires a T-
depth of
2n−l+l(1)
and a qubit count of
m×2l(2)
where nis the number input qubits, lis the number of
swap qubits and mis number of qubits required to store
the output f(x)in a fixed-point register.
So far we have described our SELECTSWAP net-
work using inputs and outputs of binary qubit registers.
However we would like to abstract the binary qubit
regsiter to a fixed-point qubit register. Q# has an in-
built fixed point register structure which readily takes
care of the conversions between binary and fixed-point
qubit registers. That in addition to Q# having some
readily available operations in its in-built libraries (e.g.
MultiplexOperations) allowed us to implement the fixed-
point SELECTSWAP operation in fewer than 100 lines of
code.
B. Using the fixed-point implementation of a LUT to
implement quantum arithmetic functions
The SELECTSWAP operation from the previous sec-
tion requires the user to input the number of qubits
in the input and output fixed-point register, as well
as the binary values of each of the desired outputs.