0% found this document useful (0 votes)
141 views8 pages

Quantum Risk Analysis PDF

Uploaded by

Sergio Porta
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)
141 views8 pages

Quantum Risk Analysis PDF

Uploaded by

Sergio Porta
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/ 8

www.nature.

com/npjqi

ARTICLE OPEN

Quantum risk analysis


1
Stefan Woerner and Daniel J. Egger1

We present a quantum algorithm that analyzes risk more efficiently than Monte Carlo simulations traditionally used on classical
computers. We employ quantum amplitude estimation to price securities and evaluate risk measures such as Value at Risk and
Conditional Value at Risk on a gate-based quantum computer. Additionally, we show how to implement this algorithm and how to
trade-off the convergence rate of the algorithm and the circuit depth. The shortest possible circuit depth—growing polynomially in
the number of qubits representing the uncertainty—leads to a convergence rate of O(M−2/3), where M is the number of samples.
This is already faster than classical Monte Carlo simulations which converge at a rate of O(M−1/2). If we allow the circuit depth to
grow faster, but still polynomially, the convergence rate quickly approaches the optimum of O(M−1). Thus, for slowly increasing
circuit depths our algorithm provides a near quadratic speed-up compared to Monte Carlo methods. We demonstrate our
algorithm using two toy models. In the first model we use real hardware, such as the IBM Q Experience, to price a Treasury-bill
(T-bill) faced by a possible interest rate increase. In the second model, we simulate our algorithm to illustrate how a quantum
computer can determine financial risk for a two-asset portfolio made up of government debt with different maturity dates. Both
models confirm the improved convergence rate over Monte Carlo methods. Using simulations, we also evaluate the impact of
cross-talk and energy relaxation errors.
npj Quantum Information (2019)5:15 ; https://doi.org/10.1038/s41534-019-0130-6

INTRODUCTION It has already been shown how AE can be used to price financial
Risk management plays a central role in the financial system. derivatives with the Black–Scholes model.13,14
Value at risk (VaR),1 a quantile of the loss distribution, is a widely In this article, we extend the use of AE to the calculation of
used risk metric. For example the Basel III regulations require variance, VaR and CVaR of random distributions. Furthermore, we
banks to perform stress tests using VaR.2 A second important risk develop methods to implement AE on actual hardware and we
metric is conditional value at risk (CVaR, sometimes also called discusses how to construct the corresponding quantum circuits to
expected shortfall), defined as the expected loss for losses greater calculate the expected value, variance, VaR and CVaR of random
than VaR. By contrast to VaR, CVaR is more sensitive to extreme variables. Therefore making AE a powerful tool for risk manage-
events in the tail of the loss distribution. ment and security pricing. We illustrate our algorithm using
Monte Carlo simulations are the method of choice to determine portfolios made up of debt issued by the United States Treasury
VaR and CVaR of a portfolio.1 They are done by building a model (US Treasury). As of December 2016 the US Treasury had 14.5
of the portfolio assets and computing the aggregated value for M trillion USD in outstanding marketable debt held by the public.15
different realizations of the model input parameters. VaR This debt is an actively traded asset class with typical daily
calculations are computationally intensive as the width of the volumes close to 500 billion USD16 and is regarded as high quality
collateral.17 government debt typically lacks some of the more
confidence interval scales as O(M−1/2). Many different runs are
complex features that other types of fixed-income securities have.
needed to achieve a representative distribution of the portfolio
These features make US Treasuries a highly relevant asset class to
value. Classical attempts to improve the performance are variance
study while allowing us to use simple models to illustrate our
reduction or Quasi-Monte Carlo techniques.3–5 The first aims at
algorithm. We demonstrate AE on a real quantum computer by
reducing the constants while not changing the asymptotic scaling; approximating the expected value of a very simple portfolio made
whereas, the latter improves the asymptotic behavior, but only up of one T-Bill, a short-term debt obligation issued by the US
works well for low-dimensional problems. Treasury, analyzed on a single period of a binomial tree. We also
Quantum computers process information using the laws of show a more comprehensive two-asset portfolio and simulate the
quantum mechanics.6 This has opened up novel ways of presented algorithms assuming a perfect as well as a noisy
addressing some problems, e.g. in quantum chemistry,7 optimiza- quantum computer.
tion,8 or machine learning.9 Problems in finance that make use of
machine learning may benefit from quantum machine learning.10
A quantum computer may also be used to optimize the risk-return
RESULTS
of portfolios and sample from the optimal portfolio.11 Amplitude
estimation (AE) is a quantum algorithm used to estimate an Amplitude estimation,12 formally introduced in Supplementary
unknown parameter and converges as O(M−1), which is a Information, allows us to estimate a in the state Aj0inþ1 ¼
pffiffiffiffiffiffiffiffiffiffiffi pffiffiffi
quadratic speed-up over classical algorithms like Monte Carlo.12 1  ajψ0 in j0i þ ajψ1 in j1i for an operator A acting on n + 1

1
IBM Research - Zurich, Rueschlikon 8803, Switzerland
Correspondence: Stefan Woerner ([email protected])

Received: 4 July 2018 Accepted: 16 January 2019

Published in partnership with The University of New South Wales


S. Woerner and D.J. Egger
2
qubits. AE uses m additional sampling qubits and Quantum Phase to get
Estimation18 to produce an estimator a ~ ¼ sin2 ðyπ=MÞ of a, where
lα X lα
i
y ∈ {0, …, M − 1} and M, the number of samples, is 2m. The CVaRα ðXÞ ¼ pi : (6)
~ satisfies
estimator a P½X  lα  i¼0 lα
π π2    
~j  þ 2 ¼ O M1 ;
ja  a (1) We also multiplied by lα, otherwise we would estimate CVaRα X
lα .
M M
with probability of at least 8/π2. This represents a quadratic speed- Even though we replace P½X  lα  by an estimation, the error
up compared to the O(M−1/2) convergence rate of classical Monte bound on CVaR, see Supplementary Information, still achieves a
Carlo methods.1 quadratic speed-up compared to classical Monte Carlo methods.
To use AE to estimate quantities related to a random variable X We have shown how to choose f to calculate the expected
we must first represent X as a quantum state. Using n qubits we value, variance, VaR and CVaR of a random variable X represented
map X to the interval {0, …, N − 1}, where N = 2n. X is then by jψin . However, we are usually interested in E½f ðXÞ for a more
represented by the state general function f:{0, …, N − 1} → {0, …, N′ − 1}, N0 ¼ 2n0 , n0 2 N,
for instance representing some payoff or loss depending on X. In
X
N1
pffiffiffiffi X
N1
some cases, as shown later, we can adjust F accordingly. In other
Rj0in ¼ jψin ¼ pi jiin with pi ¼ 1 (2) cases, we can apply a corresponding operator ji in j0in0 7!ji in jf ðiÞin0
i¼0 i¼0
and use the previously introduced algorithms on the second
created by the operator R. Here pi ∈ [0, 1] is the probability of register. There exist numerous quantum algorithms for arithmetic
measuring the state jiin and i ∈ {0, …, N − 1} is one of the N operations21–25 as well as tools to translate classical logic into
possible realizations of X. Next, we consider a function f:{0, …, N − quantum circuits.26,27
1} → [0, 1] and a corresponding operator
pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi pffiffiffiffiffiffiffi 
F : ji in j0i7!ji in 1  f ðiÞj0i þ f ðiÞj1i ; (3) Quantum circuits
We now show how the previously discussed algorithms can be
for all i ∈ {0, …, N − 1}, acting on an ancilla qubit. Applying F to mapped to quantum circuits. We start with the construction of
1234567890():,;

jψin j0i yields jψin , see Eq. (2), representing the probability distribution of X. In
X
N1 pffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi X
N1 pffiffiffiffiffiffiffi general, the best known upper bound for the number of gates
pffiffiffiffi pffiffiffiffi
1  f ðiÞ pi jiin j0i þ f ðiÞ pi jiin j1i: required to create jψin is O(2n).28 However, approximations with
i¼0 i¼0 polynomial complexity in n are possible for many distributions,
With AE we approximate the probability of measuring j1i in the e.g., log-concave distributions.29
PN1 Approximating E½X using AE requires the operator F corre-
last qubit, which equals i¼0 pi f ðiÞ ¼ E½f ðXÞ. AE can be used to
sponding to f(x) = x/(N − 1), defined in Eq. (3). In general,
approximate the expected value of a random  variable.19,20 By
representing F for the expected value or for the CVaR either
choosing f(i) = i/(N − 1) we estimate E N1 and hence E½X. If we
X
requires an exponential O(2n) number of gates or additional
choose f(i) = i2/(N − 1)2 we can efficiently estimate E½X 2  and ancillas to pre-compute the (discretized) function f into qubits,
obtain the variance VarðXÞ ¼ E½X 2   E½X2 . using quantum arithmetic, before applying the rotation.30 The
We now extend this technique to risk measures such as VaR and exact number of ancillas depends on the desired accuracy of the
CVaR. For a given confidence level α ∈ [0, 1], VaRα(X) is the smallest approximation of F. Another approach consists of piecewise
value x ∈ {0, …, N − 1} such that P½X  x  ð1  αÞ. To find polynomial approximations of f.31 However, this also implies a
VaRα(X) on a quantum computer, we define the function fl(i) = 1 if significant overhead in terms of the number of ancillas and gates.
i ≤ l and fl(i) = 0 otherwise, where l ∈ {0, …, N − 1}. Applying Fl, the In the following, we show how to overcome these hurdles by
operator corresponding to fl, to jψin j0i produces approximating F without ancillas using polynomially many gates,
X X at the cost of a lower—but still faster than classical—rate of
N1
pffiffiffiffi l
pffiffiffiffi
pi ji in j0i þ pi ji in j1i: (4) convergence. Note that the operator required for estimating VaR is
i¼lþ1 i¼0 easier to construct and we can always achieve the optimal rate of
convergence as discussed later in this section.
The probability of measuring j1i for the last qubit is
Pl Our contribution rests on the fact that an operator mapping
i¼0 pi ¼ P½X  l. Therefore, with a bisection search over l we j x in j0i to j x in ðcosðζðxÞÞj0i þ sinðζðxÞÞj1iÞ, for a given polynomial
find the smallest level lα such that P½X  lα   1  α in at most n P
ζðxÞ ¼ kj¼0 ζ j x j of degree k, can be efficiently constructed using
steps. The smallest level lα is equal to VaRα(X). This estimation of
VaRα(X) has accuracy O(M−1), i.e. a quadratic speed-up compared multi- controlled Y-rotations. Single qubit operations with n − 1
to classical Monte Carlo methods (omitting the additional control qubits can be exactly constructed, e.g., using O(n) gates
logarithmic complexity of the bisection search). and O(n) ancillas or O(n2) gates without any ancillas. They can also
CVaRα(X) is the conditional expectation of X restricted to {0, …, be approximated with accuracy ϵ > 0 using Oðn logð1=ϵÞÞ gates.32
lα}, where we compute lα = VaRα(X) as before. To estimate CVaR we For simplicity, we use O(n) gates and O(n) ancillas. Since the binary
apply the operator F corresponding to the function f ðiÞ ¼ liα  flα ðiÞ variable representation of ζ, leads to at most nk terms, the
corresponding operator can be constructed using O(nk+1) gates
to jψin j0i to create
! and O(n) ancillas. An example for a second order polynomial is
P pffiffiffiffi
N1 Plα qffiffiffiffiffiffiffiffiffiffiffipffiffiffiffi shown in Supplementary Information.
pi jiin þ 1  lα pi ji in j0i
i
For every analytic function f, there exists a sequence of
i¼lα þ1 i¼0
(5) polynomials such that the approximation error converges
Plα qffiffiffipffiffiffiffi exponentially fast to zero with increasing degree of the
þ lα pi ji in j1i:
i
polynomials.33 Thus, for simplicity, we assume that f is a
i¼0
polynomial of degree s.
The probability of measuring j1i for the ancilla, approximated If we can find a polynomial ζ(y) such that sin2 ðζðyÞÞ ¼ y, then
Pα i Plα
using AE, equals li¼0 lα pi . However, since i¼0 pi does not sum we can set y = f(x), and the previous discussion provides a way to
up to one but to P½X  lα , as evaluated during the VaR construct the operator F. Since  the expected
 value is linear, we
estimation, we must normalize the probability of measuring j1i may choose to estimate E c f ðXÞ  12 þ 12 instead of E½f ðXÞ for a

npj Quantum Information (2019) 15 Published in partnership with The University of New South Wales
S. Woerner and D.J. Egger
3
parameter c ∈ (0, 1], and then map the result back to an estimator level α, a bisection search can find the smallest lα such that P½X 
for  E½f ðXÞ.
 The rationale behind this choice is that lα   α in at most n steps, and we get lα = VaRα(X).
π
sin

2
y þ 4 1 ¼ y þ 12 þ Oðy 3 Þ. Thus, we want to find ζ(y) such that

To estimate the CVaR, we apply the circuit Fl for lα to an ancilla
c y  2 þ 2 is sufficiently well approximated by sin2 cζðyÞ þ π4 .
1 qubit and use this ancilla qubit as a control for the operator F used
Setting the two terms equal and solving for ζ(y) leads to to estimate the expected value, but with a different normalization,
sffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi

! ! as shown in Eq. (5). Based on the previous discussion, it follows
1 1 1 1 π that AE can then be used to approximate CVaRα(X) with the same
ζðyÞ ¼ sin c y þ  ; (7) trade-off between circuit depth and convergence rate as for the
c 2 2 4
expected value.
and we choose ζ(y) as a Taylor approximation of Eq. (7) around y
= 1/2. Note that Eq. (7) defines an odd function around y = 1/2, T-Bill on a single period binomial tree
and thus the even terms in the Taylor series equal zero. The Taylor Our first model consists of a zero coupon bond discounted at an
approximation of order 2u + 1 leads to a maximal approximation interest rate r. See Supplementary Information for an introduction
error for Eq. (7) of to the financial concepts used in this article. We seek to find the
c2uþ3 value of the bond today given that in the next time step there
þ Oðc2uþ5 Þ; (8) might be a δr rise in r. The value of the bond today, with face value
2ð2u þ 3Þ
VF, i.e. the amount of money the bond holder receives when the
for all y ∈ [0, 1], as shown in Supplementary Information. bond matures, is
Now we consider the resulting polynomial ζ(f(x)) of order s(2u +
1). The number of gates required to construct the corresponding ð1  pÞVF pVF
V¼ þ ¼ ð1  pÞVlow þ pVhigh ; (12)
circuit scales as O(ns(2u+1)+1). The smallest scenario of interest is s 1 þ r þ δr 1 þ r
= 1 and u = 0, i.e., both, f and ζ, are linear functions, which leads where p and (1 − p) denote the probabilities of a constant interest
to a circuit for F where the number of gates scales quadratically rate and a rise, respectively. This model is the first step of a
with respect to the number of qubits
 n representing
  jψin . binomial tree. Binomial trees can be used to price securities with a
Thus, using AE to estimate E c f ðxÞ  12 þ 12 leads to a maximal path dependency such as bonds with embedded options.34
error The simple scenario in Eq. (12) could correspond to a market
π c2uþ3   participant who bought a 1 year T-bill the day before a Federal
þ þ O c2uþ5 þ M2 ; (9) Open Markets Committee announcement and expects a δr =
M 2ð2u þ 3Þ
0.25%-points increase of the Federal Funds Rate with a (1 − p) =
where we ignore the higher order terms in the following. Since 70% probability and no change with a p = 30% probability.
our estimation uses cf(x), we also need to analyze the scaled error We show how to calculate the value of the investor’s T-bill by
cϵ, where ϵ>0 denotes the resulting estimation error for E½f ðXÞ. running AE on the IBM Q Experience and mapping V to [0, 1] such
Setting Eq. (9) equal to cϵ and reformulating it leads to that Vlow and Vhigh correspond to $0 and $1, respectively.
c2uþ3 π Here, we only need a single qubit to represent the uncertainty
cϵ  ¼ : y ðθp Þ, a Y-rotation of angle
pffiffiffi and we have A ¼pRffiffiffiffiffiffiffiffiffiffiffi
(10) and the objective
2ð2u þ 3Þ M pffiffiffi
θp ¼ 2 sin1 p , and thus, Aj0i ¼ 1  pj0i þ pj1i.
Maximizing the left-hand-side with respect to c, i.e. minimizing the AE requires applying exponentials of an operator Q derived
number of required samples M to achieve a target error ϵ, results from A. For the single qubit case Q = Ry(2θp). This implies Qj =
in c ¼ ð2ϵÞ1=ð2uþ2Þ . Plugging c* into Eq. (10) gives Ry(j2θp), which allows us to construct the AE circuit efficiently to

approximate the parameter p ¼ E½X ¼ 30%.
1 1 1 π
22uþ2 1  ϵ1þ2uþ2 ¼ : (11) Although a single period binomial tree is a very simple model, it
2u þ 3 M
is straight-forward to extend it to multi-period multi-nomial trees
Translating this into a rate of convergence for the estimation error with path-dependent assets. Thus, it represents the smallest
ϵ with2uþ2respect
 to the number of samples M leads to ϵ ¼ building block for interesting scenarios of arbitrary complexity.
O M2uþ3 : For u = 0, we get O(M−2/3), which is already better We run several experiments on read quantum hardware in
than the classical convergence rate of O(M−1/2). For increasing u, which we apply AE with a different number of evaluation qubits
the convergence rate quickly approaches the optimal rate of O m = 1, 2, 3, 4 corresponding to M = 2, 4, 8, 16 samples,
(M−1). respectively, to estimate p ¼ E½X. This requires at most five
For
 the  estimation of the expectation we exploited qubits and can be run on the IBM Q 5 Yorktown (ibmqx2) quantum
sin2 y þ π4  y þ 12, for small |y|. For the variance we apply the processor.35 Since the success probability of AE is larger than 8/π2
same idea but use sin2 ðyÞ h y 2 . We
i employ this approximation to
we would in principle only need, for instance, 24 repetitions to
achieve a success probability of 99.75%.36 However, current
estimate the value of E f ðXÞ2 and then, together with the
h i quantum hardware introduces additional errors. Therefore, we
estimation for E½f ðXÞ, we evaluate Varðf ðXÞÞ ¼ E f ðXÞ2 repeat every circuit 8192 times (i.e., the maximal number of shots
in the IBM Q Experience) to get a reliable estimate. We distinguish
E  ½f ðXÞ 2. The resulting convergence rate is again equal to between the number of repetitions required by the imperfections
O M2uþ3 .
2uþ2
of the hardware and the convergence rate of our algorithm. We
The previous discussion shows how to build quantum circuits to thus consider the 8192 repetitions as a constant overhead, which
estimate E½f ðXÞ and Var(f(X)) more efficiently than possible we ignore when comparing the quantum and classical algorithms.
classically. In the following, we extend this to VaR and CVaR. The quantum circuit for m = 3 compiled to the IBM Q 5 quantum
Suppose the state jψin corresponding to the random variable X processor is illustrated in Fig. 1. The connectivity of the IBM Q 5
on {0, …, N − 1} and a fixed l ∈ {0, …, N − 1}. To estimate VaR, we quantum processor, shown in Supplementary Information,
need an operator Fl that maps j x in j0i to j x in j1i if x ≤ l and to requires swapping two qubits in the middle of the circuit between
j x in j0i otherwise, for all x ∈ {0, …, N − 1}. Then, for the fixed l, AE the application of the controlled Q operators and the inverse
can be used to approximate P½X  l, as shown in Eq. (5). With (n Quantum Fourier Transform. The results of the algorithm are
+ 1) ancillas, adder-circuits can be used to construct Fl using O(n) illustrated in Fig. 2a where it can be seen that the most frequent
gates,23 and the resulting convergence rate is O(M−1). For a given estimator approaches the real value p and how the resolution of

Published in partnership with The University of New South Wales npj Quantum Information (2019) 15
S. Woerner and D.J. Egger
4

Fig. 1 AE circuit for the T-Bill problem with m = 3. Dashed boxes highlight from left to right: the controlled Q operators, the swap of two
qubits, and the inverse Quantum Fourier Transform (QFT). The swap is needed to overcome the limited connectivity of the chip. U2 and U3,
formally introduced in Supplementary Information, indicate single qubit rotations where the parameters are omitted. Note that the circuit
could be further optimized, e.g., the adjoint CNOT gates at the beginning of the SWAP would cancel out, but we kept them for illustration

the algorithm increases with m. The quantum algorithm presented


in this paper outperforms the Monte Carlo method already for M
= 16 samples (i.e. m = 4 evaluation qubits), which is the largest
scenario we performed on the real hardware, see Fig. 2b. The
details of this convergence analysis are discussed in Supplemen-
tary Information.

Two-asset portfolio
We now illustrate how to use our algorithm to calculate the daily
risk in a portfolio made up of 1-year US Treasury bills and 2-year
US Treasury notes with face values VF1 and VF2 , respectively. We
chose a simple portfolio in order to put the focus on the AE
algorithm applied to VaR. The portfolio is worth
VF1 X
4
rc VF2 VF 2
Vðr1 ; r2 Þ ¼ þ þ ; (13)
1 þ r1 i¼1 ð1 þ r2 =2Þi ð1 þ r2 =2Þ4
where rc is the annual coupon rate, i.e. the annual interest
payment that the bondholder receives divided by the face value
of the bond, paid every 6 months by the 2-year treasury note and
r1 and r2 are the yield to maturity of the 1-year bill and 2-year note,
respectively.
US Treasuries are usually assumed to be default free.37 The
cash-flows are thus known ex ante and the changes in the interest
rates are the primary risk factors. Therefore, a proper under-
standing of the yield curve, i.e. the yield of bonds versus their
maturity, suffices to model the risk in this portfolio. We use the
Constant Maturity Treasury (CMT) rates to model the uncertainty
in r1 and r2. To calculate the daily risk of our portfolio we study the
difference in the CMT rates from 1 day to the next. These
differences are highly correlated (as are the initial CMT rates), see
Fig. 3a, making it unnecessary to model them all when simulating
more complex portfolios. A principal component analysis reveals
that the first three principal components, named shift, twist and
butterfly account for 96% of the variance,38,39 see Fig. 3b, c.
Therefore, when modeling a portfolio of US Treasury securities it
suffices to study the distribution of these three factors. This
dimensionality reduction also lowers the amount of resources
Fig. 2 a Results of running AE on real hardware for m = 1, …, 4 with needed by our quantum algorithm.
8192 shots each. Therefore, the error bars on the histograms are
pffiffiffiffiffiffiffiffiffiffi To study the daily risk in the portfolio we write ri = ri,0 + δri for i
1= 8192 and not shown. The green bars indicate the probability of = 1, 2, where ri,0 is the yield to maturity observed today and the
the most frequent estimate and the blue bars the probability of the random variable δri follows the historical distribution of the 1 day
other estimates. The red dashed lines indicate the target value of
30%. The gray dashed lines show the probability of the second most changes in the CMT rate with maturity i. For our demonstration we
frequent value to highlight the resulting contrast. The possible set VF1 ¼ VF2 ¼ $100, r1,0 = 1.8%, r2,0 = 2.25%, and rc = 2.5% in Eq.
values are not equally distributed on the x-axis, since AE first returns (13). We perform a principal component analysis of δr1 and δr2
a number   y ∈ {0, …, M − 1} that is then classically mapped to and retain only the shift S and twist T components. Figure 3d
~ ¼ sin2 yπ
a M . b Comparison of the convergence of the error of Monte
illustrates the historical data as well as S and T, related to δri by
Carlo simulation and our algorithm with respect to the number of


δr1 S 0:703 0:711 S


samples M. Although the quantum algorithm starts with a larger ¼W ¼ : (14)
estimation error, for M ≥ 16 (m ≥ 4) the better convergence rate of δr2 T 0:711 0:703 T
the quantum algorithm takes over and the error stays below the The correlation coefficient between shift and twist is −1%. We
Monte Carlo results. The blue solid line shows the error for our real
experiments using up to m = 4 evaluation qubits. The blue dashed thus assume them to be independent and fit discrete distributions
line shows how the estimation error would further decrease for to each separately. We retained only the first two principal
experiments with m = 5, 6 evaluation qubits, respectively components to illustrate the use of principal component analysis

npj Quantum Information (2019) 15 Published in partnership with The University of New South Wales
S. Woerner and D.J. Egger
5

Fig. 3 Daily change in the CMT rates. a Correlation matrix. The high correlation between the rates can be exploited to reduce the dimension
of the problem. b Shift, Twist, and Butterfly components expressed in terms of the original constant maturity treasury rates. c Eigenvalues of
the principal components. The numbers show the cumulative explained variance. d Historical constant maturity treasury rates (1-year against
2-years to maturity) as well as the resulting principal components: shift (longer vector), and twist (shorter vector). e 8-bin histogram of
historical shift data (bars) as well as fitted distribution (dashed line). f 4-bin histogram of historical twist data (bars) as well as fitted distribution
(dashed line). In both cases the labels show the quantum state that will occur with the corresponding probability. g, h show the quantum
circuits used to load the distributions of e, f, respectively, into the quantum computer

despite the fact that, in this example, there is no dimensionality Higher order expansions, e.g. convexity could be considered at the
reduction. Furthermore, this allows us to simulate our algorithm in cost of increased circuit depth.
a reasonable time on classical hardware by keeping the number of To map the approximated value of the  portfolio ~f to
 a functionf
required qubits low. We expect that all three components would with target set [0, 1] we compute f ¼ f  fmin = ~fmax  ~fmin ,
~ ~
be retained when running this algorithm on real quantum
hardware for larger portfolios. where ~fmin ¼ ~f ð7; 3Þ and ~fmax ¼ ~f ð0; 0Þ, i.e., the minimum and
To model the uncertainty in the quantum computer we use maximum values ~f can take for the considered values of x ∈ {0, …,
three qubits, denoted by q0, q1, q2, to represent the distribution of 7} and y ∈ {0, …, 3}. This leads to
S, and two, denoted by q3, q4, for T. Following Eq. (2), the
f ðx; yÞ ¼ 1  0:1349x  0:0186y: (18)
probability distributions are encoded by the states jψS i ¼
P7 pffiffiffiffiffiffiffi P3 pffiffiffiffiffiffiffi Polynomial approximations allow us to construct an operator F
i¼0 pi;S ji i3 and jψT i ¼ i¼0 pi;T ji i2 for S and T, which can
corresponding to f for a given scaling parameter c ∈ (0, 1].
thus take eight and four different values, respectively. We use
We simulate the two-asset portfolio assuming an ideal quantum
more qubits for S than for T since the shift explains a larger part of
computer for different numbers m of sampling qubits to show the
the variance. Additional qubits may be used to represent the
behavior of the accuracy and convergence rate. We repeat this
probability distributions at a higher resolution. The qubits
task twice, once for a processor with all-to-all connectivity and
naturally represent integers via binary encoding and we apply
once for a processor with a connectivity corresponding to the IBM
the affine mappings
Q 20 Tokyo, https://quantumexperience.ng.bluemix.net/qx/
S ¼ 0:0626x  0:2188; (15) devices, accessed: 2018-05-22. chip, see Supplementary Informa-
tion. This highlights the overhead imposed by a realistic chip
T ¼ 0:0250 y  0:0375: (16) connectivity. For a number M = 2m samples, we need a total of m
+ 12 qubits for expected value and VaR, and m + 13 qubits for
Here x ∈ {0, …, 7} and y ∈ {0, …, 3} denote the integer CVaR. Five of these qubits are used to represent the distribution of
representations of S and T, respectively. Given the almost perfect the interest rate changes, one qubit is needed to create the state
symmetry of the historical data we fit symmetric distributions to it. in Eq. (3) used by AE, and six ancillas are needed to implement the
The operator R that we define prepares a quantum state Rj0i5 , controlled Q operator. For CVaR we need one more ancilla for the
illustrated by the dots in Fig. 3e, f, that represents the distributions comparison to the level l. Once the shift and twist distributions are
of S and T, up to the aforementioned affine mapping. loaded into the quantum computer, using the circuit shown in Fig.
Next, we show how to construct the operator F to translate the 3g, h, we apply the operator F to create the state defined in Eq. (3).
random variables x and y into a portfolio value. Equations (13) We compare the quantum estimation of risk to the exact 95%
through (16) allow us to define the portfolio value V in terms of x VaR level of $0.288. Based on Eq. (18), this classical VaR
and y, instead of r1 and r2. For simplicity, we use a first order corresponds to 0.093, shown by the verticle line in Fig. 4. The
approximation quantum estimation of risk rapidly approaches this value as m is
~f ðx; yÞ ¼ 203:5170  13:1896x  1:8175y (17) increased, Fig. 4. With m = 5 sample qubits the difference
between the classical and quantum estimates is 9%. The number
of V around the mid points x = 3.5 and y = 1.5. From a financial of CNOT gates needed to calculate VaR approximately doubles
perspective, the first order approximation ~f of V corresponds to each time a sample qubit is added, see Table 1, i.e. it scales as O
studying the portfolio from the point of view of its duration.40 (M) with a resulting error of O(M−1). We find that the connectivity

Published in partnership with The University of New South Wales npj Quantum Information (2019) 15
S. Woerner and D.J. Egger
6

Fig. 4 VaR estimated through a simulation of a perfect quantum


computer. As the number of sample qubits m is increased the
quantum estimated VaR approaches the classical value indicated by
the vertical blue line. The dashed lines are intended as guides to the
eye. The stars indicate the most probable values

Table 1. Summary of the number of CNOT gates to estimate VaR as a


function of m for a processor architecture featuring an all-to-all qubit
connectivity and an architecture with a qubit connectivity
corresponding to the IBM Q 20 Tokyo chip with 20 qubits

#CX
m M #qubits all-to-all IBM Q 20 Overhead
Tokyo

1 2 13 795 1773 2.23


2 4 14 2225 4802 2.16
3 8 15 5085 11,821 2.32 Fig. 5 Results from noisy simulation for estimating the expected
4 16 16 10,803 24,811 2.30 value of the two-asset portfolio using two evaluation qubits. The
5 32 17 22,235 52,096 2.34
perfect simulation returns 0.5 with 100%. This figure shows how the
probability of measuring 0.5 decreases with increasing noise: a
shows the results for both, increasing cross-talk and increasing
of the IBM Q 20 Tokyo chip increases the number of CNOT gates relaxation rate, b shows the result for varying relaxation rate without
by a factor 2.3 when compared to a chip with all-to-all cross-talk, and c shows the result for different cross-talk strengths
without relaxation. The dashed red lines indicate the estimated state
connectivity. of the currently available hardware
Computing the expected value or risk measures for the two-
asset portfolio requires a long circuit. However, it suffices for AE to We illustrate the effect of these errors by computing the
return the correct state with the highest probability, i.e.
expected value of the portfolio. Since the distributions are
measurements do not need to yield this state with 100%
symmetric around zero and mapped to the interval [0, 1] we
probability. We now run simulations with errors to investigate
expect a value of 0.5, i.e. from one day to the next we do not
how much imperfections can be tolerated before the correct state
can no longer be identified. expect a change in the portfolio value. This simulation is run with
We study the effect of two types of errors: energy relaxation and m = 2 sample qubits since this suffices to exactly estimate 0.5. The
cross-talk, where the latter is only considered for two-qubit gates algorithm is successful if it manages to identify 0.5 with a
(CNOT gates). We believe this captures the leading error sources. probability >50%. With our error model this is achieved for
Errors and gate times for single qubit gates are in general an order relaxation rates γ < 10−4 s−1 and cross-talk strength |α| < 1%, see
of magnitude lower than for two-qubit gates.41–43 Furthermore, Fig. 5a–c, despite the 4383 gates needed. A generous estimation
our algorithm requires the same order of magnitude in the of current hardware capabilities with γ = 10−4 s−1 (loosely based
number of single and two-qubit gates. Energy relaxation is on T1 = 100 μs) and α = −2%, shown as red lines in Fig. 5,
simulated using a relaxation rate γ such that after a time t each indicates that this simulation may be possible in the near future as
qubit has a probability 1 − exp(−γt) of relaxing to j0i.44 We set the long as other error sources (such as measurement error and
duration of the CNOT gates to 100 ns and assume that the single unitary errors resulting from improper gate calibrations) are kept
qubit gates are done instantly and are thus exempt from errors. under control.
We also include qubit–qubit cross-talk in our simulation by adding
a ZZ error-term in the generator of the CNOT gate
DISCUSSION
expfiπðZX þ αZZÞ=4g: (19) We developed a quantum algorithm to estimate risk, e.g. for
Typical cross-resonance45 CNOT gate rates are of the order of portfolios of financial assets, resulting in a quadratic speed-up
5 MHz whilst cross-talk on IBM Q chips are of the order of compared to classical Monte Carlo methods. The algorithm has
−100 kHz.43 We thus estimate a reasonable value of α, i.e. the been demonstrated on real hardware for a small model and the
strength of the cross-talk, to be −2% and simulate its effect over scalability and impact of noise has been studied using a more
the range [−3%, 0%]. complex model and simulation. Our approach is very flexible and

npj Quantum Information (2019) 15 Published in partnership with The University of New South Wales
S. Woerner and D.J. Egger
7
straight-forward to extend to other risk measures, such as semi- ADDITIONAL INFORMATION
variance. Supplementary Information accompanies the paper on the npj Quantum
More qubits are needed to model realistic scenarios and the Information website (https://doi.org/10.1038/s41534-019-0130-6).
errors of actual hardware need to be reduced. Although the
Competing interests: The authors declare no competing interests.
quadratic speed-up can already be observed for a small number of
samples, more is needed to achieve a practical quantum
Publisher’s note: Springer Nature remains neutral with regard to jurisdictional claims
advantage. In practice, Monte Carlo simulations can be massively
in published maps and institutional affiliations.
parallelized, which pushes the border for a quantum advantage
even higher.
Our simulations of the two-asset portfolio show that circuit REFERENCES
depth is limited for current hardware. In order to perform the 1. Glasserman, P., Heidelberger, P. & Shahabuddin, P. Efficient Monte Carlo Methods
calculation of VaR for the two-asset portfolio on real quantum for Value-at-Risk. In Mastering Risk 2, 5–18 (2000).
hardware it is likely that qubit coherence times will have to be 2. Basel Committee on Banking Supervision. Revisions to the basel ii market risk
increased by several orders of magnitude and that cross-talk will framework (2009). https://www.bis.org/publ/bcbs148.pdf.
3. Joy, C., Boyle, P. P. & Tan, K. S. Quasi-monte carlo methods in numerical finance.
have to be further suppressed.
Manag. Sci. 42, 926–938 (1996).
However, approximating, parallelizing, and decomposing quan- 4. Glasserman, P. Monte Carlo Methods in Financial Engineering. (Springer-Verlag,
tum phase estimation is ongoing research and we expect New York, 2003).
significant improvements in this area not only through hardware, 5. Glasserman, P. & Li, J. Importance sampling for portfolio credit risk. Manag. Sci.
but also algorithms.46–48 This can help shorten the required circuit 51, 11 (2005).
depths, and reduce the hardware requirements to achieve a 6. Nielsen, M. A. & Chuang, I. L. Quantum Computation and Quantum Information:
10th Anniversary Edition (Cambridge University Press, New York, NY, USA, 2011).
quantum advantage. Circuit depth can also be shortened by using
7. Peruzzo, A. et al. A variational eigenvalue solver on a photonic quantum pro-
a more versatile set of gates. For instance, the ability to implement cessor. Nat. Commun. 5, 4213 (2014).
SWAP gates directly in hardware would circumvent the need to 8. Moll, N. et al. Quantum optimization using variational algorithms on near-term
synthesize them using CNOT gates.49,50 In addition, techniques quantum devices. Quantum Sci. Technol. 3, 030503 (2018).
such as error mitigation51 could be applied to cope with the noisy 9. Biamonte, J. et al. Quantum machine learning. Nature 549, 195–202 (2017).
hardware of the near future. 10. Orus, R., Mugel, S. & Lizaso, E. Quantum computing for finance: overview and
prospects, https://arxiv.org/abs/1807.03890 (2018).
Another question that has only briefly been addressed in this
11. Rebentrost, P. & Lloyd, S. Quantum computational finance: quantum algorithm
paper is the loading of considered random distributions or for portfolio optimization, https://arxiv.org/abs/1811.03975 (2018).
stochastic processes. For auto-correlated processes this can be 12. Brassard, G., Hoyer, P., Mosca, M. & Tapp, A. Quantum amplitude amplification
rather costly and needs to be further investigated. Techniques and estimation. Contemporary Mathematics 305, https://doi.org/10.1090/conm/
known from classical Monte Carlo, such as importance sampling,52 305 (2002).
might be employed here as well to improve the results or reduce 13. Black, F. & Scholes, M. The pricing of options and corporate liabilities. J. Political
Econ. 81, 637–654 (1973).
the circuit depth.
14. Rebentrost, P., Gupt, B. & Bromley, T. R. Quantum computational finance: Monte
carlo pricing of financial derivatives. Phys. Rev. A. 98, 022321 (2018).
15. The Bureau of the fiscal service. Monthly statment of the public debt of the
METHODS united states (2017).
The code to run real experiment and simulations was written using the 16. Federal reserve bank of New York. US Treasury Trading Volume (2016).
Qiskit framework.44 Qiskit also provides access to the used quantum 17. Federal Reserve Bank of New York. Federal reserve collateral guidelines (2018).
hardware as well as the simulator. 18. Kitaev, A. Y. Quantum measurements and the Abelian Stabilizer Problem,
arXiv:9511026 (1995).
19. Abrams, D. S. & Williams, C. P. Fast quantum algorithms for numerical integrals
Code availability
and stochastic processes, arXiv:9908083 (1999).
The code used for amplitude estimation is available open source in Qiskit 20. Montanaro, A. Quantum speedup of monte carlo methods. Proc. R. Soc. Lond. A:
Aqua and some of the mentioned examples are available in Qiskit Mathematical, Phys. Eng. Sci. 471, http://rspa.royalsocietypublishing.org/content/
Finance.53 471/2181/20150301 (2015).
21. Vedral, V., Barenco, A. & Ekert, A. Quantum networks for elementary arithmetic
operations. Phys. Rev. A. 54, 147–153 (1996).
DATA AVAILABILITY 22. Draper, T. G. Addition on a Quantum Computer, arXiv:0008033 (2000).
In this work we use the Constant Maturity Treasury rates publicly available from the 23. Cuccaro, S. A., Draper, T. G., Kutin, S. A. & Moulton, D. P. A new quantum ripple-
U.S. Department of the Treasury.54 The data are made up of 1/4, 1/2, 1, 2, 3, 5, 7, 10, carry addition circuit, arXiv:0410184 (2004).
20 and 30 year rates resulting from an interpolation of the daily yield curve obtained 24. Draper, T. G., Kutin, S. A., Rains, E. M. & Svore, K. M. A logarithmic-depth quantum
from the bid yield of actively traded treasury securities at market close. We only carry-lookahead adder. Quantum Inf. Comput. 6, 351–369 (2006).
25. Bhaskar, M. K., Hadfield, S., Papageorgiou, A. & Petras, I. Quantum Algorithms and
consider periods where all rates are available and ignore the others. In total, we use
circuits for scientific computing. Quantum Inf. Comput. 16, 197–236 (2015).
more than 5000 data points. The data that support the findings of this study are
26. Green, A. S., Lumsdaine, P. L., Ross, N. J., Selinger, P. & Valiron, B. Quipper: a
available from the corresponding author upon reasonable request.
scalable quantum programming language. SIGPLAN Not. 48, 333–342 (2013).
27. Green, A. S., Lumsdaine, P. L., Ross, N. J., Selinger, P. & Valiron, B. An introduction
to quantum programming in quipper. In Reversible Computation (eds Dueck, G.
ACKNOWLEDGEMENTS W. & Miller, D. M.) 110–124 (Springer Berlin Heidelberg, Berlin, Heidelberg, 2013).
We want to thank Lior Horesh for his insights and the stimulating discussions as well 28. Mottonen, M., Vartiainen, J. J., Bergholm, V. & Salomaa, M. M. Transformation of
as Shaohan Hu, Steve Wood, and Marco Pistoia for the support with migrating the quantum states using uniformly controlled rotations. Quant. Inf. Comp. 5, 4 (2004).
code to Qiskit Aqua (Finance). IBM, IBM Q, Qiskit, and Qiskit Aqua are trademarks of 29. Grover, L. & Rudolph, T. Creating superpositions that correspond to efficiently
International Business Machines Corporation, registered in many jurisdictions integrable probability distributions, arXiv:0208112 (2002).
worldwide. Other product or service names may be trademarks or service marks of 30. Mitarai, K., Kitagawa, M. & Fujii, K. Quantum analog-digital conversion,
IBM or other companies. arXiv:1805.11250 (2018).
31. Häner, T., Roetteler, M. & Svore, K. M. Optimizing quantum circuits for arithmetic,
arXiv:1805.12445 (2018).
AUTHOR CONTRIBUTIONS 32. Barenco, A. et al. Elementary gates for quantum computation. Phys. Rev. A 52,
3457–3467 (1995).
All authors researched, collated, and wrote this paper.

Published in partnership with The University of New South Wales npj Quantum Information (2019) 15
S. Woerner and D.J. Egger
8
33. Trefethen, L. N. L. N. Approximation theory and approximation practice (2013). 47. O'Loan, C. J. Iterative phase estimation. J. Phys. A: Math. Theor. 43, 015301 (2010).
34. Black, F., Derman, E. & Toy, W. A one-factor model of interest rates and its 48. Svore, K. M., Hastings, M. B. & Freedman, M. Faster phase estimation. Quantum Inf.
application to treasury bond options. Financ. Anal. J. 46, 33–39 (1990). Comput. 14, 306–328 (2014).
35. IBM Q 5 Yorktown. https://github.com/QISKit/qiskit-backend-information/blob/ 49. Egger, D. J. et al. Entanglement generation in superconducting qubits using
master/backends/yorktown/V1/README.md. Accessed on 22 May 2018. holonomic operations. Phys. Rev. Applied 11, 014017 (2019). https://link.aps.org/
36. Xu, G., Daley, A. J., Givi, P. & Somma, R. D. Turbulent mixing simulation via a doi/10.1103/PhysRevApplied.11.014017.
quantum algorithm. AIAA J. 56, 2 (2018). 50. Sjöqvist, E. Non-adiabatic holonomic quantum computation. New J. Phys. 14,
37. Nippani, S., Liu, P. & Schulman, C. T. Are treasury securities free of default? J. 103035 (2012).
Financ. Quant. Anal. 36, 251–265 (2001). 51. Kandala, A. et al. Extending the computational reach of a noisy superconducting
38. Colin, A., Cubilié, M. & Bardoux, F. A new approach to the decomposition of yield quantum processor, arXiv:1805.04492 (2018).
curve movements for fixed income attribution. J. Perform. Measurement 10, 18–28 52. Tokdar, S. T. & Kass, R. E. Importance sampling: a review. Wiley Interdiscip. Rev.:
(2006). Comput. Stat. 2, 54–60 (2010).
39. Vannerem, P. & Iyer, A. S. Assessing interest rate risk beyond duration - shift, twist, 53. Qiskit Aqua (2019). https://qiskit.org/aqua.
butterfly. MSCI Barra Res. Insights, 1–26 http://citeseerx.ist.psu.edu/viewdoc/ 54. U.S. Department of the Treasury. Daily treasury yield curve rates (2018).
download?doi=10.1.1.179.2130&rep=rep1&type=pdf (2010).
40. Martellini, L., Priaulet, P. & Priaulet, S. Fixed-Income Securities (John Wiley & Sons
Ltd, The Atrium, Southern Gate, England, 2003). Open Access This article is licensed under a Creative Commons
41. Sheldon, S., Magesan, E., Chow, J. M. & Gambetta, J. M. Procedure for system- Attribution 4.0 International License, which permits use, sharing,
atically tuning up cross-talk in the cross-resonance gate. Phys. Rev. A. 93, 060302 adaptation, distribution and reproduction in any medium or format, as long as you give
(2016). appropriate credit to the original author(s) and the source, provide a link to the Creative
42. Gustavsson, S. et al. Improving quantum gate fidelities by using a qubit to Commons license, and indicate if changes were made. The images or other third party
measure microwave pulse distortions. Phys. Rev. Lett. 110, 040502- (2013). material in this article are included in the article’s Creative Commons license, unless
43. IBM Q Experience. https://quantumexperience.ng.bluemix.net/qx/experience (2016). indicated otherwise in a credit line to the material. If material is not included in the
44. Qiskit (2019). https://qiskit.org/. article’s Creative Commons license and your intended use is not permitted by statutory
45. Rigetti, C. & Devoret, M. Fully microwave-tunable universal gates in super- regulation or exceeds the permitted use, you will need to obtain permission directly
conducting qubits with linear couplings and fixed transition frequencies. Phys. from the copyright holder. To view a copy of this license, visit http://creativecommons.
Rev. B 81, 134507 (2010). org/licenses/by/4.0/.
46. Dobšíček, M., Johansson, G., Shumeiko, V. & Wendin, G. Arbitrary accuracy
iterative quantum phase estimation algorithm using a single ancillary qubit: a
two-qubit benchmark. Phys. Rev. A. 76, 030306 (2007). © The Author(s) 2019

npj Quantum Information (2019) 15 Published in partnership with The University of New South Wales

You might also like