A Q Implementation of a Quantum Lookup Table for Quantum Arithmetic Functions Rajiv Krishnakumar

2025-04-30 0 0 718.57KB 8 页 10玖币
侵权投诉
A Q# Implementation of a Quantum Lookup Table
for Quantum Arithmetic Functions
Rajiv Krishnakumar
Core R&D
Goldman Sachs
Geneva, Switzerland
rajiv.krishnakumar@gs.com
Mathias Soeken
Microsoft Quantum
Microsoft
Z¨
urich, Switzerland
mathias.soeken@microsoft.com
Martin Roetteler
Microsoft Quantum
Microsoft
Redmond, WA, USA
martin.roetteler@microsoft.com
William Zeng
Core R&D
Goldman Sachs
New York, NY, USA
william.zeng@gs.com
Abstract—In this paper, we present Q# implementations
for arbitrary single-variabled fixed-point arithmetic op-
erations for a gate-based quantum computer based on
lookup tables (LUTs). In general, this is an inefficent
way of implementing a function since the number of
inputs can be large or even infinite. However, if the input
domain can be bounded and there can be some error
tolerance in the output (both of which are often the case
in practical use-cases), the quantum LUT implementation
of certain quantum arithmetic functions can be more
efficient than their corresponding reversible arithmetic
implementations. We discuss the implementation of the
LUT using Q# and its approximation errors. We then
show examples of how to use the LUT to implement
quantum arithmetic functions and compare the resources
required for the implementation with the current state-of-
the-art bespoke implementations of some commonly used
arithmetic functions. The implementation of the LUT is
designed for use by practitioners to use when implementing
end-to-end quantum algorithms. In addition, given its well-
defined approximation errors, the LUT implementation
makes for a clear benchmark for evaluating the efficiency
of bespoke quantum arithmetic circuits .
Index Terms—quantum, arithmetic, circuit, T-count, T-
depth, qubit
I. INTRODUCTION
The purpose of a mathematical function (within a
piece of code or even in a general sense) is to map an
input xto an output f(x)[1], [2]. When implementing
this on a computer, the most general method is to create
a lookup table (LUT)—a structure that stores all of the
possible inputs along with their corresponding outputs.
In this paper, we present a Q# [3] implementation of such
a structure for a gate-based quantum computer for fixed-
point arithmetic functions.1We focus on single variable
1https://github.com/microsoft/QuantumLibraries/pull/611
real functions i.e. f:RR. In essence, the imple-
mented LUT executes the unitary U:|xi |00 . . . 0i 7→
|xi |f(x)iwhere xand f(x)are fixed-point representa-
tions of the input and output values. At first this may
seem like an inefficent way of implementing a function
since the number of inputs can be large or even infinite.
However, if the input domain can be bounded and there
can be some error tolerance in the output (both of which
are often the case in practical use-cases), the quan-
tum LUT implementation of certain quantum arithmetic
functions can be more efficient than their corresponding
reversible arithmetic implementations. In the rest of this
paper, we will first discuss the implementation of the
LUT in Q# using the convenient built-in functions in
Q# that make the implemention well-structured, followed
by how the implementation is geared for practitioners
that are interested in implementing quantum arithmetic
operations within a larger end-to-end algorithm. We then
discuss the approximation error of the operator, which
is a key factor in enabling this implementation to be
used in end-to-end algorithms as well as a benchmark
for evaluating the efficiency of single variable bespoke
quantum arithmetic circuits. We will then show examples
of how to use the LUT to implement specific quantum
arithmetic functions and compare the resources required
for the implementation with the current state-of-the-art
bespoke implementations of the exponential, Gaussian
and square root functions.
Related work
While we compare our method to some dedicated
arithmetic implementations in the remainder, we want to
point out some related general purpose work and how it
differentiates from our work. In [4], the authors proposed
a method to implement single-variabled fixed-point arith-
metic using piecewise polynomial evaluation. In order to
arXiv:2210.11786v1 [quant-ph] 21 Oct 2022
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
2nl+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.
摘要:

AQ#ImplementationofaQuantumLookupTableforQuantumArithmeticFunctionsRajivKrishnakumarCoreR&DGoldmanSachsGeneva,Switzerlandrajiv.krishnakumar@gs.comMathiasSoekenMicrosoftQuantumMicrosoftZ¨urich,Switzerlandmathias.soeken@microsoft.comMartinRoettelerMicrosoftQuantumMicrosoftRedmond,WA,USAmartin.roettele...

展开>> 收起<<
A Q Implementation of a Quantum Lookup Table for Quantum Arithmetic Functions Rajiv Krishnakumar.pdf

共8页,预览2页

还剩页未读, 继续阅读

声明:本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。玖贝云文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知玖贝云文库,我们立即给予删除!
分类:图书资源 价格:10玖币 属性:8 页 大小:718.57KB 格式:PDF 时间:2025-04-30

开通VIP享超值会员特权

  • 多端同步记录
  • 高速下载文档
  • 免费文档工具
  • 分享文档赚钱
  • 每日登录抽奖
  • 优质衍生服务
/ 8
客服
关注