+ All Categories
Home > Documents > arXiv:2105.12087v1 [quant-ph] 25 May 2021

arXiv:2105.12087v1 [quant-ph] 25 May 2021

Date post: 16-Oct-2021
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
23
Quantum algorithm for credit valuation adjustments Javier Alcazar, 1 Andrea Cadarso, 2 Amara Katabarwa, 1 Marta Mauri, 1 Borja Peropadre, 1 Guoming Wang, 1 and Yudong Cao 1, * 1 Zapata Computing, Inc. 2 BBVA Corporate & Investment Banking, Calle Sauceda 28, 28050 Madrid, Spain Quantum mechanics is well known to accelerate statistical sampling processes over classical tech- niques. In quantitative finance, statistical samplings arise broadly in many use cases. Here we focus on a particular one of such use cases, credit valuation adjustment (CVA), and identify opportuni- ties and challenges towards quantum advantage for practical instances. To improve the depths of quantum circuits for solving such problem, we draw on various heuristics that indicate the potential for significant improvement over well-known techniques such as reversible logical circuit synthesis. In minimizing the resource requirements for amplitude amplification while maximizing the speedup gained from the quantum coherence of a noisy device, we adopt a recently developed Bayesian variant of quantum amplitude estimation using engineered likelihood functions (ELF). We perform numerical analyses to characterize the prospect of quantum speedup in concrete CVA instances over classical Monte Carlo simulations. I. INTRODUCTION Statistical simulation tasks are often the most compu- tationally expensive exercises that banks perform. One important class of such exercises is counterparty risk analysis, which has gained increasing importance in the recent years since the Great Recession in the late 2000s. In the aforementioned financial crisis, banks lost tremen- dous amount of capital in counterparty credit default during derivative transactions, which led to specific regu- lations and capital requirements. Therefore, risk analyses need to be in place to calculate the precise amounts by which the prices of the derivatives should be adjusted to hedge against the risk of counterparty default, and fall under the general term of credit valuation adjustments (CVA). In response to the credit losses during the Great Recession, the Basel Committee for Banking Supervision (BCBS) has defined regulatory requirements for CVA cal- culations [1, 50.31-50.36]. The regulation demands that CVA be calculated by simulating the stochastic paths of the underlying exposures, which is frequently carried out by Monte Carlo methods. The probabilistic nature of this process means there will be inherent statistical errors in the resulting CVA estimation. In order to sup- press such statistical errors, one must increase the num- ber of stochastic paths sampled. Therefore, a typical CVA calculation for a derivative product involves cal- culating statistical averages over a large number of price trajectories of the underlying asset(s) of the derivative as well as possible default scenarios of the counterparty. A rough estimation [2] shows that a large number of Monte Carlo samples is needed for meeting the standards laid out in Basel Committee on Banking Supervision’s July 2015 consultation document regarding CVA calculations. The stochastic simulation of the prices of the under- lying assets as they change over time is one of the key ingredients of most CVA calculations, except for cases * [email protected] where the expected exposure can be computed analyt- ically. The price fluctuation is typically described as a stochastic process, which is defined for every point in time. Simulating such a stochastic process on mod- ern digital computers introduces a discretized time grid, which introduces a discretization error D . Each simula- tion generates a concrete path of how the price(s) of the asset(s) change(s) over time, which supplies one sample in the Monte Carlo simulation for estimating the expected payoff of the financial instrument that is based on the as- set(s). The general goal of the Monte Carlo simulations in financial use cases such as CVA can be described as estimating the expectation value E[f (S)] of some func- tion f of a set of random variables S. Since one is only able to draw a finite amount of samples or paths on a computer, there is a statistical error S associated with each simulation. To estimate the expectation within ad- ditive error S , generally O(1/ 2 S ) samples are required. On a classical computer, discretization error introduces additional cost in the simulation. For a discrete approxi- mation scheme of order r on a grid of time interval Δt, the discretization error is D = Ot r ) [3]. This gives rise to an extra factor of O(1/ 1/r D ) in the cost of classical sim- ulation. However, such overhead factor can in practice be either mitigated by adopting higher order approxima- tion schemes or multi-level schemes [4]. The cost scaling of O(1/ 2 S ) with respect to statistical error S is a more fundamental artifact of statistics that is in general hard to overcome classically. The advent of quantum computing presents an excit- ing opportunity to break the barrier of the classical cost scaling with respect to statistical error. A typical strat- egy for addressing the problem of estimating E[f (S)] is by casting it as a problem of estimating an operator expectation: E[f (S)] = chψ|O|ψi for some constant c, state |ψi and operator O. The problem of estimating hψ|O|ψi can be addressed by quantum amplitude esti- mation, with which early proposals [5, 6] demonstrated that one could improve the fundamental cost scaling of parameter estimation from O(1/ 2 S ) to O(1/ S ). This is a significant improvement for applications requiring some arXiv:2105.12087v1 [quant-ph] 25 May 2021
Transcript

Quantum algorithm for credit valuation adjustments

Javier Alcazar,1 Andrea Cadarso,2 Amara Katabarwa,1 Marta

Mauri,1 Borja Peropadre,1 Guoming Wang,1 and Yudong Cao1, ∗

1Zapata Computing, Inc.2BBVA Corporate & Investment Banking, Calle Sauceda 28, 28050 Madrid, Spain

Quantum mechanics is well known to accelerate statistical sampling processes over classical tech-niques. In quantitative finance, statistical samplings arise broadly in many use cases. Here we focuson a particular one of such use cases, credit valuation adjustment (CVA), and identify opportuni-ties and challenges towards quantum advantage for practical instances. To improve the depths ofquantum circuits for solving such problem, we draw on various heuristics that indicate the potentialfor significant improvement over well-known techniques such as reversible logical circuit synthesis.In minimizing the resource requirements for amplitude amplification while maximizing the speedupgained from the quantum coherence of a noisy device, we adopt a recently developed Bayesianvariant of quantum amplitude estimation using engineered likelihood functions (ELF). We performnumerical analyses to characterize the prospect of quantum speedup in concrete CVA instances overclassical Monte Carlo simulations.

I. INTRODUCTION

Statistical simulation tasks are often the most compu-tationally expensive exercises that banks perform. Oneimportant class of such exercises is counterparty riskanalysis, which has gained increasing importance in therecent years since the Great Recession in the late 2000s.In the aforementioned financial crisis, banks lost tremen-dous amount of capital in counterparty credit defaultduring derivative transactions, which led to specific regu-lations and capital requirements. Therefore, risk analysesneed to be in place to calculate the precise amounts bywhich the prices of the derivatives should be adjusted tohedge against the risk of counterparty default, and fallunder the general term of credit valuation adjustments(CVA). In response to the credit losses during the GreatRecession, the Basel Committee for Banking Supervision(BCBS) has defined regulatory requirements for CVA cal-culations [1, 50.31-50.36]. The regulation demands thatCVA be calculated by simulating the stochastic pathsof the underlying exposures, which is frequently carriedout by Monte Carlo methods. The probabilistic natureof this process means there will be inherent statisticalerrors in the resulting CVA estimation. In order to sup-press such statistical errors, one must increase the num-ber of stochastic paths sampled. Therefore, a typicalCVA calculation for a derivative product involves cal-culating statistical averages over a large number of pricetrajectories of the underlying asset(s) of the derivative aswell as possible default scenarios of the counterparty. Arough estimation [2] shows that a large number of MonteCarlo samples is needed for meeting the standards laidout in Basel Committee on Banking Supervision’s July2015 consultation document regarding CVA calculations.

The stochastic simulation of the prices of the under-lying assets as they change over time is one of the keyingredients of most CVA calculations, except for cases

[email protected]

where the expected exposure can be computed analyt-ically. The price fluctuation is typically described asa stochastic process, which is defined for every pointin time. Simulating such a stochastic process on mod-ern digital computers introduces a discretized time grid,which introduces a discretization error εD. Each simula-tion generates a concrete path of how the price(s) of theasset(s) change(s) over time, which supplies one sample inthe Monte Carlo simulation for estimating the expectedpayoff of the financial instrument that is based on the as-set(s). The general goal of the Monte Carlo simulationsin financial use cases such as CVA can be described asestimating the expectation value E[f(S)] of some func-tion f of a set of random variables S. Since one is onlyable to draw a finite amount of samples or paths on acomputer, there is a statistical error εS associated witheach simulation. To estimate the expectation within ad-ditive error εS , generally O(1/ε2S) samples are required.On a classical computer, discretization error introducesadditional cost in the simulation. For a discrete approxi-mation scheme of order r on a grid of time interval ∆t, thediscretization error is εD = O(∆tr) [3]. This gives rise to

an extra factor of O(1/ε1/rD ) in the cost of classical sim-

ulation. However, such overhead factor can in practicebe either mitigated by adopting higher order approxima-tion schemes or multi-level schemes [4]. The cost scalingof O(1/ε2S) with respect to statistical error εS is a morefundamental artifact of statistics that is in general hardto overcome classically.

The advent of quantum computing presents an excit-ing opportunity to break the barrier of the classical costscaling with respect to statistical error. A typical strat-egy for addressing the problem of estimating E[f(S)] isby casting it as a problem of estimating an operatorexpectation: E[f(S)] = c〈ψ|O|ψ〉 for some constant c,state |ψ〉 and operator O. The problem of estimating〈ψ|O|ψ〉 can be addressed by quantum amplitude esti-mation, with which early proposals [5, 6] demonstratedthat one could improve the fundamental cost scaling ofparameter estimation from O(1/ε2S) to O(1/εS). This isa significant improvement for applications requiring some

arX

iv:2

105.

1208

7v1

[qu

ant-

ph]

25

May

202

1

2

Π

Asset price dynamics

Probability of default

Discount factor

|0⟩

|0⟩

|0⟩

a) Quantum circuit Born machine (QCBM)

b) Matrix product state based ansatz

Classical computer

Parameter optimization

Parameterized quantum circuit

MPS trainingMPS preparation circuit

Bayesian inference

Rotation circuit training

|0!"#"$ ⟩

ΠZ

|𝜉⟩

CVA = 𝑀 1 − 𝑅 𝐶!𝐶"𝐶# ⋅ ⟨𝜉|Π|𝜉⟩

Step 2: Bayesian amplitude estimation

Engineered likelihood function (ELF)

New parameter values

Controlled rotation circuit ansatz (CRCA)

Step 1: Quantum circuit

generation

|0!⟩|0"⟩

𝑥#, 𝑥$, ⋯ , 𝑥$%&#, 𝑥$%

Repeat L times

Quantum computer

ORPayoff

function

State preparation

Controlled rotation

𝐺 |0!"#⟩ = ∑$,&

(𝑠& , 𝑡$)|𝑖, 𝑗⟩

𝑅'|𝑥⟩|0⟩ = |𝑥⟩( 1 − 𝑓(𝑥)|0⟩ + 𝑓(𝑥)|1⟩)

𝐴 𝐴! 𝑒78'(9)𝑒78'(*+9 𝐴

⋯ ⋯

FIG. 1: Overview of the quantum approach to credit valuation adjustment proposed in this work. We start by inspectingthe components that make up the CVA quantity (Section II), which translate to the structure of the quantum circuit A in

Step 1. It consists of state preparation and controlled rotations (Section III). We expand on the quantum circuit constructionin Section IV, where we investigate two alternatives to the state preparation subroutine: quantum circuit Born machine

(QCBM) in Section IV.1.1 and matrix product states (MPS) in section IV.1.2. For controlled rotation, we propose controlledrotation circuit ansatz (CRCA) in Section IV.2. For both MPS and CRCA, training occurs only on the classical computerand the resulting parameters are used for constructing the quantum circuit. For QCBM, one trains the quantum circuit

iteratively between the quantum and classical computer. At this point the problem of estimating CVA is reduced toestimating the expectation of an observable Π with respect to the output state |ξ〉 = A|0n+m+3〉 of the quantum circuit A.

We then move on to Step 2 to perform the amplitude estimation using engineered likelihood functions (Appendix E).

control over the statistical error. However, the quantumadvantage is realized at a cost of running deep circuits ofdepth O(1/εS) on a quantum computer. This rendersthe early algorithms infeasible for near-term quantumdevices, which can execute circuits of only finite depth.Recently, there have been various proposals [7–10] forrealizing amplitude estimation with reduced depth cir-cuits, at a cost of less quantum speedup compared withthe quadratic advantage given by fault-tolerant quantumcomputers. A general goal of these proposals is to deriveas much asymptotic speedup as possible by using thequantum resource available on a given quantum device,even though the speedup may be less than quadratic inmany cases.

In this study, we adopt the framework of engineeredlikelihood function (ELF) proposed in [8, 11] for carry-ing out the CVA calculation on a quantum computer.This is the first proposal of a quantum algorithm able totackle the CVA problem, with in-depth discussions aboutconcrete implementations in terms of elementary opera-tions that can be carried out on quantum computers. The

same approach can be extended to other risk analysis usecases in quantitative finance. A particular advantage ofthe ELF framework is that it does not impose a priorian amount of quantum resource required for carrying outa certain task, but instead it adaptively takes advantageof however much quantum resource one can afford on anoisy quantum device. To illustrate the concreteness weare able to associate to our solution of the CVA problem,our numerical results indicate that on a quantum com-puter that has all-to-all qubit connectivity, physical gateerror rate 10−3, and uses the surface code of distance18 for error correction (with cycle time 1µs), performingCVA calculation under the specification listed in Table Iwithin relative error of 0.001% takes around 4.9×105 sec-onds, while the same calculation takes around 3.7 × 106

seconds on a single-core classical computer (4GB RAM,up to 3.1GHz). Such comparison is certainly subject tochanges in the details of both the classical and quan-tum implementations. However, the level of specificityat which we are able to carry out the resource estimationmakes it straightforward to account for such implementa-

3

tion details if necessary. With the engineered likelihoodfunction (ELF) technique developed previously [8, 11] weare able to produce concrete estimates of quantum run-time as the noise and error parameters of the hardwareimprove.

Our overall approach for the quantum calculation ofCVA can be divided into two steps (Figure 1): quan-tum circuit generation and amplitude estimation. Thelatter has been discussed in the preceding paragraphs.The former can be further divided into state preparationand controlled rotation subroutines. For both subrou-tines we have identified opportunities to drastically re-duce the depths of quantum circuits compared with thoseproduced from reversible logic synthesis (RLS) [12–15].

Related works. There are many applications in quan-titative finance such as derivative pricing and risk anal-ysis that amount to performing integration on domainsof stochastic variables. During the early days of quan-tum computing [16–18], it has been recognized that, forthose integration tasks, one is able to glean a quadraticspeedup in cost scaling with respect to the statistical er-ror εS by using insights on quantum counting [19], whichlater on was developed into quantum amplitude estima-tion [5]. This line of inquiry was later extended to con-crete quantitative finance use cases such as option pric-ing [20, 21] and risk analysis [22]. However, no use casesrelated to valuation adjustment (XVA) have been consid-ered so far, making our proposal the first of such studies.There has been also a line of research [23, 24] focusing onusing quantum computers for accelerating Monte Carlocalculations; these studies are based on the availabilityof quantum oracles that can implement certain functions,without considering how these oracles are implemented.Here in our work, however, we will discuss the detailedimplementation of the oracles relevant for the CVA prob-lem using elementary quantum operations. Our broadermotivation is to make the quantum algorithm as concreteas possible so that it will be amenable for comparisonwith existing classical solutions as well as implementa-tion on near-term quantum devices.

II. CREDIT VALUATION ADJUSTMENT

Financial derivatives are essentially contracts betweentwo parties. For example, an option contract is a guaran-tee that one can buy or sell a set of underlying assets ata particular price before or on a specific date (dependingon the type of option contract). However, it is possiblethat when the option contract is exercised, namely whenone of the parties decides to go through with the trans-action (buying or selling), the counterparty is not able tohonor the contract, e.g., the party responsible for buyingthe asset(s) does not have enough capital to make thepurchase. This is a default event that leads to a loss onthe selling party. Since an option contract offers insur-ance against price fluctuation of the underlying asset(s),it has an intrinsic value for which one must pay a pre-

mium in order to enter it. In the event of default, thepremium paid by the party entering the option contractis essentially lost. Therefore, if there is risk that such de-fault may happen, the premium to be paid for the optioncontract should be accounted for in its price. The fairamount with which one should make the discount is thevalue of CVA.

In this study, we focus on CVA problems for EuropeanCall options. In general, the CVA quantity is built fromthe following components:

1. The probability distribution of asset prices P (s|t)at time t. Classically, for a given future time t = τ ,sampling from P (s|t = τ) is typically achieved byperforming stochastic simulation of how the assetprice s fluctuates as a function of time up to τ ,and the set of final price values is the set of sam-ples from P (s|t = τ). One of the most commonstochastic processes used for modeling price fluctu-ation is geometric Brownian motion.

2. The net amount v(s, t) gained by the purchaser ofthe option contract, or payoff, at asset price s andtime t. For a given future time t = τ , the expectedexposure E(τ) = EP (s|τ)[v(s, τ)] characterizes theaverage worth of the option at time τ . Classically,this is estimated by averaging over the values of vcomputed for each of the samples generated in theprevious step. In particular, for the case of Eu-ropean options the payoff is the maximum valuebetween zero and the difference between the priceof the asset at maturity and a fixed price K pre-determined at the start of the contract, the strikeprice.

3. The probability of default q(t) at time t. Onemethod for modeling q(t) is to consider it as aPoisson process where the Poisson parameter istime dependent. Its exact time dependence can bebootstrapped efficiently, and calibrated from mar-ket quantities such as CDS spreads [25].

4. The discount factor p(t). It expresses the timevalue of money, and it is used to determine thepresent value of an asset in the future. The for-mula for the discount factor will depend on thenumber of periods considered for interest rate pay-ments, where a typical choice is as continuous com-pound interest, which corresponds to discount fac-tor p(t) = e−rt for an interest rate r. The interestrate can also be time dependent.

The CVA is then calculated as the expected value underthe probability measure q(t) of the capital at risk, i.e.,how much can be lost if the counterparty does not honorits part in the contract, which in our case of study cor-responds to a positive payoff, discounted to the present

4

and corrected by a loss given default (LGD) factor 1−R:

CVA = (1−R) · Eq(t)[p(t)E(t)]

= (1−R) · Eq(t)p(t)EP (s|t)[v(s, t)]

= (1−R)

∫ T

0

q(t)p(t)

∫ ∞

0

P (s|t)v(s, t)dsdt.

(1)Here R is the recovery rate, defined as the fraction ofthe value of an asset retained after the borrower defaults.The above CVA calculation can also be generalized to thecase where the option contract has multiple underlyingassets. In both the single-asset and the multi-asset cases,estimating the value of CVA within statistical error εScosts O(1/ε2S).

From Equation (1) one sees that the CVA value is anintegral over time and price space. Hence, a startingpoint for estimating the CVA is to approximate it bya sum over its value over discretized time steps tiMi=0

where t0 = 0 and tM = T (note that the summationstarts from i = 1 while the definitions of ti start fromi = 0):

(1−R) ·M∑

i=1

E(ti)p(ti)q(ti), (2)

where p(ti) = exp (−rtiti) is the risk-free discount factorwith time-dependent interest rate rti at time ti, q(ti) isthe probability of default between time ti−1 and ti. More-over, E(ti) = EP (s|ti) [v(s, ti)] is the expected exposurewith

v(s, t) = maxs(t)−K exp (−rt(T − t)), 0, (3)

being the payoff at maturity time T for a strike priceK, assuming a single underlying asset for the European

option. Here, s(t) = s(0) exp(σξ +

(µ− σ2

2

)t)

is the

asset price at time t, modeled as a geometric Brownianmotion where ξ ∼ N(0, 1) is a unit normal random vari-able, σ is the volatility of the asset and µ the marketdrift, accounting for the long-term price movement trendon average at the risk-free rate.To enable representation of the asset price using quan-tum registers, we also discretize the value of the pricewith N + 1 values sjNj=0. We can then approximatethe distribution of the asset price fluctuation by consid-ering the joint distribution P (s, t) = P (s|t)P (t) wherethe marginal distribution P (t) is the uniform distribu-tion over the time period from 0 to T . We then define adiscrete probability distribution P defined at each point(sj , ti) for approximating P (s, t):

P(sj , ti) =1

MN

∫ sj

sj−1

P (s|ti)ds. (4)

where i = 1, · · · , N , j = 1, · · · ,M and N =∫ sNs0

P (s, ti)ds is the normalization constant. Since the

marginal distribution P (t) is uniform, after discretiza-tion the marginal distribution of P should satisfy P(ti) =

1/M . This produces an approximation of the expectedexposure as

E(ti) =

N∑

j=1

P(sj , ti)

P(ti)v(sj , ti)

= M

N∑

j=1

P(sj , ti)v(sj , ti)

(5)

Combining the discretizations for both asset price andtime, we arrive at the quantity to be estimated as

M(1−R) ·M∑

i=1

N∑

j=1

P(sj , ti)v(sj , ti)p(ti)q(ti). (6)

Note that in Equation (6) the quantities P, p and qare bounded between 0 and 1, while the payoff functionv may not be so. Since the discretization in asset prices means the value of s is bounded, the value of v mustalso be bounded. We introduce a scaling factor Cv suchthat v = Cv v where v is bounded between 0 and 1. Forquantities p and q, it is possible that their values varyonly subtly over their entire domains, making it hardto accurately approximate them. We therefore introducescaling factors Cp and Cq such that p = Cpp and q = Cq q.By letting Cp > 1 and Cq > 1 we are able to amplify thefluctuations of the functions p and q on their domainsrespectively. This leads to the final expression

CVA = M(1−R)CvCpCq·M∑

i=1

N∑

j=1

P(sj , ti)v(sj , ti)p(ti)q(ti)

︸ ︷︷ ︸. (7)

The problem then becomes casting the bracketed term inEquation (7), which is bounded between 0 and 1, as anamplitude estimation problem.

CVA instance for benchmarking. We consider a spe-cific instance of the CVA problem defined on a singleasset European call option: all the calculations were car-ried out under the specification listed in Table I. Thetime points tiMi=1 used for this instance are generatedusing the formula

ti = i · TM, i = 1, · · · ,M (8)

where M = 2m is chosen such that the time points canbe represented by the computational basis state of anm-qubit register. The maturity time of 6 months corre-sponds to T = 184

360 ≈ 0.511, namely the number of busi-ness days (184) in the 6-month duration starting fromMarch 5th, 2020, divided by the total number of daysconsidered in a year under Day Count convention (360).Using the Actual convention for day count means thatall days between two dates are considered for interestaccrual. If a given date is not a business day, it is ad-justed according to the Following convention, which con-siders the first business day after the given holiday. The

5

method used to determine the day at which payments aredue is the IMM convention (International Money Marketmonth), namely the effective dates are taken to be thethird Wednesday of March, June, September and Decem-ber. The quarterly frequency indicates how often pay-ments are due. In order to compute default probabilities,we use a bootstrapping approach to recover hazard ratesfrom market CDS quote spreads [25], where the interestrate curve is variable over time, specifically, it is taken tobe the EONIA curve.

Initial Asset Price 5.0

Strike Price 5.5

Volatility 0.25

Drift 0.02

Maturity 6 months

Start Date 05/03/2020

CVA Recovery Rate 0.415

Notional 1

Forward Rate Curve EONIA Curve

Hazard Rates Flat Piecewise

CDS Quote Spreads

[0.00093772, 0.00184451,

0.0032286, 0.0047065,

0.00574888, 0.00574888]

CDS Tenors [1y, 3y, 5y, 7y, 10y, 15y]

CDS Recovery Rate 0.4125

CDS Settlement Days 0

Calendar Target

Day Count Actual / 360

Business Day Convention Following

Date Generation IMM

Frequency Quarterly

TABLE I: Specification of the CVA instance benchmarkedin this study.

Benchmark value using Monte Carlo simulation. As aclassical benchmark for numerically testing the quantumalgorithm, we ran Monte Carlo simulations that use 105

stochastic paths mimicking the asset price fluctuationover time. The simulation results allow us to estimate theexpected exposure E(t) and approximate CVA by Equa-tion (2) directly, without applying the price discretizationthat produces P. The Monte Carlo simulations show thatthe CVA value for this particular instance is

CVAMC = (5.599± 0.002) · 10−5. (9)

The calculation is implemented using the Orquestra®

integration with the quantlib library [26]. For the re-mainder of the paper, we will use the value of CVAMC

as the benchmark value representing the “exact” value ofCVA, with which CVA calculations by other methods inthis study are compared.

Benchmark value with price discretization. The value of

4 5 6 7 8 9 10 11 12 13 14 15 16

Total number of qubits n+m

10−7

10−6

10−5

Dis

cret

izat

ion

erro

r|CVA

(n)−CVA

(∞)|

FIG. 2: The convergence of CVA(n) as n grows. Here thetotal number of qubits is n+m, where the number of qubits

m for representing time (Equation 8) is fixed to be 2.

CVA in Equation (9) assumes discretization in time ac-cording to Equation (8) but the price can take any valuefrom 0 to infinity. To prepare for quantum algorithmtreatment, we also discretize the price, leading to thediscrete distribution P in Equation (4). In Section IV.1we provide more details on the construction of P.

Clearly, such CVA estimation based on discretizedprice values depends on the number N of discrete price

values. Let CVA(n) be the value obtained using N = 2n

discrete price values evenly spaced between s1 and sN .Here we choose N values that are powers of two for itsconvenience in associating with the number of qubitsn = log2N needed for encoding each price value sj .Numerical results (Figure 2) indicate that as n grows,

CVA(n) converges towards a value

CVA(∞) = (5.48± 0.02) · 10−5. (10)

The difference between CVA(∞) and CVAMC is likelydue to the probability weight lost when restricting theasset price domain from [0,∞) to [s1, sN ]. However, thisdifference accounts for only around 2% relative error withrespect to CVAMC. As shown in Figure 2, for small val-ues of n, the error due to discretization (namely the in-troduction of (sj , ti)|j = 1, · · · , N ; i = 1, · · · ,M forrepresenting the domain of time and price) is dominatedby the number of discrete values sj that represent theprice.

III. QUANTUM ALGORITHM

In Section II, the CVA calculation is broken down into4 components. To describe how the quantum algorithmworks, we group the 4 steps into two parts: step 1 beingthe state preparation, steps 2-4 being the controlled ro-tation implementation. The final step is then assemblingthe operations from the previous 4 steps into a quantum

6

circuit whose output state allows for the measurement ofthe bracketed term in Equation (7).

State preparation. The goal here is to (approximately)realize an operation GP acting on n + m qubits, wheren = dlog2Ne and m = dlog2Me, such that

GP∣∣0n+m

⟩=∑

i,j

√P(sj , ti) |i, j〉 . (11)

Here |i〉 (resp. |j〉) is the computational basis state mark-ing the index i (resp. j) in its binary form. The settingof the marginal distribution of P over the asset prices isa log-normal distribution, as a consequence of choosingthe geometric Brownian model as the statistical modelfor the underlying asset. A different distribution maybe chosen for other statistical models. For example, incases where one would like to contemplate distributionswith heavy tails, Levy distribution may be used for themarginal distribution over the asset prices.

Controlled rotation. The goal here is to use a quan-tum state |x〉 encoding an input variable x as a controlregister for enacting a rotation on an ancilla qubits thatresults in a state

√1− f(x)|0〉+

√f(x)|1〉 for some func-

tion f . This construction is also commonly used in previ-ous works [23, 27] on quantum speedups for Monte Carloprocedures. For our purpose, we introduce a controlledrotation operator for each of the steps 2-4 described inSection II.

For representing the payoff of the option contract, wedefine quantum operator Rv acting on n+m+ 1 qubitssuch that

Rv |i〉 |j〉 |0〉 = |i〉 |j〉(√

1− v(sj , ti) |0〉+√v(sj , ti) |1〉

).

(12)For representing the probability of default, we intro-

duce operator Rq acting on n+ 1 qubits be such that

Rq |i〉 |0〉 = |i〉(√

1− q(ti) |0〉+√q(ti) |1〉

). (13)

For representing the discount factor, we define quan-tum operator Rp acting on n+ 1 qubits such that

Rp |i〉 |0〉 = |i〉(√

1− p(ti) |0〉+√p(ti) |1〉

). (14)

Quantum circuit assembly. We could then describea procedure for estimating the bracketed quantity in (7)as the following (Figure 3):

1. Start with two quantum registers, one of n qubitsand the other of m qubits and generate the quan-tum state

M∑

i=1

N∑

j=1

√P(sj , ti) |i〉 |j〉 . (15)

using the operator GP .

2. Add an ancilla qubit in |0〉 for storing the payofffunction (p.f.) and apply the operator Rv to pro-duce an entangled state

M∑

i=1

N∑

j=1

√P(sj , ti) |i〉 |j〉 ⊗

(√1− v(sj , ti) |0〉p.f. +

√v(sj , ti) |1〉p.f.

). (16)

3. Add another ancilla qubit in |0〉 for storing theprobability of default (p.o.d.) and apply the oper-ator Rq onto the first register and the new ancillaqubit to produce the state

M∑

i=1

N∑

j=1

√P(sj , ti) |i〉 |j〉 ⊗

(√1− v(sj , ti) |0〉p.f. +

√v(sj , ti) |1〉p.f.

)⊗

(√1− q(ti) |0〉p.o.d. +

√q(ti) |1〉p.o.d.

).

(17)

4. Add another ancilla qubit in |0〉 for storing the dis-count factor (d.f.) and apply the operator Rp ontothe first register and the new ancilla qubit to pro-duce the final state

|ξ〉 =

M∑

i=1

N∑

j=1

√P(sj , ti) |i〉 |j〉 ⊗

(√1− v(sj , ti) |0〉p.f. +

√v(sj , ti) |1〉p.f.

)⊗

(√1− q(ti) |0〉p.o.d +

√q(ti) |1〉p.o.d

)⊗

(√1− p(ti) |0〉d.f. +

√p(ti) |1〉d.f.

)(18)

5. Let Π be projector onto the subspace where thed.f., p.f. and p.o.d. ancilla qubits are all in thestate |1〉. More explicitly, we have

Π = |1〉 〈1|d.f. ⊗ |1〉 〈1|p.f. ⊗ |1〉 〈1|p.o.d.=

1

8(I − Zd.f. − Zp.f. − Zp.o.d.

+Zd.f.Zp.f. + Zd.f.Zp.o.d. + Zp.f.Zp.o.d.

−Zd.f.Zp.f.Zp.o.d.), (19)

which is a linear combination of Pauli operatorsthat can be measured directly and simultaneouslyon the quantum processor.

We observe that the quantity desired in Equation (7) canbe obtained by

M∑

i=1

N∑

j=1

P(sj , ti)v(sj , ti)p(ti)q(ti) = 〈ξ|Π |ξ〉 , (20)

7

|0n⟩|0m⟩

|0⟩d.f.

|0⟩p.f.|0⟩p.o.d

Time

Asset price

Discount factor

Payoff function

Probability of default

G

Rv

Rq

Rp

FIG. 3: The proposed (ideal) quantum circuit to perform credit value adjustment as described in Section III.

which can be estimated within a sampling error of εS intime O(1/εS) using amplitude estimation.

The rest of the paper is organized as follows. In SectionIV we describe in details the quantum circuit construc-tion used for preparing the state |ξ〉, using a particularcircuit as an example. The quantum circuit constructioninvolves the following operations:

• Operator GP for state preparation (Section IV.1);

• Controlled operations Rv, Rq, Rp (Section IV.2).

The proposed quantum circuit for the algorithm can befound in Figure 3. In Appendix E we proceed to describehow the quantum circuit design is used for amplitudeestimation by engineered likelihood function (ELF) [8].

IV. QUANTUM CIRCUIT

Existing state preparation techniques [12–15] rely onthe ability to perform operations such as evaluating arith-metic expressions [14], computing the integral of a prob-ability density function over an interval [12], and extract-ing elements of a sparse matrix [13]. These operations areeither assumed to be supplied through oracles, in whichcase their implementations in terms of elementary quan-tum operations on a quantum computer are entirely nottaken in to account, or assumed to be realizable efficientlyvia well-known techniques such as reversible logic synthe-sis (RLS) [28–33]. However, although RLS is efficient inan asymptotic sense if the underlying function can be re-alized by a polynomial-time classical procedure, concreteresource estimations show that it is costly compared withother parts of quantum algorithms, motivating alterna-tive approaches [34]. In this paper we also perform nu-merical experiments to illustrate how costly RLS can bewith even small examples of CVA calculations (SectionIV.2).

Instead of RLS, which is capable of enabling both thecontrolled rotation and the state preparation [35], in thiswork we identify opportunities for realizing both withcircuits of much shorter depths. For state preparation,we investigate two alternatives: quantum circuit Bornmachine [36] and quantum circuit construction based onmatrix product states [37]. We show that highly accurateapproximations are possible with circuits that are much

shallower than those produced from RLS. We note thatthere are also other state preparation schemes [38–40]inspired by generative adversarial networks that can alsoyield more efficient state preparation protocols than RLS.

For the purpose of illustration, we consider a specificinstance of CVA estimation using Equation (7) with pa-rameters listed in Table II.

The classical benchmark value (Section II) for this in-stance is

CVA(2) = 1.223 · 10−5. (21)

The large discrepancy between CVA(2) and CVAMC inEquation (9) can be mostly attributed to discretizationerror due to finite n (Figure 2). In Section IV.3 we will

compute the value CVAQ produced by the quantum cir-

cuit for this instance, compare it with CVA(2) and dis-cuss the sources of error.

Number of qubits m for encoding time 2

Number of qubits n for encoding price 2

Scaling constant for payoff Cv 1.8201814

Scaling constant for default probability Cq 0.0002038

Scaling constant for discount factor Cp 1

TABLE II: Parameters of the example quantum circuitconsidered in Section IV. The other parameters related to

the CVA instance are shown in Table I.

IV.1. State preparation

In the context of the CVA problem (Section III), therole of state preparation is to implement theGP operator,thus preparing a quantum state loading into it the targetdistribution ptg(x) = P(sj , ti) which is the discretizedjoint distribution of time and asset price. The circuitacts on two registers of qubits encoding time and assetprice respectively, where the qubit states are representedas bitstrings whose first part refers to the time registerand the following to the price register. Given that weare considering asset fluctuations modeled by geometricBrownian motion, at each point in time such distributionis the log-normal distribution, namely:

8

Quantum Computing and HPC - CINECA

/ZapataComputing Zapatacomputing.com

Born’s Rule

!! # = # %(') "

**) ' = − ∑$ !%& (#) log /0# !! # , 2

Estimate mismatch between data and quantum outcomes

clipped neg log likelihood

Classical Optimizer''() ''

Parametrized Quantum Circuit

!!($)3 4% (')… …3 4% '*(')

Quantum computer

Classical computer

FIG. 4: Quantum circuit Born machine for learning the state preparation circuit GP .

P (s|t) =1

s√

2πσ2exp

[−(

ln s− ln s0 − (µ− σ2

2 )t√2σ2t

)2],

(22)where σ is the price volatility, µ represents the marketdrift which accounts for the long term price movementtrend, and s0 is the initial asset price.

The target distribution of P in Equation (4) is obtainedvia classical Monte Carlo simulation of the asset pricesand then discretized to the available quantum states|x〉 = |i, j〉. Specifically, 105 trajectories of asset pricesdynamics from time 0 to maturity T are computed, sim-ulating geometric Brownian motion on a fine time grid.Then, the asset price distributions at the time steps ti de-fined by Equation (8) are extracted from the above simu-lation: for each time step ti we obtain a log-normal peakas in Equation (22). We choose the range of the discretesj values such that the smallest value s1 = maxµ−3σ, 0and the largest value sN = µ + 3σ, where µ and σ arethe sample mean and sample standard deviation of theprice values produced by the Monte Carlo simulations.We then calculate P by binning the price data from theMonte Carlo simulation yielding CVAMC according to thedifferent sj values, which enabled the estimation of CVAaccording to Equation (7).

IV.1.1. Quantum Circuit Born Machine

Quantum Circuit Born Machine (QCBM) [36] has beenshown to learn and load a target probability distributionptg into a quantum state. The structure of this hybridquantum-classical algorithm is depicted in Figure 4. Thesubroutine running on the quantum computer consists oftraining a parametrized quantum circuit, depending on

some parameters ~θ and encoding a probability distribu-

tion p~θ. Indeed, the output state of the circuit |ψ(~θ)〉contains in its amplitudes the probability distribution,according to Born’s rule:

p~θ(x) = |〈x|ψ(~θ)〉|2, (23)

where |x〉 = |i, j〉 represents a computational basis statethat encodes a point on the discretized domain of the tar-get probability distribution ptg. The circuit parameters~θ are tuned in order to find the optimal set ~θ∗ such thatp~θ is as close as possible to ptg. The process of learningthe parameters is carried out by a classical optimizer: itsgoal is to minimize a cost function which quantifies thedifference between the two probability distribution intoplay. We choose to employ an evolutionary and derivativefree strategy as the classical optimizer, namely the Co-variance Matrix Adaptation Evolution Strategy (CMA-ES [41]). As for the cost function, we use the clippednegative log-likelihood [36], defined as follows:

C(~θ) = −∑

x

ptg(x) log(max(p~θ(x), ε), (24)

where ε is a small parameter to avoid singularity. Thereare several options available for both the optimizer andthe cost function, whose efficiency is highly dependent onthe specific problem instance.

The QCBM is able to learn the desired distributionP(sj , ti), by undergoing a training process that tunes theparameters of the quantum circuit so that the desiredtarget is loaded into a quantum state. The ansatz weconsider for the parametrized quantum circuit, definedon 4 qubits, is shown in Figure 5.

|0⟩

|0⟩|0⟩

Rx|0⟩Rx

Rx

Rx

XXRz

Rz

Rz

Rz

XX

XX

XX

XX

XX

XX

XX

XX

XX XXXX

l = 1 l = 2

FIG. 5: The ansatz circuit for realizing the operator GP ,with 14 variational parameters (one for each gate). It is com-posed of a single qubit layers (l = 1) and an entangling layer(l = 2), so that overall it has nlayers = 2.

9

FIG. 6: The training process of the parametrized quantum circuit in the single asset case, where the ansatz is defined on 4qubits and has 14 gates. On the left, the plot shows the convergence of the (rescaled) cost function towards its ideal value.The orange dots mark the cost function value at each optimization step, whereas the blue line connects only points with

progressively decreasing values, thus highlighting the minimization trend. On the right, histograms display the probabilitydistributions encoded in the quantum state before (top) and after (bottom) the training.

It is composed of two layers, where the first layer (l = 1)is made of single qubit rotations and the second one(l = 2) uses two qubit gates to introduce entanglement.The depth of the circuit can be varied as needed, so thateach layer of one(two)-qubit(s) gates is identified by anodd(even) index l, with l = 1, · · · , nlayers. The types ofone-qubit gates used in the QCBM circuit are chosen tobe X and Z rotations, whereas for the two-qubits gateswe use the XX coupling gate, which is implemented na-tively in ion-trap quantum computers. Specifically, thegates are defined as follows:

Rx,z(θ) = exp(− i θ2σx,z

)

XX(θ) = exp(− iθσx ⊗ σx

).

(25)

The qubit connectivity is assumed to be all-to-all, so thateach pair of qubits undergoes an XX transformation.The depth of the circuit grows according to the circuitsize: the larger the number of qubits, the deeper thecircuit needs to be in order to be trained successfully(see Appendix A). For the 4-qubit instance in Figure 5,one layer of tunable entangling gates is enough for theQCBM to be able to learn the target distribution. Figure6 shows a typical training curve of the cost function, asthe iterations proceed. Note that the cost function hasbeen rescaled so that its expected value for a successfultraining is zero.

IV.1.2. Matrix Product State

An alternative method to using QCBM is to leverageMatrix Product State (MPS) [37], which is a tensor net-work that has been used for mimicking correlations be-tween different variables. An MPS is represented by asequence of tensors A(1), A(2), · · · , A(n+m). Each tensorA(`) depends on the value of x`, which is the `-th ele-ment of x = |i, j〉. When evaluated at a particular valueof x`, A

(`) becomes a matrix (except for when ` = 1 or

` = n+m, where it becomes a vector), denoted as A(`)x` .

The MPS can then be defined as (Figure 7a)

ΨA(x) = Tr(A(1)x1A(2)x2· · ·A(n+m)

xn+m

). (26)

The equation above assumes that the A(`)x` objects have

compatible dimensions so that they can be multiplied

together properly. If A(`)x` is a matrix of dimension d` ×

d`+1 and A(`+1)x`+1 is a matrix of dimension d`+1×d`+2, then

d`+1 is the bond dimension between A(`)x` and A

(`+1)x`+1 .

An MPS can represent a quantum wavefunction ΨA(x)that approximates a target distribution ptg in the sameway as QCBM, namely pA(x) = |ΨA(x)|2 ≈ ptg(x). Aconcrete way to measure the closeness between the MPSoutput pA and the target distribution ptg is by computinga negative log-likelihood function over a set S of samples

10

ΨA( x ) = ΨA(x1, x2, ⋯, xn+m) = Tr(A(1)x1 A(2)

x2 ⋯A(n+m)xn+m )

ΨA

x1 x2 x3 x4

= A(1)

x1 x2 x3 x4

n = 2, m = 2 :

=

x1 x2 x3 x4

[A(2,3)x2x3 ]ik

= ∑j

[A(2)x2 ]ij [A(3)

x3 ]jk

i j k

i k

A(2) A(3) A(4)

A(1) A(4)A(2,3)

A(1) A(ℓ) A(ℓ+1) A(n+m)⋯ ⋯

Step 6: Move on to the next pair, and repeat Step 1

A(ℓ,ℓ+1)

Step 1: Merge two tensors

Step 3: Singular value decomposition

DU V

Step 2: Tensor parameter update

A(ℓ,ℓ+1)

[ A(ℓ,ℓ+1)xℓxℓ+1 ]ik

= [A(ℓ,ℓ+1)xℓxℓ+1 ]ik

− γ∂

∂ [A(ℓ,ℓ+1)xℓxℓ+1 ]ik

xℓ xℓ+1

i k

Step 4: Truncate singular values with cutoff

¯DU V

Step 5: Re-assemble tensors andA(ℓ) A(ℓ+1)

(a) Matrix product state (MPS) (b) Training MPS to learn target distribution

FIG. 7: Matrix product state (MPS) and its usage for learning a target distribution. (a) Definition of an MPS ΨA(x) andprocess for contracting two tensors in the MPS. (b) Process for training MPS to learn a target distribution. Note that in

Step 5 one could either “go left” by letting A(`) = U · ¯D, A(`+1) = V or “go right” by letting A(`) = U and A(`+1) =

¯D · V .

Details for evaluating the gradient of the cost function L are shown in [37].

x generated from ptg:

L(A) = − 1

|S|∑

x∈Slog pA(x). (27)

The likelihood function is similar to the cost functionin Equation 24 in the sense that averaging over S ap-proximates the expectation over the target distribution−∑x ptg(x) log pA(x).

In order to minimize the negative log-likelihood func-tion, we adopt an iterative scheme. A summary of thescheme is provided in Figure 7b. This method builds onthe connection between unsupervised generative model-ing and quantum physics, where MPS is employed as amodel to learn the probability distribution of a given dataset with an algorithm which resembles Density MatrixRenormalization Group (DMRG), which is an efficientalgorithm that attempts to find the MPS wavefunctioncorresponding to the ground state for a given Hamilto-nian. Relying on the ability to efficiently evaluate gradi-ents of the objective function [37], we can iteratively im-prove the MPS approximation of the target distribution.The iterations proceed until one of the three scenarios:1) a threshold for the KL divergence between the modeloutput and the training data is reached, 2) the differencein the objective function between two adjacent trainingsteps is below a threshold, or 3) a maximum number ofiterations is reached. In Figure 8 we show results fortraining the MPS up to nqubits = n + m = 20 qubits.From the data, the empirical scaling of the MPS trainingcost is roughly O(n6

qubits).In order to make the MPS construction useful for the

CVA calculation, as well as to compare QCBM and MPSin a fair way, we need an explicit recipe for generating

4 5 6 7 8 9 10 11 12 13 14 151617181920

Total number of qubits n

100

1000

10000

Tra

inin

gti

me

(sec

ond

s)

FIG. 8: Runtime for training the MPS versus the numberof qubits. The scales for both axes are logarithmic. The reddashed line is a linear regression with correlation coefficient

being 0.987 and the slope being roughly 5.827.

quantum circuits that prepare the MPS. The basic ideais to use a sequence of Singular Value Decomposition(SVD) steps to transform the MPS into an orthogonalform in which each tensor is an isometry and hence canbe embedded into a unitary operator. Then we decom-pose these unitary operators into CNOT and single-qubitgates by the method in [42]. When the MPS has n sitesand bond dimension D, there are at most n− dlog2(D)esuch unitary operators, where each of them acts on atmost dlog2(D)e+ 1 qubits and can be implemented withO(D2) two-qubit gates. As a consequence, the quantumcircuit for preparing the MPS contains O(nD2) two-qubitgates. Note that it remains unknown how many CNOT

11

FIG. 9: The training process of the MPS model in the single asset case, where the ansatz is defined on 4 qubits and has 14gates. On the left, the plot shows the convergence of the cost function towards its ideal value with y-axis rescaled

logarithmically. The dots mark the cost function value at each optimization step, whereas the line connects only points withprogressively decreasing values, thus highlighting the minimization trend. On the right, histograms display the probability

distributions encoded in the quantum state after the first training step (top) and the one after the final step of training(bottom).

nqubits ttrain KL niters

4 17.94 3.21 · 10−6 2

5 28.44 4.11 · 10−6 2

6 42.17 4.53 · 10−6 2

7 62.06 1.62 · 10−6 3

8 116.46 8.60 · 10−5 3

10 399.99 2.07 · 10−2 5

12 870.41 1.5 · 10−2 7

14 4967.78 7.04 · 10−2 19

16 6417.41 0.86 22

20 24084.47 3.20 25

TABLE III: Results for MPS training. Herenqubits = n+m is the number of qubits encoding the joint

time and price values, ttrain is the total time for training theMPS (in seconds). The maximum bond dimension of the

MPS in all cases is limited to 2. The values on this table hasbeen obtained with a threshold for KL divergence of 3 · 10−5.

and single-qubit gates are needed exactly to implement ageneral k-qubit unitary operator for k ≥ 3, and the bestknown results are lower and upper bounds on them. Sowe can only give lower and upper bounds on the numbers

of elementary gates in the circuit for preparing the MPS(except for the case D = 2) in Table IV. See AppendixB for more details about encoding MPS into quantumcircuits.

We are now able to compare the two methods pro-posed so far for the state preparation task. Specifically,we focus on the aforementioned 4-qubits instance of theQCBM with different depths, i.e. nlayers = [2, 4, 6, 8, 10],which corresponds to a 4-site MPS with the same val-ues of bond dimension D. We also consider a 6-qubitsQCBM instance and its analogous MPS, varying nlayers

and D as in the former setting. The target distributioncorresponds to Equation (4) with P (s|t) as in Equation(22). Tables V and IV show the results of the compar-ison between QCBM and MPS-based circuits, where wereport the number of one- and two- qubit gates (in termsof CNOTs for a fair comparison), the number of itera-tions until convergence of the cost function minimizationand the corresponding values of KL divergence, i.e. train-ing accuracy. From this data, we can draw the followingconclusions, that hold for both cases under examination:

• Given a circuit depth and a target accuracy, MPSis able to reach the desired KL divergence valuewith very few iterations, while the QCBM requiresmany more optimization steps.

12

• Given a circuit depth, we observe that in some casesthe QCBM is able to reach a lower KL divergencethan MPS, provided we use a sufficiently high num-ber of iterations. Additional numerics suggests thatthe QCBM is able to beat the training accuracy ofMPS, which instead reaches a plateau that preventsthe KL value to decrease further when the numberof the optimization steps is increased.

• Given a fixed number of qubits, we compare MPSand QCBM depths in terms of CNOTs. With smallnlayers or D, we see that MPS is shallower than theQCBM, but as nlayers or D are increased there is aninversion point - whose exact location depends onthe circuit size - where QCBM becomes shallowerthan MPS.

We note that some of the recent works on using MPS fordescribing continuous probability distributions [43] cansignificantly improve the training cost of MPS or avoidtraining altogether. This will also affect the comparisonwith QCBM.

MPS D CNOT 1-qb niters KL

nqubit

s=

4

2 9 19 2 1.15 · 10−4

4 [28, 40] [42, 80] 2 3.21 · 10−6

6 [61, 100] [85, 184] 2 3.21 · 10−6

8 [61, 100] [85, 184] 2 3.21 · 10−6

10 - - - -

nqubit

s=

6

2 15 31 2 3.68 · 10−2

4 [56, 80] [84, 160] 2 2.31 · 10−4

6 [183, 300] [255, 552] 2 2.93 · 10−5

8 [183, 300] [255, 552] 2 4.53 · 10−5

10 [504, 888] [682, 1568] 2 4.53 · 10−5

TABLE IV: For MPS-equivalent circuit with nqubits = 4(top) and nqubits = 6 (bottom), the table displays the circuitdetails (bond dimension D, number of CNOT gates and num-ber of single qubit gates), the number of optimization steps(i.e. niters) and the KL divergence values. Since it remainsunknown how many CNOT and single qubit gates are neededexactly to implement a general k-qubit unitary operator, wecan only give lower and upper bounds (except for the caseD = 2). Lastly, for nqubits = 4, the upper bound for D is 8:for nqubits = 4 and D > 8 the formula for the equivalent cir-cuit breaks down. See Appendix B for details about encodingMPS into quantum circuits.

IV.2. Controlled rotations

In preparing the quantum state for the CVA problemwe are faced with the problem of constructing operatorsthat are all of the following form:

Rf : |i〉 |0〉 7−→ |i〉(√

1− f(xi) |0〉+√f(xi) |1〉

), (28)

QCBM nlayers CNOT 1-qb niters KL

nqubit

s=

4

2 12 38

10

100

1500

4.49 · 10−1

1.16 · 10−1

1.10 · 10−3

4 24 80

10

100

4000

6.78 · 10−1

1.28 · 10−1

1.82 · 10−7

6 36 118

10

100

4000

5.86 · 10−1

2.95 · 10−1

3.02 · 10−10

8 48 156

10

100

4000

6.50 · 10−1

1.64 · 10−1

8.96 · 10−9

10 60 194

10

100

5000

5.43 · 10−1

1.77 · 10−1

1.08 · 10−7

nqubit

s=

6

2 30 87

10

1000

15000

1.088

4.43 · 10−2

2.56 · 10−2

4 60 180

10

1000

30000

1.204

5.81 · 10−2

1.43 · 10−3

6 90 267

10

1000

50000

9.82 · 10−1

6.92 · 10−2

1.03 · 10−4

8 120 354

10

1000

15000

8.81 · 10−1

2.08 · 10−1

2.93 · 10−6

10 150 441

10

1000

20000

8.69 · 10−1

4.48 · 10−1

4.56 · 10−6

TABLE V: For QCBM with nqubits = 4 (top) andnqubits = 6 (bottom), the table displays the circuit details(number of layers, number of CNOT gates and number ofsingle qubit gates), the number of optimization steps (i.e.

niters) and the KL divergence values.

where the function f : Ω 7−→ [0, 1] and xi ∈ Ω are dis-crete points chosen in its domain and lastly, the labeli ∈ N is an integer indexing discrete points whose binary

expansion is∑k=n+m−1k=0 2kik , with ik ∈ [0, 1]. If f is

efficiently computable classically with O(poly(n,m)) re-source, a common strategy for realizing f exactly is byReversible Logic Synthesis ([32, 33]); the cost of doing sowould also be O (poly(m,n)).The polynomial scaling isefficient in theory but in practice - and especially for near-term quantum computers - much more is to be desired interms of lowering the circuit cost. For example, for theCVA instance considered in this work (with a total of 7qubits), RLS requires a total of 89 CNOT gates. For thepurpose of a near term alternative to RLS, we introducean ansatz, Controlled Rotation Circuit Ansatz (CRCA)to try to approximate (28) in the following ansatz (Figure

13

10):

Rf : |i〉 |0〉 7−→|i〉(√

1− f(xi, ~θ) |0〉+ eiφ(xi,~θ)

√f(xi, ~θ) |1〉

)(29)

where f is some function with the same domain andco-domain as f , and φ is some relative phase that de-

pends on xi and ~θ. This ansatz can be used to approxi-mate the operators Rv, Rq, and Rp (see Equations (12),

(13), (14) in Section III). Let Rv, Rq and Rp denoteapproximations to each of the operators in the form de-scribed in Equation (29). In the computational basis

span|i〉 ⊗ span|0〉, |1〉 the operators Rf and Rf canbe arranged as block diagonal matrices with each blockbeing an SU(2) rotation U (i) indexed by the label i:

Rf =

U (1)

U (2)

. . .

U (2n+m)

, (30)

U (i) =

(√1− f(xi) −

√f(xi)√

f(xi)√

1− f(xi)

). (31)

For Rf we can similarly consider the block structure in(30) with each block realizing the single-qubit rotationthat leads to (29). However, the relative phase factor

eiφ(xi,~θ) is immaterial for the purpose of the CVA calcu-lation, since ultimately the quantity desired 〈ξ|Π|ξ〉 (Sec-tion III) is independent of the phase factors. We make

a simplification and consider an operator R′f which is

equivalent to Rf for the purpose of CVA calculation butconsists of only real elements:

R′f =

V (1)

V (2)

. . .

V (2n+m)

, (32)

V (i) =

1− f(xi, ~θ) −√f(xi, ~θ)√

f(xi, ~θ)

√1− f(xi, ~θ)

. (33)

The error in CRCA training can then be characterizedas the norm difference between the unitary operators Rfand R′f . Based on the block structures in Equations (30)

and (32), the norm difference becomes

εCRCA,f =∥∥∥Rf − R′f

∥∥∥2

= maxi‖U (i) − V (i)‖2. (34)

Another common way to measure the approximation er-

ror of f with respect to f is by the 1-norm difference:

1

2n+m

2n+m−1∑

i=0

|f(xi, ~θ)− f(xi)|. (35)

In Appendix C we show that |f(xi, ~θ)− f(xi)| ≤ ‖U (i)−V (i)‖2, which implies that εCRCA,f is an upper bound tothe 1-norm difference.

Having proposed CRCA as an alternative to RLS, itis instructive to investigate the cost of RLS not only tohighlight the value of having CRCA, but also to look intowhat RLS produces in terms of the number of entanglingoperations (CNOT gates) for a practical problem. Weuse the transformation based synthesis method [44] forour implementation of RLS. We assume the existence ofthree qubit registers, namely:

(i) First register stores the domain values,

(ii) Second register stores the function values,

(iii) Third register contains the ancilla qubit for whichthe probability of measuring it in the |1〉 state givesthe value of the function.

More concretely, we have the following sequence ofquantum operations:

Uf : |i〉 |0〉 |0〉 7−→ |i〉 |f(i)〉 |0〉 , (36)

Of : |i〉 |f(i)〉 |0〉 7−→ |i〉 |f(i)〉 (ai |0〉+ bi |1〉) , (37)

U†f : |i〉 |f(i)〉 (ai |0〉+ bi |1〉) 7−→ |i〉 |0〉 (ai |0〉+ bi |1〉) ,(38)

where bi is such that |bi|2 = f(i). The quantum opera-tion Uf is implemented by RLS while Of is a quantumcircuit that contains O(n) controlled rotations, where nis the number of qubits in the first register. Let C bethe number of CNOT gates from RLS, then we need atotal of 2C CNOT gates to implement the evaluationof the function i.e (36) and its un-computation i.e (38).The number we report for C will contain all the CNOTgates needed to implement functions for the payoff func-tion, the discount factor, and default probabilities. Forthe step in (37) we require n two qubit gates for boththe discount factor and the default probabilities and 2ntwo qubit gates for the payoff function. Thus, the totalnumber of two qubit gates N2q needed to solve a CVAproblem instance is

N2q = 2C + n+ n+ 2n = 2(C + 2n). (39)

In Table VI we present numerical results for calculatingN2q for different numbers of qubits. In comparison, toimplement all the three desired functions for the CVA in-stance with CRCA, we need a total of 6 CNOTs for boththe discount factor and the default probabilities and 24CNOTs (2 layers) for the payoff function, giving a grandtotal of 36 CNOTs for a qubit size register of 4 qubits. Ofcourse, while we expect to continue to see savings in thenumber of CNOT gates, the classical optimization prob-lem for CRCA gets harder with the number of qubits.

IV.3. Noiseless quantum CVA value

We now have all the ingredients needed to build thequantum circuit shown in Figure 3 so that we are able

14

| i1⟩| i2⟩

|0⟩| in⟩

R (θ1)y R(θ2)

z R (θ3)y R(θ4)

x R (θ5)y R(θ6)

z R(θ7)x R (θ8)

y R(θ9)z R(θ3n+1)

x R (θ3n+2)y

FIG. 10: Controlled Rotation Circuit Ansatz (CRCA), the proposed near term circuit to implement operators of the form inEquation (29).

n N2q

4 212

6 640

8 1428

10 25226

12 114632

14 483436

TABLE VI: Cost of RLS. n is the number of qubits, whileN2q is the number of required two-qubit gates.

to get a quantum estimate for the CVA value. Once allthe components are trained we can simply run the circuitand calculate the probability of three ancilla being in the

state |111〉. Let∣∣∣ξ⟩

be the actual output state of the

quantum circuit (versus the ideal state |ξ〉 in Equation18). The quantum CVA value is then:

CVAQ = 2m(1−R)CpCqCv

⟨ξ∣∣∣Π∣∣∣ξ⟩

(40)

= 1.987 · 10−5 (41)

where the values of Cp, Cv, m, Cq are reported in TableII and R is reported in Table I. The above result is cal-culated from an exact simulation of the quantum circuit.The error in the CVA calculation can be decomposed asthe following:

|CVAMC − CVAQ| ≤

|CVAMC − CVA(2)|+ |CVA(2)− CVAQ|= εD + εQ

(42)

where εD = |CVAMC−CVA(2)| is the discretization error

and εQ = |CVA(2) − CVAQ| is defined as the error dueto deviation of the trained quantum circuit from an idealquantum circuit that prepares |ξ〉 in Equation (18). Witha slight abuse of notation regarding the operators form-ing the quantum circuit (Figure 3), we consider |ξ〉 =

RpRqRvGP |0n+m+3〉 and |ξ〉 = RpRqRvGP |0n+m+3〉where Rp, Rq, Rv, and GP denote the operators producedfrom training. The core component of understanding εQ

Discretization error εD 4.376 · 10−5

Noiseless quantum circuit error εQ 7.638 · 10−6

Noiseless observable error εΠ 8.836 · 10−3

State preparation error KL(pG||ptg) 4.150 · 10−4

Payoff function error εCRCA,v 3.218 · 10−3

Discount factor error εCRCA,q 1.545 · 10−4

Default probability error εCRCA,p 1.546 · 10−4

TABLE VII: Error quantities of the quantum circuit forthe CVA instance described in Table II.

is to bound the error in estimating Π, for which we havethe following upper bound (derived in Appendix D):

εΠ = |〈ξ|Π|ξ〉 − 〈ξ|Π|ξ〉| ≤√2 ·KL(pG||ptg) + 2(εCRCA,v + εCRCA,q + εCRCA,p)

(43)

where εCRCA,f = ‖Rf − Rf‖2. Here we use pG to de-note the output probability distribution (Equation 23and pA = |ΨA|2 for ΨA in Equation 26) from the statepreparation operator GP . Although slightly different ob-jective functions are used for QCBM and MPS training,

in both cases (C(~θ) in Equation 24 and L in Equation 27)they are related to the KL divergence between the gen-erated distribution pG and the target distribution ptg.

In Table VII we list the error quantities that are usefulfor gaining insight on the main sources error. Clearly,since the CVA instance contains only n+m = 4 qubits,the dominant source of error is discretization εD (com-puted from Equations 9 and 21), compared with error inbuilding the quantum circuit εQ (computed from Equa-tions 21 and 41). However, as shown in Figure 2, εD canbe quickly suppressed by increasing the number of qubitsn for encoding the asset price. Through Equation (40) wecan obtain the error εΠ = εQ/(M(1−R)CvCpCq) in esti-mating the observable Π as listed in Table VII. Based onthe upper bound of εΠ, apparently the contribution fromstate preparation, which is

√2 ·KL(pG||ptg) = 0.0288,

dominates over the contributions from CRCA training.The value of εΠ is well within the upper bound in (43).

The analysis so far assumes perfect amplitude esti-

mation, namely that we are able to obtain 〈ξ|Π|ξ〉 ex-actly. In reality, with both quantum amplitude estima-

15

(a) Discount Factor

(b) Default probability

(c) Payoff function

FIG. 11: The CVA circuit requires that we learn functions for (a) the discount factor p(ti), (b) the probability of defaultq(ti) and (c) the payoff function v(sj , ti). For each subplot, on the right, the histograms display the functions encoded in thequantum state after the first training step and the one after the final step of training. The plots to the left display the value

of the cost function in the training procedure.

16

tion and classical Monte Carlo algorithms, there is al-ways a statistical error εS due to the finite amount ofcomputational resource, be it quantum circuit runs orMonte Carlo steps, being used for statistical estimation.In the next section, we discuss using a recently developedBayesian amplitude estimation technique [8] for perform-ing the amplitude estimation. A central object of this al-gorithm is the engineered likelihood function (ELF) whichis used for carrying out Bayesian inference. See AppendixE for a detailed description of this algorithm.

V. CONCRETE RESOURCE ESTIMATION

In this section, we evaluate and compare the runtimesof classical and quantum algorithms for solving the CVAinstance specified in Table I. For the classical benchmark,we compute the CVA value based on Equation (1). Inparticular, to compute the expected exposure E(ti) ateach time ti, we run a classical Monte Carlo simulationwith 10, 100, 1000, 10000 or 100000 paths, respectively.This leads to different runtimes of the algorithm and dif-ferent errors in the outputs, which are illustrated in Fig-ure 12.

For the quantum amplitude estimation, we apply theELF-based amplitude estimation algorithm (Appendix

E) to the circuit A = RpRqRvGP and the projectionoperator Π given by Equation (19). The ELF-based es-timation scheme requires implementing two types of re-flection operations:

1. We implement the unitary operator R0(y) =exp(iy

∣∣0n+m+3⟩ ⟨

0n+m+3∣∣) with the method in

[45], which requires n + m + 2 ancilla qubits and8(n+m+ 2) two-qubit gates [46].

2. To implement the operator U(x) = exp(ixΠ), wedecompose it into 4 two-qubit gates, as implied byTheorem 8 of [42].

As a consequence, the quantum circuit for drawing sam-ples that correspond to an ELF acts on 13 logical qubitsand contains M = 136 logical two-qubit gates per layer.

We assume that the quantum device has gate error rate10−3 and uses the surface code in [47] for quantum errorcorrection, and we follow the method in [48] to analyzethe overhead of this scheme. When the distance of thesurface code is d, each logical qubit is mapped to 2d2

physical qubits, the fidelity of each non-Clifford gate isfnc ≈ (1−10−(d+3)/2)100d, and the execution time of thisgate is tnc ≈ 100d×the surface code cycle time. Undera reasonable assumption about the layout of the circuit[48], we have f2Q ≈ fnc, and t2Q ≈ tnc. We set thesurface code cycle time to 1µs (which is an optimisticestimate [47]), and vary the code distance from 10 to26. This leads to different fidelities and execution timesof logical two-qubit gates. We also assume the readoutfidelity is p = f3

nc, as the projection operator Π actson three logical qubits. Under these assumptions aboutthe hardware, we use the following equation to estimatethe quantum runtimes needed to achieve the same errortolerance ε as in the classical experiments.

Tε ∼ O

t2QM ·

e−λ

p2

λ

ε2+

1√2ε

+

√√√√(λ

ε2

)2

+

(2√

2

ε

)2

, (44)

where t2Q is the two-qubit gate time, M is the numberof two-qubit gates per layer [49], λ = M ln(1/f2Q) inwhich f2Q is the two-qubit gate fidelity, and p is the read-out fidelity. In the low-noise limit, i.e. λ ε, Equation(44) recovers the Heisenberg-limit scaling O(1/ε); whilein the high-noise limit, i.e. λ ε, Equation (44) recoversthe shot-noise-limit scaling O(1/ε2). Thus, this modelinterpolates between the two extreme cases as a functionof λ. Such bounds allow us to make concrete statementsabout the extent of quantum speedup as a function ofhardware specifications (e.g. the number of qubits andthe two-qubit gate fidelity), and estimate runtimes usingrealistic parameters for current and future hardware.

The numerical results generated from the runtimemodel are demonstrated in Figure 12. We observe thatfor estimating CVA to a relatively large error (e.g. ≥0.35%), our quantum algorithm runs slower than theclassical algorithm. This is mainly because elementaryquantum operations take much longer time to execute

than their classical counterparts, due to the overheadfrom quantum error correction. So even though our al-gorithm contains fewer elementary operations than theclassical algorithm, its runtime is still larger than thelatter’s. Nevertheless, as demonstrated by Figure 13, theruntime of classical algorithm scales almost quadraticallyin the inverse error in the result, while the runtime of ouralgorithm scales almost linearly in the same quantity, as-suming the gate fidelity is sufficiently high. Therefore, asthe desired accuracy of the result becomes higher, the gapbetween the quantum and classical runtimes will shrink,and eventually the quantum algorithm will surpass theclassical one in efficiency. For example, based on the pro-jection in Figure 13, our algorithm will run faster thanthe classical one for estimating CVA within relative er-ror ≤ 0.0067%. We emphasize that this threshold heav-ily depends on the hardware specifications, and could bedramatically shifted once we have better technology forrealizing high-fidelity quantum gates.

17

FIG. 12: Classical and quantum runtimes needed toestimate CVA to various accuracies. Here “RE” is short forrelative error. Each color represents a target accuracy, andthe dashed line and solid curve of that color represent the

classical and quantum runtimes needed to reach thataccuracy, respectively. We assume that the quantum deviceuses the surface code in [47] for quantum error correction

and follow the method in [48] to analyze the overhead of thisscheme. The surface code cycle time is set to 1µs.

FIG. 13: Trends of classical and quantum runtimes forestimating CVA to higher and higher accuracies. Here we

make the same assumption about the quantum device as inFigure 12, setting the code distance to 18. The classical

runtime scales almost quadratically in the inverse error inthe result, while the quantum runtime scales almost linearly

in the same quantity.

Our results are consistent with the ones in [50] whichshow that it is unlikely to realize quantum advantage ona modest fault-tolerant quantum computer with quan-tum algorithms giving quadratic speedup over its clas-sical alternatives, due to the large overheads associatedwith quantum error correction. For such quantum al-gorithms to run faster than their classical competitors,the input instance must be sufficiently large (as mea-sured by the inverse accuracy of the result in this work),so that the small quantum scaling advantage can com-pensate for the large overhead factor from error correc-tion. These findings suggest that we should either focusbeyond quadratic speedups or dramatically improve thetechniques for quantum error correction (or do both) inorder to achieve quantum advantage on early generationsof fault-tolerant quantum computers.

While our observation of quantum advantage happen-ing at large scales echoes the point in [50], our resource

estimation is less pessimistic than the ones in that pa-per, due to the innovations in our circuit construction.Specifically, [50] has focused on the case where both clas-sical and quantum algorithms make calls to certain prim-itive circuits to solve the same problem, and the quan-tum primitive circuit is simply the coherent version of theclassical one and is usually obtained via reversible logicsynthesis. (Namely, the quantum algorithm has essen-tially the same spirit as the classical one but leveragesamplitude amplification to achieve quadratic speedup.)Due to the overhead from reversible logic synthesis andquantum error correction, the quantum primitive circuitis much slower than its classical counterpart. However,this is not the case in this work, as we have inventedalternative, shallower quantum circuits for CVA evalua-tion that are qualitatively different from the classical onebased on Monte Carlo sampling, and consequently, ourprimitive calls take much less time than the ones consid-ered in [50], which reduces the gap between the runtimesof classical and quantum algorithm at small scales.

VI. DISCUSSION

In this work we have described a general quantum al-gorithm for computing credit valuation adjustment andperformed concrete resource estimation using a specificinstance of the CVA problem along with the recentlydeveloped engineered likelihood function technique forquantum amplitude estimation. The study has revealedboth challenges towards quantum advantage and oppor-tunities for improving the quantum algorithm. Resultsfrom Section V show that unless very small statistical er-ror εS is desired (roughly on the order of 10−10) in esti-

mating CVAQ, the classical Monte Carlo implementationis faster than the quantum algorithm. Here we assumethat εS is the dominant source of error, namely that allof the other error quantities in Table VII are significantlysmaller than εS . Fulfilling this assumption requires fur-ther innovation on the quantum circuit construction. Forinstance, in order to suppress εD we need to increase thenumber of qubits encoding time and price parameters,which implies that scalable circuit generation trainingmethods for both state preparation and control rotationare needed. The circuit generation methods are not onlymeasured in terms of the scaling of their computationaltime but also the accuracy of the resulting circuit con-structions, since this directly influences the εQ contribu-tion. We have identified some of the recently developedtools [43, 51, 52] that may help improving circuit gener-ation, and active work is in progress to deploy and testthose tools.

From a quantitative finance perspective, it is well-known that an European option pricing problem involv-ing a single asset is analytically solvable, without theneed for a Monte Carlo simulation. Nonetheless, ourmethod can be generalized to other settings that do re-quire stochastic simulation, such as multi-asset options,fat-tail distributions for P (s, t), and stochastic intensity

18

models [53]. As the landscape of risk analysis use casesin quantitative finance unfolds, we expect more innova-tions to be made in the future that push the frontier ofquantum computing closer to practical advantage.

VII. ACKNOWLEDGEMENTS

We thank Brian Dellabetta, Jerome Gonthier, PeterJohnson, Alejandro Perdomo-Ortiz, Max Radin for help-ful discussions and support during the project. We thankthe team at BBVA for supporting the early parts of thisstudy. All of the numerical experiments in this work werecarried out with Orquestra® [54] for workflow and datamanagement.

Appendix A: QCBM Efficiency of Learning DiscreteDistributions

In Section IV.1.1, we showed that a Quantum CircuitBorn Machine defined on 4 qubits is able to learn the de-sired target distribution associated to the chosen probleminstance. In order to perform the QCBM training, it isessential to collect a certain amount M of measurementsoutcomes that build up the measured distribution to becompared to the target one. The QCBM training per-formance changes as the number of shots taken from thequantum computer varies. We performed an initial studyto assess the efficiency of the algorithm in dependence onthe number of quantum samples M for different circuitsizes and depths. In order to quantify the QCBM effi-ciency, let’s define the following measures:

εµ = |µm − µt|εσ2 = |σ2

m − σ2t |,

(A1)

where µ and σ2 are the mean and the variance of themeasured (m) and the target (t) distribution. For sim-plicity, we limited the target distribution to one singlelog-normal peak. We computed the median of this quan-tity over 10 equivalent simulations for different value ofM and compared the scaling behaviour against the oneobtained for a classical Monte Carlo simulation (i.e. re-jection sampling).

The relation between QCBM and Monte Carlo scal-ing depends on the circuit details. Specifically, if oneincreases the problem size while keeping the depth fixed,the QCBM efficiency decreases, whereas if one increasesthe depth keeping the number of qubits fixed, the QCBMefficiency increases and eventually outperforms its classi-cal Monte Carlo counterpart. This initial analysis showsthat the “aspect ratio” of the quantum circuit matterswhen it comes to the efficiency of learning a discrete dis-tribution. That is to say: given a n qubits QCBM, itneeds to have f(n) layers in order to yield an advantageover Monte Carlo (see Table VIII).

n 2 3 4 5 6

f(n) < 2 < 2 & 4 ≥ 5 ≥ 7

TABLE VIII: Relation between number of qubits n andnumber of layers f(n) needed in the quantum circuit to yield

advantage over the classical algorithm.

Appendix B: Quantum Circuits for PreparingMatrix Product States

Our method for encoding matrix product states intoquantum circuits is based on the one in [55]. Suppose|ψ〉 is an MPS given by

|ψ〉 = 〈ψF |A[1]A[2] . . . A[n] |ψI〉 (B1)

=∑

i1,i2,...,in∈0,1

〈ψF |A[1]i1A

[2]i2. . . A

[n]in|ψI〉 |i1i2. . . in〉 ,

(B2)

where A[j] : CD → CD ⊗ C2 satisfies A[j] = A[j]0 ⊗ |0〉 +

A[j]1 ⊗ |1〉, for j = 1, 2, . . . , n, and |ψI〉, |ψF 〉 ∈ CD are

arbitrary. Without loss of generality, we assume thatD = 2d for some d ∈ Z+ (if D is not a power of two,we can embed this MPS into a larger MPS whose bonddimension is 2dlog2(D)e). We will find isometries V [1],V [2], . . . , V [n] such that

|ψ〉 = V [1]V [2] . . . V [n] |φ〉 (B3)

for some state |φ〉 ∈ CD by a sequence of singular valuedecompositions (SVDs). Specifically, we start by writing

〈ψF |A[1] = V [1]M [1], (B4)

where V [1] is the left unitary matrix in the SVD of theleft-hand side, and M [1] is the remaining part of the SVD.Then we construct the other isometries by the followinginduction:

(M [k] ⊗ I)A[k+1] = V [k+1]M [k+1], (B5)

where V [k+1] comes from the left unitary matrix in theSVD of the left-hand side, and M [k+1] is the associatedremaining part of the SVD. After n applications of SVDsfrom left to right, we set

|φ〉 = M [n] |ψI〉 , (B6)

obtaining Eq. (B3) as desired. It is easy to show that V [k]

has dimension min(2D, 2k) × min(D, 2k). This impliesthat we can embed V [k] into a 2D-dimensional or 2k-dimensional unitary U [k], depending on whether k > dor not. (Precisely, we define U [k] as follows. If k ≤ d, thenU [k] = V [k]; otherwise, U [k] can be any 2D-dimensionalunitary operator such that U [k] |0〉 |η〉 = V [k] |η〉 for all|η〉 ∈ CD.)

Now we treat |φ〉 as a d-qubit state (i.e. we use d qubitsto simulate the D-dimensional system). It follows that

|ψ〉 = U [1]U [2] . . . U [n]∣∣0n−d

⟩|φ〉 , (B7)

19

|0⟩|0⟩

|0⟩

|0⟩|0⟩

W[6]

|0⟩

U[5]U[4]

U[3]W[2]

A[1]

A[2]

A[3]

A[4]

A[5]

A[6]

=

FIG. 14: Quantum circuit for preparing a 6-qubit MPSwith bond dimension 2. The two-qubit operators W [2], U [3],

U [4], U [5] and W [6] are computed by the procedure inAppendix B.

where U [k] acts on the first k qubits if k ≤ d, and the(k − d)-th to the k-th qubits otherwise. Let Q be a d-qubit unitary operator such that Q

∣∣0d⟩

= |φ〉. Then weget

|ψ〉 = W [d+1]U [d+2] . . . U [n−1]W [n] |0n〉 , (B8)

where W [d+1] := U [1]U [2] . . . U [d+1] acts on the first d+ 1qubits, and W [n] := U [n](I ⊗ Q) acts on the (n − d)-thto the n-th qubits. Eq. (B8) leads to a quantum circuitfor preparing the state |ψ〉. Figure 14 demonstrates thiscircuit for the case n = 6 and D = 2.

The unitary operators W [d+1], U [d+2], . . . , U [n−1] andW [n] can be decomposed into one- and two-qubit gatesby using the method in [42]. Since each of these oper-ators acts on d + 1 qubits, it can be implemented by acircuit containing cd+1 CNOT gates, where [4d+1−3(d+1)− 1]/4 ≤ cd+1 ≤ (23/48)× 4d+1 − (3/2)× 2d+1 + 4/3.This implies that the number of CNOT gates in the finalcircuit is Θ(n4d) = Θ(nD2). Table IX gives estimatedCNOT counts for various n’s and D’s [56].

D=2 D=4 D=8 D=16

n=4 9 [28, 40] – –

n=8 21 [84, 120] [305, 500] [1008, 1776]

n=16 45 [196, 280] [793, 1300] [3024, 5328]

n=32 93 [420, 600] [1769, 2900] [7056, 12432]

TABLE IX: Estimated numbers of CNOT gates in thequantum circuits for MPS of various sizes and bond

dimensions. Here n is the number of qubits, and D is thebond dimension. For each pair (n,D), we give an upperbound and a lower bound on the corresponding CNOT

count. Without loss of generality, we assume thatD ≤ 2bn/2c, since any n-qubit MPS can be transformed intoan equivalent form with bond dimension at most 2bn/2c. Sothere are no entries for (n = 4, D = 8) or (n = 4, D = 16).

Appendix C: Comparing two SU(2) rotations forCRCA

We are concerned with relating the cost function of theform in Equation (35) to the norm difference ‖U − V ‖2

φ − η

η

O B

F

C′

D′

CD

EE′

G

A

FIG. 15: Geometric proof of inequality (C3).

between SU(2) rotations U and V such that

U =

(cosϕ − sinϕ

sinϕ cosϕ

), V =

(cos η − sin η

sin η cos η

). (C1)

It is clear that

‖U − V ‖2 = ‖I − V U†‖2= ‖I − exp (−i(ϕ− η)σy) ‖2= 2

∣∣∣∣sin(ϕ− η

2

)∣∣∣∣ .(C2)

A quantity that is relevant to the training error ofCRCA, as described in Equation (35), is the difference

| sinϕ− sin η|. This quantity is equal to |f(xj , ~θ)−f(xj)|when U is the SU(2) rotation in the block of the CRCAunitary indexed by j and V is the ideal rotation in thesame block with all of its matrix elements being real num-bers. We show that

| sinϕ−sin η| ≤ 2

∣∣∣∣sin(ϕ− η

2

)∣∣∣∣ , 0 ≤ η < ϕ ≤ π/2 (C3)

using a geometric illustration (Figure 15). Assume 0 <

η < ϕ < π/2. From point O we make three rays−→OA,−−→

OD and−−→OE such that ∠AOD = η and ∠DOE = ϕ− η.

Points A, D, and E form an arc>ADE on a unit circle.

Therefore |−−→DE| = 2| sin(ϕ−η

2

)|. From A we make two

lines−→AC and

−−→AB that are perpendicular to

−−→OD and

−−→OE

respectively. Therefore |−→AC| = sin η and |−−→AB| = sinϕ.

Using A as the center and−→AC as the radius, we make an

arc>CG which intercepts

−−→AB at G. Hence

|−−→BG| = | sinϕ− sin η|. (C4)

From points C and D we make perpendicular lines to

|−−→AB| that intercepts−−→AB at C ′ and D′ respectively. Since

η > 0, C is between D and F . Since−−→CC ′ is in parallel to−−→

DD′, C ′ is between D′ and F . Since ∠C ′CF = ∠DOE =

ϕ − η and−−→CF is a tangent of

>CG, G is between F and

20

C ′, which is itself between F and D′. Therefore we havethat G is between F and D′, namely

|−−→BG| < |−−→BD′|. (C5)

From D′ we make a parallel line to DE which intersects−→AE at E′. Then

|−−→BD′| < |

−−−→E′D′| = |−−→ED| = 2

∣∣∣∣sin(ϕ− η

2

)∣∣∣∣ . (C6)

Combining (C4), (C5) and (C6) yields the conclusion in(C3).

Appendix D: Derivation of the CVA observableerror bound

Here we derive the upper bound in (43). We startfrom state preparation, where we generate pG(xi) =|〈xi|GP |0n+m〉|2 to approximate a target distributionptg(xi) for xi ∈ Ω = 0, 1n+m, i = 1, · · · , 2n+m. Wecan then rewrite the error term as

∣∣∣〈ξ|Π|ξ〉 − 〈ξ|Π|ξ〉∣∣∣ =

∣∣∣∣∣∑

i

ptg(xi)〈xi|R†vR†qR†pΠRpRqRv|xi〉 −∑

i

pG(xi)〈xi|R†vR†qR†pΠRpRqRv|xi〉∣∣∣∣∣ (D1)

=

∣∣∣∣∣∑

i

ptg(xi)〈xi|R†vR†qR†pΠRpRqRv|xi〉 −∑

i

pG(xi)〈xi|R†vR†qR†pΠRpRqRv|xi〉

+∑

i

pG(xi)〈xi|R†vR†qR†pΠRpRqRv|xi〉 −∑

i

pG(xi)〈xi|R†vR†qR†pΠRpRqRv|xi〉∣∣∣∣∣ (D2)

≤∑

i

|pG(xi)− ptg(xi)|+∑

i

pG(xi)∣∣〈xi|R†vR†qR†pΠRpRqRv|xi〉 − 〈xi|R†vR†qR†pΠRpRqRv|xi〉| (D3)

The first term in (D3) can be bounded from above by√2 ·KL(pG||ptg) due to Pinsker’s inequality. The second

term can be bounded from above by∑

i

pG(xi)∣∣〈xi|R†vR†qR†pΠRpRqRv|xi〉

−〈xi|R†vR†qR†pΠRpRqRv|xi〉+〈xi|R†vR†qR†pΠRpRqRv|xi〉− 〈xi|R†vR†qR†pΠRpRqRv|xi〉| (D4)

≤∑

i

pG(xi)(∣∣∣〈xi|

(R†vR

†qR†p − R†vR†qR†p

)ΠRpRqRv|xi〉

∣∣∣

+∣∣∣〈xi|R†vR†qR†pΠ

(RpRqRv − RpRqRv

)|xi〉∣∣∣)

(D5)

≤ 2∥∥∥RpRqRv −RpRqRv

∥∥∥2

(D6)

where going from (D5) to (D6) we apply the followingargument:

∣∣∣∣∣∣〈0|V † |111〉〈111|︸ ︷︷ ︸

Π

(V − U)|0〉

∣∣∣∣∣∣

=

∣∣∣∣∣∣∣〈0|V † σ⊗3

x |0〉︸ ︷︷ ︸=|111〉

∣∣∣∣∣∣∣·∣∣〈0|σ⊗3

x (V − U)|0〉∣∣

≤ ‖V †σ⊗3x ‖2 · ‖σ⊗3

x (V − U)‖2= ‖V − U‖2.

(D7)

When applying the argument for each term in the sum

of (D5) we let U and V be unitary operators such that

U |0〉 = RpRqRv|xi〉 and V |0〉 = RpRqRv|xi〉. The opera-tor σ⊗3

x acts on the three ancilla qubits that the projectorΠ acts non-trivially on (Equation 19).

The term in (D6) can be further bounded from aboveby

∥∥∥RpRqRv −RpRqRv∥∥∥

2

=∥∥∥RpRqRv − RpRqRv + RpRqRv −RpRqRv

∥∥∥2

=∥∥∥RpRq

(Rv −Rv

)+(RpRq −RpRq

)Rv

∥∥∥2

≤∥∥∥Rv −Rv

∥∥∥2

+∥∥∥RpRq −RpRq

∥∥∥2

(D8)

≤ · · ·≤∥∥∥Rv −Rv

∥∥∥2

+∥∥∥Rp −Rp

∥∥∥2

+∥∥∥Rq −Rq

∥∥∥2

(D9)

where in going from (D8) to (D9) we essentially repeatthe same argument that leads to (D8). Combining (D9)and (D3) yields (43).

Appendix E: Quantum amplitude estimation usingengineered likelihood function (ELF)

Here we describe the quantum algorithm in [8] for ro-bust amplitude estimation. Suppose we want to estimatethe expectation value

η = cos (θ) = 〈A|O |A〉 , (E1)

21

FIG. 16: Quantum circuit for generating samples thatcorrespond to an engineered likelihood function. HereR0(y) = exp(iy

∣∣0k⟩ ⟨

0k∣∣) in which y ∈ R is arbitrary.

where |A〉 = A∣∣0k⟩

in which A is a k-qubit unitaryoperator, O = 2Π − I in which Π is a projection op-erator, and θ = arccos (η) is introduced to facilitateBayesian inference later on. For the CVA problem,

A = RpRqRvGP is the quantum circuit for preparing the

state |A〉 =∣∣∣ξ⟩

, and Π is given by Equation (19). Then

〈A|O |A〉 = 2CVAQ/C−1, where C = M(1−R)CvCpCq

by Equation (7). So one can infer CVAQ from the esti-mate of 〈A|O |A〉.

We use the quantum circuit in Figure 16 to generatethe engineered likelihood function (ELF), which is theprobability distribution of a binary outcome d ∈ 0, 1given the unknown quantity θ to be estimated. The cir-cuit consists of a sequence of unitary operations of formsU(x) = exp(ixΠ) and V (y) = A exp(iy

∣∣0k⟩ ⟨

0k∣∣)A† in

which x, y ∈ R are tunable parameters. Specifically, af-ter preparing the ansatz state |A〉 = A

∣∣0k⟩, we apply 2L

unitary operations U(x1), V (x2), . . . , U(x2L−1), V (x2L)to it, varying the rotation angle xj in each operation.For convenience, we call V (x2j)U(x2j−1) the j-th layerof the circuit, for j = 1, 2, . . . , L. The output state ofthis circuit is

Q(~x) |A〉 = V (x2L)U(x2L−1) . . . V (x2)U(x1) |A〉 , (E2)

where ~x = (x1, x2, . . . , x2L−1, x2L) ∈ R2L contains thetunable parameters. Finally, we perform the projective

measurement Π, I−Π on this state, receiving outcomed ∈ 0, 1 with probability

P(d|~x) =1 + (−1)d 〈A|Q†(~x)OQ(~x) |A〉

2. (E3)

This Bernoulli distribution depends on θ implicitly.In practice, the quantum circuit for generating the

ELF is inevitably noisy, and the bias of the Bernoullidistribution in Eq. (E3) will be re-scaled by a factor ofthe fidelity of the circuit. Namely, if the fidelity of thecircuit is f ∈ [0, 1], then the probability of obtaining out-come d ∈ 0, 1 becomes

P(d|f, ~x) =1 + (−1)df 〈A|Q†(~x)OQ(~x) |A〉

2, (E4)

which still depends on θ implicitly.We use a Gaussian distribution to represent our knowl-

edge of θ and keep updating this distribution until it issufficiently concentrated around a single value. Specif-ically, we begin with an initial distribution of η andconvert it to the initial distribution of θ = arccos (η).Then we repeat the following procedure until conver-gence is reached. At each round, we first compute thecircuit parameters ~x ∈ R2L that maximize the informa-tion gain from the measurement outcome d (in certainsense). Then we run the quantum circuit in Figure 16with the optimized parameters ~x and receive a measure-ment outcome d ∈ 0, 1. After that, we update thedistribution of θ by using Bayes’ rule. Once this loopis finished, we convert the final distribution of θ to thefinal distribution of η = cos (θ), and set the mean of thisdistribution as the estimate of η.

We have discovered that the efficiency of this algorithmis determined by the Fisher information of the engineeredlikelihood function at each round, and proposed efficientheuristic algorithms for finding the parameters ~x ∈ R2L

that maximize this quantity. We have also found thatthe engineered likelihood function resembles a sinusoidalfunction in the critical region, and this fact allows us toperform Bayesian update efficiently without resorting tonumerical integration. See [8] for more details.

[1] Basel Committee on Banking Supervision. Targeted re-visions to the credit valuation adjustment risk frame-work. Bank for International Settlements, July 2020.https://www.bis.org/bcbs/publ/d507.pdf.

[2] Alvin Lee. The triple convergence of creditvaluation adjustment (CVA). 2015. URL:https://www.fixglobal.com/home/the-triple-convergence-of-credit-valuation-adjustment-cva/.

[3] Peter E. Kloeden and Eckhard Platen. Numerical Solu-tion of Stochastic Differential Equations. Springer BerlinHeidelberg, 1992.

[4] Michael B. Giles. Multilevel monte carlo methods. ActaNumerica, 24:259–328, April 2015.

[5] Gilles Brassard, Peter Hoyer, Michele Mosca, and AlainTapp. Quantum amplitude amplification and estimation.

2000.[6] Daniel S. Abrams and Colin P. Williams. Fast quan-

tum algorithms for numerical integrals and stochasticprocesses, 1999. arXiv:quant-ph/9908083.

[7] Daochen Wang, Oscar Higgott, and Stephen Brierley. Ac-celerated variational quantum eigensolver. Physical Re-view Letters, 122(14), April 2019.

[8] Guoming Wang, Dax Enshan Koh, Peter D. Johnson, andYudong Cao. Minimizing estimation runtime on noisyquantum computers. PRX Quantum, 2021. In press.arXiv:2006.09350.

[9] Yohichi Suzuki, Shumpei Uno, Rudy Raymond, TomokiTanaka, Tamiya Onodera, and Naoki Yamamoto. Am-plitude estimation without phase estimation. QuantumInformation Processing, 19(2), January 2020.

22

[10] Tudor Giurgica-Tiron, Iordanis Kerenidis, FarrokhLabib, Anupam Prakash, and William Zeng. Low depthalgorithms for quantum amplitude estimation, 2020.arXiv:2012.03348.

[11] Dax Enshan Koh, Guoming Wang, Peter D. Johnson,and Yudong Cao. A framework for engineering quantumlikelihood functions for expectation estimation, 2020.arXiv:2006.09349.

[12] Lov Grover and Terry Rudolph. Creating superpositionsthat correspond to efficiently integrable probability dis-tributions, 2002.

[13] Dorit Aharonov and Amnon Ta-Shma. Adiabatic quan-tum state generation and statistical zero knowledge. InProceedings of the Thirty-Fifth Annual ACM Symposiumon Theory of Computing, STOC ’03, page 20–29, NewYork, NY, USA, 2003. Association for Computing Ma-chinery.

[14] Alexei Kitaev and William A. Webb. Wavefunctionpreparation and resampling using a quantum computer,2008. arXiv:0801.0342.

[15] Maris Ozols, Martin Roetteler, and Jeremie Roland.Quantum rejection sampling. ACM Trans. Comput. The-ory, 5(3), August 2013.

[16] Ashwin Nayak and Felix Wu. The quantum query com-plexity of approximating the median and related statis-tics. 1998. arXiv:quant-ph/9804066.

[17] Daniel S. Abrams and Colin P. Williams. Fast quan-tum algorithms for numerical integrals and stochasticprocesses. 1999. arXiv:quant-ph/9908083.

[18] Erich Novak. Quantum complexity of integration. Jour-nal of Complexity, 17(1):2–16, March 2001.

[19] Gilles Brassard, Peter HØyer, and Alain Tapp. Quantumcounting. In Automata, Languages and Programming,pages 820–831. Springer Berlin Heidelberg, 1998.

[20] Patrick Rebentrost, Brajesh Gupt, and Thomas R.Bromley. Quantum computational finance: Monte carlopricing of financial derivatives. Phys. Rev. A, 98:022321,Aug 2018.

[21] Nikitas Stamatopoulos, Daniel J. Egger, Yue Sun,Christa Zoufal, Raban Iten, Ning Shen, and Stefan Wo-erner. Option Pricing using Quantum Computers. Quan-tum, 4:291, July 2020.

[22] Stefan Woerner and Daniel J. Egger. Quantum risk anal-ysis. npj Quantum Information, 5(1), February 2019.

[23] Ashley Montanaro. Quantum speedup of montecarlo methods. Proceedings of the Royal SocietyA: Mathematical, Physical and Engineering Sciences,471(2181):20150301, September 2015.

[24] Dong An, Noah Linden, Jin-Peng Liu, Ashley Monta-naro, Changpeng Shao, and Jiasu Wang. Quantum-accelerated multilevel monte carlo methods for stochas-tic differential equations in mathematical finance, 2020.arXiv:2012.06283.

[25] Marco Marchioro. Pricing simple credit derivatives. 2009.http://janroman.dhis.org/finance/Kreditrisk/intro-credit-derivatives.pdf.

[26] https://www.quantlib.org/.[27] Pawel Wocjan, Chen-Fu Chiang, Daniel Nagaj, and

Anura Abeyesinghe. Quantum algorithm for approximat-ing partition functions. Physical Review A, 80(2), August2009.

[28] Vlatko Vedral, Adriano Barenco, and Artur Ekert.Quantum networks for elementary arithmetic operations.Physical Review A, 54(1):147–153, July 1996.

[29] David Beckman, Amalavoyal N. Chari, Srikrishna Devab-

haktuni, and John Preskill. Efficient networks for quan-tum factoring. Physical Review A, 54(2):1034–1063, Au-gust 1996.

[30] Thomas G. Draper, Samuel A. Kutin, Eric M. Rains, andKrysta M. Svore. A logarithmic-depth quantum carry-lookahead adder. Quantum Info. Comput., 6(4):351–369,July 2006.

[31] Steven A. Cuccaro, Thomas G. Draper, Samuel A. Kutin,and David Petrie Moulton. A new quantum ripple-carryaddition circuit, 2004.

[32] D. Maslov D. M. Miller and G. W. Dueck. A transfor-mation based algorithm for reversible logic synthesis. InProceedings 2003. Design Automation Conference, pages318–323. IEEE, aug 2003.

[33] Miller D.M. Soeken M., Dueck G.W. Reversible computa-tion. In Lanese I. Devitt S., editor, Reversible Computa-tion, volume 9720 of Lecture Notes in Computer Science,.Springer, 2016.

[34] Nathan Wiebe and Martin Roetteler. Quantum arith-metic and numerical analysis using repeat-until-successcircuits. Quantum Info. Comput., 16(1–2):134–178, Jan-uary 2016.

[35] With RLS, consider the state preparation process

|i〉|0〉 → |i〉|p(i)〉 → |i〉|p(i)〉(√

1− p(i)|0〉 +√p(i)|1〉)

and post selection on the state |1〉 for the last qubit.With proper uncomputation, one can then generate thestate Σi

√p(i)|i〉 which is relevant in the context of this

paper.[36] Daiwei Zhu, Norbert M Linke, Marcello Benedetti,

Kevin A Landsman, Nhung H Nguyen, C HuertaAlderete, Alejandro Perdomo-Ortiz, Nathan Korda,A Garfoot, Charles Brecque, et al. Training of quan-tum circuits on a hybrid quantum computer. Scienceadvances, 5(10):eaaw9918, 2019.

[37] Lei Wang Han, Wang and Zhang. Unsupervised genera-tive modeling using matrix product states. arXiv preprintarXiv:1709.01662, 2018.

[38] Pierre-Luc Dallaire-Demers and Nathan Killoran. Quan-tum generative adversarial networks. Physical Review A,98(1), July 2018.

[39] Christa Zoufal, Aurelien Lucchi, and Stefan Woerner.Quantum generative adversarial networks for learningand loading random distributions. npj Quantum Infor-mation, 5(1), November 2019.

[40] Jonathan Romero and Alan Aspuru-Guzik. Variationalquantum generators: Generative adversarial quantummachine learning for continuous distributions. AdvancedQuantum Technologies, 4(1):2000003, December 2020.

[41] Nikolaus Hansen. The cma evolution strategy: a compar-ing review. In Towards a new evolutionary computation,pages 75–102. Springer, 2006.

[42] V. V. Shende, S. S. Bullock, and I. L. Markov. Syn-thesis of quantum-logic circuits. IEEE Transactions onComputer-Aided Design of Integrated Circuits and Sys-tems, 25(6):1000–1010, 2006.

[43] Adam Holmes and A. Y. Matsuura. Efficient quantumcircuits for accurate state preparation of smooth, differ-entiable functions, 2020.

[44] Mathias Soeken, Stefan Frehse, Robert Wille, and RolfDrechsler. Revkit: A toolkit for reversible circuit design.volume 18, 07 2010.

[45] Adam Holmes, Sonika Johri, Gian Giacomo Guerreschi,James S Clarke, and A Y Matsuura. Impact of qubit con-nectivity on quantum algorithm performance. QuantumScience and Technology, 5(2):025009, mar 2020.

23

[46] The idea of implementing R0(y) =exp(iy |0n +m+ 2〉 〈0n +m+ 2|) is as follows. Wefirst compute the logical AND of the bitwise NOT of theinput by using n + m + 2 ancilla qubits and n + m + 2Toffoli gates which are organized in a binary-tree fashion.Then we perform a Rz rotation on the ancilla qubit thatencodes the result. Finally, we undo the logical AND andbitwise NOT operations, restoring the ancilla qubits totheir initial states. Each Toffoli gate can be decomposedinto 4 two-qubits gates, as implied by Theorem 8 of [42].

[47] D. S. Wang, A. G. Fowler, A. M. Stephens, and L. C. L.Hollenberg. Threshold error rates for the toric and pla-nar codes. Quantum Info. Comput., 10(5):456–469, May2010.

[48] William J Huggins, Sam McArdle, Thomas E O’Brien,Joonho Lee, Nicholas C Rubin, Sergio Boixo, K BirgittaWhaley, Ryan Babbush, and Jarrod R McClean. Virtualdistillation for quantum error mitigation. arXiv preprintarXiv:2011.07064, 2020.

[49] [8] has assumed that the two-qubit gates are arranged ina bricklayer fashion and hence M ≈ nD/2, where n is thenumber of qubits and D is the two-qubit gate depth perlayer. This assumption does not hold here, as our ansatzcircuit is highly sequential.

[50] Ryan Babbush, Jarrod McClean, Craig Gidney, SergioBoixo, and Hartmut Neven. Focus beyond quadraticspeedups for error-corrected quantum advantage. arXivpreprint arXiv:2011.04149, 2020.

[51] Frederic Sauvage, Sukin Sim, Alexander A. Ku-nitsa, William A. Simon, Marta Mauri, and Alejan-dro Perdomo-Ortiz. Flip: A flexible initializer forarbitrarily-sized parametrized quantum circuits, 2021.arXiv:2103.08572.

[52] Sukin Sim, Jonathan Romero, Jerome F. Gonthier, andAlexander A. Kunitsa. Adaptive pruning-based opti-mization of parameterized quantum circuits, 2020.

[53] Samim Ghamami and Lisa R. Goldberg. Stochas-tic intensity models of wrong way risk: Wrongway cva need not exceed independent cva. Fi-nance and Economics Discussion Series (FEDS), 2014.https://www.federalreserve.gov/econres/feds/stochastic-intensity-models-of-wrong-way-risk-wrong-way-cva-need-not-exceed-independent-cva.htm.

[54] https://www.orquestra.io/.[55] C. Schon, E. Solano, F. Verstraete, J. I. Cirac, and

M. M. Wolf. Sequential generation of entangled multi-qubit states. Phys. Rev. Lett., 95:110503, Sep 2005.

[56] Here we also give estimated numbers of single-qubit gatesin the circuit for preparing a n-qubit MPS with bonddimension D = 2d. If arbitrary single-qubit gates can beused, then the number of single-qubit gates is 6n−5 if d =1, or between (n−d)(4d+1−1)/3 and (n−d)(13×4d−1−3×2d) if d ≥ 2. If only Rx(θ), Ry(θ) and Rz(θ) gates can beused, where θ ∈ R is arbitrary, then the number of single-qubit gates is 12n−9 if d = 1, or between (n−d)(4d+1−1)and (n− d)(21× 4d−1 − 3× 2d)) if d ≥ 2.


Recommended