Will quantum computers one day manage international reserves? (Part 2)
In part one of this blog article we discussed quantum computers in general. We outlined some of their potential applications in finance, for example for optimising portfolios and pricing derivatives, but also outside the financial sector, for example for solving complex logistical tasks and factorising integers into primes. We also discussed why quantum computers can solve some problems faster than classical computers. We identified two quantum phenomena as the reason: superposition (the fact that a qubit can simultaneously be in states 0 and 1) and quantum entanglement (the fact that the state of one qubit can in some cases be derived from that of another). In this part, we will discuss specific potential applications of quantum computers in international reserves management. We will first focus on the quantum computer IBM QuantumTM, which we used in our experiments, then describe quantum algorithms that can be used for risk measurement and portfolio optimisation, and finally analyse the results of our experiments and the prospects for the future.
Published in Working Paper 2/2022
IBM QuantumTM and Qiskit
We will start by describing the most important tool we used in our experiments – a real quantum computer, or rather several quantum processors, provided by IBM. Together with several other corporations (for example Google [1], Microsoft [2], Honeywell [3], D-Wave [4] and Rigetti Computing [5]), IBM is one of the pioneers of commercial quantum computing. Although these are naturally profit-oriented projects, IBM offers some of its quantum processors for research and study purposes free of charge as a web service [6]. Virtually anyone can thus create a user account and start to experiment with quantum computation. Several five-qubit quantum processors are available for these purposes. IBMs’ partners – universities and some companies (for example J.P. Morgan Bank, which we mentioned in part one of our blog article) – have access to a 127 qubit processor, and IBM plans to set up a processor with more than 1,000 qubits [7] for them by 2023.[1] Five qubits is a relatively low number for practical application, but these processors are fully sufficient to demonstrate quantum algorithms. IBM also offers quantum processor simulators (software running on a classical computer that simulates quantum processors) on this platform for testing and debugging purposes.[2]
IBM’s quantum processors can be programmed in two ways: at quantum gate level, that is, similar to a classical computer at the processor instruction level (in an assembler language), or using a higher-level programming language called Qiskit [8]. Composing directly from quantum gates is mainly suitable for education purposes, but it can also be used for simple algorithms. IBM offers a user-friendly graphical environment where the algorithm can be composed using the drag-and-drop method and the computation results can be visualised (using histograms, for example). More sophisticated software can be written in Qiskit, which is essentially an extension of Python. The latter is widespread in the financial community. In addition, all the Python libraries can be used to combine quantum and classical calculations with ease. The Qiskit libraries contain not only frequently used quantum algorithms (some of which we employed), but also whole modules focused directly on specific areas of human activity, such as quantum chemistry, optimisation and, of course, finance, which is the most important field for us. Another advantage of the IBM environment is that one can program directly in the IBM QuantumTM web interface without installing additional local software[3] (although that option also exists).
Risk measurement using a quantum computer
We now turn to the individual problems and the algorithms we used to solve them. We will start with risk measurement, a key issue in finance. We measured Value-at-Risk (VaR) and Conditional VaR (CVaR). The VaR metric indicates the maximum loss we will suffer in, for example, 95% of market cases (99% is also frequently used). The problem is, however, that the remaining 5% (or 1%) of cases may involve relatively low, but also extreme, losses. These remaining cases are captured by CVaR, which is the average loss in the worst 5% (1%) of cases. Both metrics are evidently of a statistical nature and can therefore be quantified on the basis of a known profit/loss probability distribution.
“Loading” this probability distribution into qubits is the first step towards applying quantum computing for risk measurement. As mentioned in part one of this blog article, qubits can be in superposition and the probability of a measurement result can differ according to the “mixing ratio” between the states the qubits may be in. So, if we can set the superposition of the qubit states to match the profit/loss distribution, we have successfully performed the first step. Each qubit measurement result then corresponds to a particular profit/loss.[4]
The second step is to calculate certain statistical characteristics of the probability distribution – in this case VaR and CVaR, although the algorithm also enables computation of other statistical variables, such as the mean, the median and the standard deviation. We calculate the statistical variables using special quantum gates. We manipulate one auxiliary (“ancilla”) qubit on the basis of the superposition representing our probability distribution. The probability that the ancilla qubit will be in state 0 or 1 after the measurement therefore changes. By repeating the calculation and measurement process, we can determine the probabilities of the resulting state of the ancilla qubit and used them to derive the value of our risk metric. This is because there is a mathematical relationship between the probability of state 1 of the ancilla qubit and the value of the risk metric.
Although this approach may seem complicated at first glance (in fact, it merely involves calculating simple descriptive statistics), its main advantage is that it provides quadratic speedup over classical computing [9]. So, the algorithm will certainly be useful for performing calculations on large amounts of data, i.e. for handling the large numbers of portfolios and long time series used a basis for determining the profit/loss distribution.
Quantum optimisation - “the binary way”
Besides risk measurement, another area linked with international reserves (and investment in general) is portfolio optimisation. This consists in maximising returns at the lowest possible risk, subject to certain conditions regarding, for example, the shares of particular assets or currencies. Quantum computers offer usable algorithms in this field as well. The first is the quantum approximate optimization algorithm (QAOA) [10], which can find the minimum of a function with binary variables (i.e. variables that take values of 0 or 1).[5]
When constructing the optimal portfolio, we encounter the binary approach if, from a list of assets (such as a market index), we choose only a limited number of issues to include in the portfolio and simultaneously want to maximise the return and minimise risk [11]. The binary variable takes the value of 1 if the asset is included in the portfolio and zero if it is not. Assets with a higher return increase the value of a particular function (the optimisation criterion) more significantly than those with a lower return, while those with a higher risk lower the value of the optimisation criterion more significantly than those with a lower risk. The aim is to find the portfolio for which the optimisation criterion is maximised, in other words to find the best trade-off between return and risk.
In general, tasks with binary variables are hard for classical computers to perform, especially when there is a large number of variables (see the travelling salesman problem in part one of this blog article). However, binary optimisation can be converted into simulation of a quantum system of a particular kind, and simulation of quantum systems is exactly what quantum computers have been designed to do. This particular quantum system is called a spin glass, which is a special class of magnetic material.[6] Binary variables representing assets correspond to the individual particles of this material. The QAOA algorithm then looks for the configuration of particles in the spin glass that minimises the energy level. In our portfolio optimisation task, it will find the combination of assets associated with the maximum risk-corrected return.
Let’s now take a closer look at how the QAOA works. As we said, the algorithm simulates a quantum system. This means it must have a description of the system that tells it how to perform the simulation. Each quantum system can be described by a Hamiltonian, an energy operator that describes how the state of the system will evolve over time.[7] For each Hamiltonian one can find the ground state, i.e. the state corresponding to the lowest energy level to which each system naturally tends. This state is the optimum we are looking for. The QAOA then searches for the optimum of our task by first setting the quantum computer to the ground state of the initial Hamiltonian. This Hamiltonian is “simple enough” and its ground state is therefore known from an exact calculation. Then we start changing the system’s Hamiltonian so that the initial Hamiltonian is gradually converted into the Hamiltonian describing our optimisation task. Between these two “extremes”, the Hamiltonian is a mix of the initial one and that of our task. If we carry out this process “carefully enough”, we remain in the ground state of the instantaneous Hamiltonian (this is known as the adiabatic theorem). At the end, the system is described solely by the Hamiltonian representing our task, hence the ground state obtained represents the optimal solution to our task.
The QAOA is a hybrid algorithm, which means that part of the computation is done on a classical computer. The classical computer takes the result of one simulation, uses it to reprogram the quantum one and runs more simulations. This process is iterated until the optimal solution is found.
In addition to Hamiltonian simulation on quantum gate-based computers, there are special quantum processors tailored exclusively to binary optimisation tasks, the principle of which is based on the adiabatic theorem. Such specialised processors are offered, for example, by D-Wave [4].
Unlike the previous algorithm, the QAOA has not been rigorously proven to be faster than classical computers. However, some studies [12][13] provide empirical evidence that the QAOA performs better than the optimisation algorithms commonly used these days.
Quantum portfolio optimisation by solving a system of equations
A disadvantage of the binary approach to optimisation is that it only decides whether or not to include an asset in the portfolio. In practice, however, we often ask what share to give an asset in our portfolio. For example, we may be solving the task of minimising risk given a required return. Such a task can be converted to a system of linear equations [14]. It is here that quantum computers can be applied again, thanks to the HHL algorithm, which allows us to solve systems of equations with exponential speedup over classical computers, as we mentioned in our previous blog article.[8]
The HHL algorithm considers a system of equations to describe the energy state of a quantum system. Again, we are converting the task to simulation of a quantum system, and the system of equations we are solving is the Hamiltonian of the system. As we know, quantum systems can only be found in certain exactly defined energy states associated with exactly defined energy values. The first step of the HHL algorithm is to identify these energy values and their corresponding quantum states. In the next step, a new combined state (superposition) representing the solution to our system of equations is created from these individual levels and states.[9] This state is then stored in qubits for further use.
Here, however, we run into one of the pitfalls of the HHL algorithm. Measuring the entire quantum state representing the solution of the system is very costly in terms of computing resources and hence completely erases the exponential speedup delivered by the HHL algorithm. However, the solution can be used for other purposes [14], such as assessing whether the optimal portfolio corresponds to the current portfolio or how much it differs from it. In this case, it is sufficient to encode the composition of the current portfolio into a superposition of qubits (as in the case of the profit/loss probability distribution) and compare this newly acquired state with the state represented by the solution obtained by the HHL algorithm.[10] The comparison of the superpositions of the two groups of qubits can be converted to the measurement of only one ancilla qubit. As a result, we will not lose the speedup gained thanks to the HHL algorithm. The result of the measurement will answer the question of how similar the current portfolio is to the optimal one.
A brief look at quantum memories
Before looking at our results, we will briefly discuss quantum memories. Like its classical counterpart, a quantum computer needs memory to store input and output data and software. Unfortunately, there is currently no quantum version of operating memory (qRAM) in the quantum computers available today. All data must therefore be stored in quantum processor qubits or gate parameters. If the inputs change, the processor must be reprogrammed. This makes the situation similar to classical computers in their very beginnings in the late 1940s. As a result, we are losing some of the potential that quantum computers offer. For example, the HHL algorithm assumes that inputs are stored in qRAM. Similarly, preparing the states representing the portfolio composition or the profit/loss probability distribution would be easier if qRAM were available. Besides the problem of ensuring quantum state coherence (mentioned in the previous instalment of this blog article), the creation of functional qRAM is a critical point for the further expansion of quantum computers. Intensive research is therefore under way in this field [17][18]. In addition, at the end of November 2021 Qunnect announced the sale of the first commercial qRAM to Brookhaven National Laboratory (a research institute of the US Department of Energy)[19]. For the time being, however, the Qunnect memory is intended only for quantum communication networks using photons,[11] not semiconductor quantum chips.
What results did we obtain?
Let’s now move on to the specific tasks we solved on the quantum computer. As already mentioned, the fee-free IBM quantum processors have only five qubits (six processors of this size are available in total). Our models are greatly limited by the low number of qubits and are therefore toy models used merely to demonstrate the concept.
Our first task was to measure the VaR and CVaR metrics. In addition, we calculated the mean and the standard deviation. In particular, we calculated these parameters for the daily returns from a fixed-income dollar portfolio, using a time series starting in 2018 and ending in August 2021 to estimate the profit/loss distribution. We encoded the distribution obtained into a quantum state of first three and then four qubits. In the first case, therefore, the distribution was coarser. In other words, the bins of the profit/loss distribution histogram were wider, leading to a wider confidence interval for the estimate of the statistical variable concerned. In both cases, we first ran a simulation of the quantum algorithm to check the correctness of our implementation. We should add that we constructed the algorithm at the gate level, with the design of the quantum circuit being controlled by classical software in Python/Qiskit. We then switched to the quantum hardware itself, specifically four processors (Belem, Bogota, Lima and Yorktown[12]). The calculation of the mean was successful, but for the other variables the deviations from the correct values were unfortunately large. The deviations for the three qubits case were smaller than those for four qubits. As already mentioned, the algorithm itself was designed correctly, as the simulation results matched the expected values. We believe the main reasons for the miscalculation were noise, which interfered with the quantum state coherence, and limited accuracy in the parameters of some quantum gates. Unfortunately, noise is currently an integral part of quantum processors, although significant progress has been made compared with a few years ago [20]. At that time, we would not even have been able to quantify the mean correctly.
Another task was to find the optimal portfolio composition using a system of linear equations. In this case, we chose as an example the search for the optimal ratio between bonds and stocks in a US dollar-denominated portfolio. The expected return, the standard deviation of the return and the correlation of the returns on the two asset classes were based on data on the equity and fixed-income USD portfolio, again between January 2018 and August 2021. For the required return, we searched for the weights of the two assets. Once again, this is a very simple task that can be solved by hand. However, our goal was to determine whether quantum algorithms can help at all in this area. We used the implementation of the HHL algorithm in the Qiskit library for the solution. Again in this case, we first used the simulator to check the correctness of the design. Unfortunately, the simulation returned wrong results. After several tests, we found that the implementation of the HHL algorithm in Qiskit was unable to work with the systems of equations created in our task. However, according to an unofficial message from IBM [21], this situation should soon be rectified, so we will certainly return to this task in the future. However, to familiarise ourselves with the HHL algorithm, we performed tests with other systems of equations and also implemented the HHL algorithm directly at the gate level.[13] The simulations now showed the correct results, but the calculation on the quantum hardware was not very successful. We identified the complexity of the circuit as the main problem. For example, 4x4 systems gave rise to a circuit consisting of more than 13,000 gates, whereas the circuit for a 2x2 system contained less than 200 gates. Unfortunately, the short quantum state coherence time prevented us from successfully completing the calculation even in the case of a 2x2 system.
Our final task again involved portfolio optimisation, this time using binary optimisation. Specifically, we investigated the choice of equities to invest in. We should add that this is not a task we perform at the CNB in relation to the reserves. Our equity investment strategy consists in accurate replication of market indices, for example the S&P 500. We chose this type of task only as a representative of the use of binary optimisation in finance. But let’s get back to our task. From a set of five equities (the maximum number given the number of qubits in the quantum processor) of US semiconductor industry companies,[14] we selected three for simultaneous profit maximisation and risk minimisation. As with the previous tasks, the returns and their variances and correlations were based on the prices of the individual shares between January 2018 and August 2021. To solve this task, we used the QAOA implementation in the Qiskit libraries. Again, we first tested the calculation on the simulator. The results were in line with expectations.[15] We then carried out the calculation on all six available IBM quantum processors (Belem, Bogota, Lima, Manila, Quito and Santiago). The expected results were returned in all cases. QAOA is simpler than the previous algorithms in terms of circuit construction. Despite the issues with noise in the other algorithms, the quantum processors were therefore able to find the correct solution. Binary optimisation could soon become the first area of deployment of quantum computers on an “industrial scale” [23].
So what is the future of quantum computers in international reserves management?
Although the above results are not very optimistic, we have shown generally that quantum computing could be used in international reserves management in the future. Although it is still suffering from “teething problems”, we should bear in mind that this is a new technology that has only recently left the laboratory. The time for which quantum state coherence can be maintained is now the main problem. However, a number of scientific institutions and commercial organisations are currently working to remove this obstacle. The absence of practically usable quantum memories (qRAM) is an equally pressing problem. However, intensive research is under way in this area as well, and some of the results are very encouraging.
We should certainly not be discouraged by these problems, because it is the search for possible applications and the interest in the technology itself that are motivating its further development. Moreover, new technology is often underestimated. For example, Thomas J. Watson (IBM Chairman and CEO 1914–1956) said in 1943 that he saw a world market for about five computers [24], and just look how fast computer technology developed in the years that followed!
The benefits quantum computers could yield in the future are considerable. They range from the development of new medicines and materials (quantum chemistry applications) through help in tackling climate change [25] to applications in finance. In the last-mentioned area, they could help especially in the pricing of complex derivatives [26] and the simulation of market developments [12], in addition to the tasks we addressed in our research.
Over the next few years, though, quantum computing will be of interest mostly to researchers and developers. However, we should use this time to get acquainted with it, assess its possible applications and prepare for its period of mass expansion. In the field of central banking, we hope that our research has contributed to these first steps.
References:
[2] https://azure.microsoft.com/en-us/solutions/quantum-computing/#microsoft-approach
[3] https://www.honeywell.com/us/en/company/quantum
[6] https://quantum-computing.ibm.com/docs/
[7] IBM (2021): “The Quantum Decade”. On-line: https://www.ibm.com/thought-leadership/institute-business-value/report/quantum-decade
[8] https://qiskit.org/documentation/
[9] WOERNER, S. AND D. J. EGGER (2019): “Quantum Risk Analysis.” Nature Partner Journal: Quantum Information, 5(15).
[10] FARHI, E., J. GOLDSTONE, AND S. GUTMANN (2014): “A Quantum Approximate Optimization Algorithm.” arXiv:1411.4028v1 [quant-ph].
[11] ELSOKKARY, N., F. S. KHAN, D. L. TORRE, T. S. HUMBLE, AND J. GOTTLIEB (2017): “Financial Portfolio Management using Adiabatic Quantum Optimization: The Case of Abu Dhabi Securities Exchange.” IEEE High-performance Extreme Computing 2017 conference proceedings.
[12] DING, Y., L. LAMATA, J. D. M. GUERRERO, E. LIZASO, S. MUGEL, X. CHEN, R. ORÚS, E. SOLANO, AND M. SANZ (2019): “Towards Prediction of Financial Crashes with a D-Wave Quantum Computer.” arXiv:1904.05808v2 [quant-ph].
[13] HARWOOD, S., C. GAMBELLA, D. TRENEV, A. SIMONETTO, D. BERNAL, AND D. GREENBERG (2021): “Formulating and Solving Routing Problems on Quantum Computers.” IEEE Transactions on Quantum Engineering, 2.
[14] REBENTROST, P., AND S. LLOYD (2018): “Quantum computational finance: quantum algorithm for portfolio optimization.” arXiv:1811.03975 [quant-ph].
[15] MORRELL, H. J. AND H. Y. WONG (2021): “Step-by-Step HHL Algorithm Walkthrough to Enhance the Understanding of Critical Quantum Computing Concepts.” arXiv:2108.09004v2 [quant-ph].
[16] MOTTONEN, M., J. J. VARTIAINEN, V. BERGHOLM, AND M. M. SALOMAA (2005): “Transformation of quantum states using uniformly controlled rotations.” arXiv:quantph/0407010v1.
[17] GIOVANNETTI, V., S. LLOYD2, AND L. MACCONE (2008): “Quantum random access memory.” Physical Review Letters, 100.
[18] ZHONG, M., M. P. HEDGES, R. L. AHLEFELDT, J. G. BARTHOLOMEW, S. E. BEAVAN, S. M. WITTIG, J. J. LONGDELL, AND M. J. SELLARS (2015): “Optically Addressable Nuclear Spins in a Solid with a Six-hour Coherence Time.” Nature, 517.
[19] “Qunnect Announces Sale of First Commercial Quantum Memory” https://www.prnewswire.com/news-releases/qunnect-announces-sale-of-first-commercial-quantum-memory-301428820.html, issued 19 Nov 2021, cited 23 Nov 2021
[20] GYENIS, A., A. D. PAOLO, J. KOCH, A. BLAIS, A. A. HOUCK, AND D. I. SCHUSTER (2021): “Moving beyond the transmon: Noise-protected superconducting quantum circuits.” arXiv:2106.10296v1 [quant-ph].
[21] https://github.com/Qiskit/qiskit-terra/issues/6880, cited 27 Aug 2021
[22] CAO, Y., A. DASKIN, S. FRANKEL, AND S. KAIS (2012): “Quantum circuits for solving linear systems of equations.” Molecular Physics, 110(15–16).
[23] PRESKILL, J. (2018): “Quantum computing in the NISQ era and beyond.” Quantum, 2.
[24] NIELSEN, M. A. AND I. L. CHUANG (2010): “Quantum Computation and Quantum Information”, 10th Anniversary Edition. Cambridge University Press., pg. 277
[25] SIMPSON W. (2021): “Six Ways Quantum Computing Can Help Tackle Climate Change”. On-line: https://quantumcomputingreport.com/six-ways-quantum-computing-can-help-tackle-climate-change/
[26] BOULAND, A., W. DAM, H. JOORATI, I. KERENIDIS, AND A. PRAKASHA (2020): “Prospects and challenges of quantum finance.” arXiv:2011.06492v1 [q-fin.CP].
Keywords
Quantum computers, international reserves, portfolio optimisation, risk measurement
JEL Classification
C61, C63, G11
[1] These processors are based on superconducting technology, which we briefly described in part one of our blog article.
[2] Simulators are of course not suited to practical tasks, due to exponential growth in memory requirements and computational time as the number of qubits increases, as mentioned in part one of this blog article. However, they are invaluable for testing and debugging purposes.
[3] In the web interface, Python runs in interactive Jupyter Notebooks.
[4] The profit/loss value is encoded as a binary number, i.e. a string of ones and zeros, indicating the histogram bin.
[5] Although the QAOA algorithm is designed to search for the minimum, it will also find the maximum if we put a minus sign before the maximized function.
[6] Materials can be classified into several classes in terms of their magnetic properties. For example, iron and cobalt are ferromagnetic materials and remain magnetised after the magnetic field is removed. By contrast, paramagnetic materials such as aluminium and platinum lose their magnetisation almost immediately after the magnetic field is switched off. Spin glass lies on the borderline between paramagnets and ferromagnets and loses its magnetisation slowly (linearly) after the external magnetic field is no longer presented.
[7] Note that the Hamiltonian is a part of the well-known Schrödinger equation, which is one of the central equations of quantum theory and whose solution is the time evolution of the state of the quantum system.
[8] We should add that after certain modifications of the task, the weights of individual assets can also be found with the help of the QAOA. However, this modification requires “high consumption” of qubits and we are not guaranteed speedup compared with the HHL algorithm.
[9] This description of the algorithm is greatly simplified. An accurate description requires knowledge of linear algebra. Readers with a deeper interest in the subject can find technical details in articles [14] and [15].
[10] It should be noted that the design of circuits for generating some quantum states can also be exponentially time-consuming in the number of qubits [16], so these circuits will need to be replaced by quantum memory in the future (see the next paragraph).
[11] The memory is based on a photon being captured by an electron in an atomic shell (data storage) and released (reading) using a modulated laser beam. The beam allows the originally captured photon to be reconstructed. If we merely waited for the excited electron to emit the photon, the photon would have random properties, so the information stored would be lost. Of course, the electron will not stay in the excited state indefinitely. A task for further research is to extend this time as much as possible (again, we are confronted with the issue of ensuring quantum state coherence).
[12] This processor was retired shortly after our calculations were carried out, as IBM says it is an outdated model.
[13] Based on [22].
[14] The choice of this segment of the economy has nothing to do with the CNB’s investment strategy. The author of this blog is merely interested in the history of this industry.
[15] Again, the task can be solved manually. For five equities there are 25 = 32 possible forms of the portfolio. By simply plugging combinations of zeros and ones into the optimisation criterion, we then obtain its values and select the best one. In addition, only combinations of zeros and ones that include three ones can be used (as we require three equities).