Abstract
Compact data representations in quantum systems are crucial for the development of quantum algorithms for data analysis. In this study, we present two innovative data encoding techniques, known as QCrank and QBArt, which exhibit significant quantum parallelism via uniformly controlled rotation gates. The QCrank method encodes a series of real-valued data as rotations on data qubits, resulting in increased storage capacity. On the other hand, QBArt directly incorporates a binary representation of the data within the computational basis, requiring fewer quantum measurements and enabling well-established arithmetic operations on binary data. We showcase various applications of the proposed encoding methods for various data types. Notably, we demonstrate quantum algorithms for tasks such as DNA pattern matching, Hamming weight computation, complex value conjugation, and the retrieval of a binary image with 384 pixels, all executed on the Quantinuum trapped-ion QPU. Furthermore, we employ several cloud-accessible QPUs, including those from IBMQ and IonQ, to conduct supplementary benchmarking experiments.
Subject terms: Quantum information, Applied mathematics, Computer science, Scientific data, Genomics
Introduction
Quantum computing is believed to open doorways to novel methods and algorithms that can outperform their classical counterparts1. Among the most prominent examples of quantum algorithms are Shor’s prime factoring algorithm2 and Grover’s unstructured search algorithm3. In addition, recent results show that quantum computers have great potential to solve problems in machine learning4–9. Similarly, there has been considerable work in quantum image processing10–14. However, despite this progress, the current era of noisy intermediate-scale quantum (NISQ) devices still calls for basic research to understand better the capabilities and applicability of quantum information science (QIS)15.
A crucial problem when designing and implementing quantum algorithms that process classical data is the data encoding problem16, which relates to how data is encoded in the quantum state of a qubit register, and is closely related to the data input problem. In the encoding process, there is a trade-off between the efficient use of the Hilbert space and the computational complexity of the algorithms leveraging the quantum representation9.
The main contributions of this paper are related to the data encoding problem and how to address it on NISQ hardware to implement quantum data analysis algorithms in practice. First, we introduce an extension of the uniformly controlled rotation gate17 that enables concurrent execution of two-qubit CX gates on the address and data qubits of the memory. We call this a parallel uniformly controlled rotation gate and it can be viewed as a generalization of the parallel Toffoli gate decomposition18 to more than 2 address lines.
We implement our circuits in two quantum data encoding schemes: a QCrank angle encoding for continuous data and a QBArt basis encoding for discrete data in binary representation. Second, we present the results of a collection of data encoding and analysis experiments demonstrated using real quantum processors at an unprecedented scale for different data types, including images, DNA sequences, and time-series.
The three most well-known types of data encoding are basis encoding, amplitude encoding, and angle encoding19. Assume that the input data is an -dimensional vector . Basis encoding is mainly used when discrete data must be arithmetically manipulated in a quantum algorithm. In this case, is a binary string obtained from the original classical data. For example, if the classical data is the vector [0, 1, 2, 3], then . This binary string is encoded in the computational basis states of a qubit system, i.e., . In the case of amplitude encoding, a (normalized) real- or complex-valued data vector is directly encoded in a -dimensional Hilbert space through the amplitudes of the state . Finally, in an angle encoding, each in is embedded through single-qubit rotations, for example, as in case of a Pauli-Y rotation.
As previously mentioned, the problem of quantum data encoding is closely related to research on quantum data input and quantum memory. Analogous to classical computer memory, the two main designs under investigation within the field of quantum computing are quantum read only memory (QROM)20 and quantum random access memory (QRAM)18,21. Both are based on coherent access to data stored in quantum memory addresses that can be queried within a quantum algorithm. Theoretical designs vary from quantum circuit implementations to proposals for native hardware implementations of quantum memory.
This work extends data encodings predominantly used in quantum image processing, usually called quantum image representations (QIR), and have a close connection to QROM/QRAM. A variety of QIR methods have been developed22. The (improved) flexible representation of quantum images ([I]FRQI)23–25, the (improved) novel enhanced quantum representation ([I]NEQR)26,27, the multi-channel representation of quantum images (MCRQI/MCQI)28,29, and the (improved) novel quantum representation of color digital images ([I]NCQI)30,31 are among the most powerful existing QIR methods. Our previous work proposed an overarching encoding framework called QPIXL32 that unifies all QIRs mentioned above. In the QPIXL framework, every QIR can be written as
1 |
where is an encoding of the pixel colors in the qubit state and an encoding of the pixel positions in the qubit state32. All QIRs that are commonly considered in the literature use a straightforward basis encoding for the pixel position information. However, the color mapping varies for different QIRs. For example, NEQR employs a basis encoding for the pixel color information, FRQI uses an angle encoding in a single qubit. In contrast, IFRQI and MCRQI/MCQI use angle encodings over multiple qubits.
The second contribution of QPIXL is an asymptotically optimal quantum circuit implementation to prepare QIRs based on uniformly controlled rotation () gates17. A is a multi-parameter, multi-qubit gate acting on control or address qubits and 1 target or data qubit. A UCR gate performs a single-qubit rotation of the data qubit around a fixed axis on the Bloch sphere. Here, the rotation angle depends conditionally on the computational basis state of the address qubits. As such, it is parametrized by rotation angles as there are different basis states in the address register. For example, assuming Pauli-Y rotations,
2 |
the unitary matrix corresponding to a gate with the final qubit as the data qubit is given by the following block diagonal matrix,
3 |
where is a vector of rotation angles. It follows that32
4 |
To recover through projective measurement of in the computational basis, we sample from the probability density function (PDF) , where and . The input angles can be uniquely recovered by measuring the PDF,
5 |
provided that . The input data should be rescaled to rotation angles in this restricted range, e.g., , where A is a scaling factor such that the angles are mapped to .
A straightforward circuit implementation of the gate in Eq. (3) consists of fully-controlled gates, where, for , the rotation angle is given by and the address qubits are controlled on the state . An optimized circuit implementation existing of a depth- sequence of two-qubit CX gates and uncontrolled single-qubit rotations17 reduces the quantum resources32 at the cost of an increased classical overhead to solve the linear system
6 |
for the rotation angles . The angles are the parameters that are used in rotations of the compact circuit implementation for the gate in Fig. 1a. The linear system (6) is a Walsh-Hadamard transformation with Gray ordering, explained in more details in “Theoretical analysis of permuted gates” in the Supplementary Information. It can be solved efficiently classically in operations through a Fast Walsh-Hadamard Transform (FWHT)32, where N denotes the length of the input sequence.
In another related work, we proposed FABLE33, which leverages compact and circuits to generate block-encodings of matrices, a widely used primitive in quantum linear algebra algorithms such as the quantum singular value transformation34,35.
Our new data encoding QCrank is an extension of the QPIXL–FRQI and MCRQI angle encodings. It uses parallel single-qubit rotations and CX gates acting on disjoint qubit pairs leading to much shorter circuits with a high degree of quantum parallelism. Our new QBArt basis encoding is a QCrank derivative that generates compact circuits for QIRs which use a basis encoding for the color mapping such as NEQR. We do consider both QCrank and QBArt in the broader context of encoding ordered data in a quantum state following Eq. (1), where the ordering of is imposed by the tensor product of states on the address and data qubits . Eq. (1) can be viewed as a generic case of a vectorized data structure with the index and encodes the value of , respectively. This general quantum index-value data structure enables a natural representation and manipulation of different types of ordered data, such as DNA sequences, complex-valued series, 2D images, and time-ordered ECG waveforms, as shown by the experiments presented in the next section and in “Further experiments using QCrank and QBArt” in the Supplementary Information. The experiments leverage QCrank and QBArt based quantum algorithms and are executed on either NISQ36 hardware or noisy simulators. This work demonstrates that today’s NISQ devices can encode and compute on classical data sets. Because of the limitations on circuit depth that NISQ devices impose, we use relatively small data sets and simple processing tasks that are straightforward for classical computers. Nonetheless, our results showcase the limits of what is currently experimentally possible in this field. At the same time, our initial proof-of-concept results unveil the true possibilities for data analysis using quantum algorithms in the future as quantum hardware evolves.
Results
In this section, we describe the main contributions of this paper, including the optimally scheduled parallel UCR gates, our new QROM encodings QCrank and QBArt, and a series of experiments with various types of data demonstrating their performance on real QPUs.
Optimally scheduled parallel UCR gates
Figure 1a illustrates the standard compact circuit implementation for a gate17 with address qubits used in the QPIXL framework32. However, the circuit implementation is not unique. The positions of the control qubits of the CX gates can be permuted cyclically, as shown in Fig. 1b. We denote as the circuit implementation of a uniformly controlled rotation with address qubits and cyclic permutations . We show all 3 possible realizations of cyclic permuted UCRs for 3 address qubits, i.e., , , and . Note that the different implementations of the gate require a permutation of the linear system (6) to compute the rotation angles. However, the angles can always be computed with an algorithm. More details are provided in “Theoretical analysis of permuted gates” in the the Supplementary Information.
The benefit of the permuted gates becomes clear when we combine multiple of them acting on different data qubits but sharing the same address qubits, as shown in Fig. 1c. In this case, the 1- and 2-qubit gates expressing the circuits with the 3 different permutations acting on 3 data qubits can be reordered to an equivalent circuit with the same critical depth as a single circuit operating on 1 data qubit. That is possible because the single-qubit rotations work on different qubits, and groups of CX gates act on different pairs of qubits. Consequently, both the and CX gates mutually commute and can be reordered to enable concurrent execution. We call this a parallel uniformly controlled rotation gate or with address qubits and data qubits. The CX-depth of a circuit is
7 |
If , Eq. (7) is a strict equality, because the CX gates within a cycle act along edges in the bipartite connectivity graph shown on the right of Fig. 1c that connect disjoint pairs of address and data qubits. Consequently, these CX gates can be executed in parallel on the quantum hardware, significantly shortening the execution time and improving the fidelity. If , we require UCR circuits but only different UCR permutations exist. Following the gate grouping shown in Fig. 1c, we again find the CX depth on the right-hand side of Eq. (7). However, for certain ratios of , we can commute independent CX and gates and regroup them in such a manner that further reduces the critical CX depth to the number of CX gates that are controlled by the address qubit with the most CX gates connected to it.
Table 1 illustrates the circuit depth advantage of the gate implementation, introduced in Fig. 1c, over a logically equivalent serial implementation that does not use the cyclic permuted but instead just combines unpermuted circuits on different data lines. In this implementation, all the CX gates in a single cycle (blue box in Fig. 1c) share the same control qubit and cannot be executed concurrently on current quantum hardware. The circuit depths reported in Table 1 are taken after transpilation. We see that the Qiskit transpiler is not able to achieve the same data starting from the serial circuit compared to the parallel circuit. The reduction ranges between to for the size of circuits we considered. This maps 1-to-1 to a similar reduction in data loading time.
Table 1.
(# address qubits) | 4 | 5 | 6 | 8 | 10 | |
---|---|---|---|---|---|---|
(# data qubits) | 4 | 5 | 6 | 8 | 10 | |
Parallel UCR | 16 | 32 | 64 | 256 | 1025 | |
Serial UCR | 32 | 81 | 193 | 1025 | 5121 | |
Reduction |
A gate implements the block diagonal unitary
8 |
with a vector of rotation angles that encode the data .
Next, we describe our new QROM encodings QCrank and QBArt, which take advantage of this novel idea of optimally scheduled parallel UCR gates.
QCrank data encoding
The quantum-parallel data encoding scheme we propose in this paper leverages the circuits to generate an encoding. To this end, we only have to prepend Hadamard gates acting on the register of address qubits of the circuit. That creates an equal superposition over all addresses as required for Eq. (1). Figure 2 shows the high-level block diagram of the QCrank circuit. We call our method QCrank as the arrangement of the CX gates in the circuit diagram in Fig. 1c resembles a crankshaft in a combustion engine.
Similar to Eq. (4), it follows from Eq. (8) that the QCrank circuit prepares the state:
9 |
where . For a fixed index i and corresponding state on the address qubits, the different rotation angles are encoded in the product state . Consequently, the data recovery process can be decoupled into independent vectors of input parameters , where denotes the vector constructed by taking all values with second index equal to j. By tracing out all data qubits except the jth, the FRQI state23 corresponding to the input parameter is retrieved. Formally,
10 |
where is the Hilbert space of all data qubits except the jth, and and are the density matrices defined in the usual manner. Eq. (10) provides a procedure to reduce the PDF on qubits measured from QCrank to PDFs on qubits for an FRQI encoding, for which we can recover the data using Eq. (5). As such, the state can be used to encode a dataset of size by mapping and/or rescaling real values to QCrank inputs . We note that QCrank uses shared address qubits with different data qubits, naturally resulting in shorter circuit depths as shown in Fig. 1. We remark that the QCrank state preparation defined in Eq. (9) is mathematically equivalent to the MCRQI encoding29.
In an idealized setting, QCrank allows for a lossless data encoding in a quantum state. In general, the purpose of the QCrank scheme is to enable potentially complex data processing or learning tasks on quantum computers. However, because of the limitations of current NISQ-era hardware, which is still severely restricted by gate infidelities, short coherence times, and cross-talk, we limit ourselves in this work to experimental demonstrations that either load and immediately recover the data through measurement, or apply a relatively simple and shallow data processing circuit.
For the task of data recovery, can in principle be measured up to arbitrary precision with the error scaling as , where is the number of shots. For a NISQ device, we cannot expect that the reconstruction error decreases monotonically just by increasing . For example, slight under- or over-rotation during the rotations on the data qubits can accumulate and distort the relationship between the intended and achieved rotation angles. Moreover, CX errors are typically an order of magnitude higher and lead to non-local errors. To compensate for all these effects, we introduce a hardware and circuit-dependent heuristic function , called adaptive calibration,
11 |
which corrects the angles obtained from Eq. (5) to allow for a near-perfect QCrank decoding on NISQ devices. For clarity, we distinguish parameters recovered with the heuristic Eq. (11) by adding an asterisk as a superscript. The construction of from calibration measurements is discussed in more detail in Methods.
Additionally, for the QCrank experiments discussed in this work, we limit the input data from continuous to discrete variables. We assume that consists of a sequence of values drawn from a discrete set . We call each possible input value a symbol and interpret K as the max value or as the bit depth in the case of digitized sequences, images, or time-series data. The advantage here is that to recover the discretized data , we only need to be able to distinguish K different values that are spaced apart. In practice, we choose , which is small enough to simplify the task of distinguishing the K different rotation angles in the presence of noise and a limited measurement budget.
Despite all of the advantages of the QCrank encoding, we must point out that there are two difficulties in using it for large-scale data processing. First, to decode the data from a QCrank encoding relies on accurately measuring the PDF to compute the data using Eq. (5), which clearly scales exponentially with the number of address qubits . For example, assuming 8 address qubits and 16 data qubits, QCrank can store real input values on a QPU using 24 qubits. To recover all real values, we need to accurately measure probabilities for all address bit-strings separately for each data qubit. Assuming we aim for an error of 1% for probabilities used in Eq. (5), it would require about shots per bit-string. Hence, about shots would be required to recover 100s of stored values with a desired precision of 1%. This estimate on the number of shots is based purely on sampling error. It does not consider the infidelity of the actual quantum hardware, which will further increase the necessary amount of shots. Using QCrank in this manner can be practical if we plan to recover only a small number of values from the QPU, in which case specific address bits can be queried on the address register. Furthermore, merely encoding and decoding classical data on a QPU is of limited interest beyond benchmarking and verification purposes. Consequently, some quantum data processing that condenses the information from the high-dimensional input space to a low-dimensional solution must be applied on the QPU before we read it out classically. Second, it is not trivial to develop data processing algorithms that act on the angle encoding used in QCrank and return a condensed result. To overcome these issues, we propose the QBArt encoding, which uses the NEQR basis encoding.
QBArt data encoding
Our Quantum Binary representation Arithmetic (QBArt) encoding retains the quantum-parallel feature of QCrank while encoding the data in the well-studied basis encoding as used in NEQR26. Formally, QBArt generates circuits with identical structure as the QCrank circuit (Fig. 2), except that the rotation angles are now restricted to two discrete values . It was noted in Figure 3 and Definition 6 in our previous work32 that serial gates can be used to prepare a NEQR state. QBArt instead leverages the compact parallel UCR circuits to efficiently prepare the NEQR state on real QPUs.
QBArt offers a lower density of information storage than QCrank because data qubits now hold only superposition of ’s instead of superposition of real numbers encoded as rotations. However, the output of QBArt is sparse, so decoding requires a far smaller number of shots. Furthermore, instead of relying on estimating the PDF and using Eq. (5) to recover the data, the observed bit-strings themselves contain the data. Theoretically, that leads to an exact data value reconstruction using a single observation. We will experimentally demonstrate that post-processing by majority voting suppresses the noise artifacts very effectively for QBArt executed on NISQ hardware. The number of data qubits used in QBArt sets the absolute precision with which a quantum computation is performed on the data, regardless of the QPU’s fidelity. Since many data processing tasks require 8 to 16 bits of precision, this is a manageable overhead for the qubit count, even for existing QPUs.
QBArt benchmarking
In this section, we run a benchmark using a QBArt circuit of fixed size on various available QPUs. We consider this to be an application-level benchmark37,38 that specifically evaluates the performance of the QPU to serve as QROM. We use this benchmark to inform our choice of QPU to run the data processing experiments described in Quantum Data Processing on H1-1.
We use a QBArt circuit with 2 address and 4 data qubits such that it can be executed on any QPU with at least 6 qubits. A circuit of this size can load 4 bit strings, each of length 4, and we use randomly generated bit strings as input data. Our benchmarks are executed on Quantinuum, IonQ, and IBMQ QPUs. The specifications of these different backends are summarized in Table 2.
Table 2.
Qubits | CX error | CX depth | # runs | |
---|---|---|---|---|
Quantinuum H1-1 | 20 | 0.003 | 8 | 1–10 |
IonQ Harmony | 11 | 0.040 | 8 | 10–15 |
IonQ Aria | 23 | 0.004 | 8 | 10 |
IBM guadalupe | 16 | 0.012 | 42 | 98 |
IBM montreal | 27 | 0.020 | 39 | 98 |
IBM jakarta | 7 | 0.008 | 42 | 98 |
A QBArt encoding generates the optimal circuit for QPUs on which a bipartite qubit connectivity is naturally available. The trapped ion QPUs (H1-1, Harmony, and Aria) natively allow such connectivity. However, for the transmon-based QPUs from IBMQ with heavy-hexagonal connectivity, the transpiled circuits become deeper due to the inevitable swap operations (see Table 2). Before transpilation, the circuit depth is 8 CX-cycles. We also run the same experiment on the noise-free Qiskit simulator for reference.
We compare shot dependence of two metrics pertaining to (1) the fidelity of individual values in the sequence and (2) the whole sequence being recovered correctly, both defined in Methods. The results are shown in Fig. 3. The trapped-ion QPUs require only 100 shots to recover the entire sequence and significantly outperform the transmon-based QPUs. The two decisive factors are differences in the fidelity of entangling gates and the versatility of the native connectivity. Only on the IBM jakarta, which has a relatively low CX-gate error, can we achieve 100% sequence fidelity but at the expense of more than 2000 shots. It requires 100 times more shots compared to an ideal noise-free QPU.
The Quantinuum H1-1 QPU achieves the highest fidelity among all the QPUs tested and will be the backend we use for the data processing experiments in the next section.
Quantum data processing on H1-1
In the following, we describe four experiments using different types of data executed on H1-1 as summarized in Table 3.
Table 3.
Experiment #1 | Experiment #2 | Experiment #3 | Experiment #4 | |
---|---|---|---|---|
Encoding | QBArt | QBArt | QBArt | QCrank |
Data type | DNA Sequence | Time-series | Binary image | |
Objective | DNA match | Hamming weight | Complex conjugate | LBL logo I/O |
QPU | H1-1 | H1-1 | H1-1 | H1-1 |
Addr. qubits | 4 | 4 | 5 | 4 |
Data qubits | 12 | 3 | 10 | 8 |
Ancillas | – | 1 | – | – |
Reset ops | 5 | – | – | – |
Input (bits) | 192 | 48 | 320 | 384⋆ |
⋆Assuming 3-bit resolution per real value encoded by QCrank
DNA sequences
The genetic code of any organism is described as a sequence of codons that encode specific amino acids. A codon consists of three nucleotides. Since 4 types of nucleotides exist in nature (A, T, G, C), there are 64 different codons, which is equivalent to 6 classical bits of information. On a quantum computer, we will use 6 qubits to encode a codon by assigning 2-qubit basis states to the 4 nucleotides,
12 |
and constructing the tensor product of 3 2-qubit states, e.g., or . To compare 2 DNA sequences made of codons, we compute on pairs of codons, requiring 12 qubits in total. Consequently, the integer values in Eq. (1), , allow the encoding of 2 codons as a quantum state , being again a tensor product of the quantum states of 2 codons.
We realize that the quantum DNA data processing primitives presented in this section are toy models based on relatively small data sets and do not provide computational advantage over far more efficient conventional algorithms. Our goal is rather to demonstrate what is possible with current generation quantum computers and motivate future work in this field.
Pattern matching
In Experiment #1, the inputs are two codon sequences of equal length, and the output is a 1-bit sequence of the same length that contains 1 for every position where the codons match and 0 elsewhere. The additional 6-bit wide output sequence encodes which nucleotides did not match. The QBArt circuit (Fig. 4(Left)) implementing Experiment #1 requires a total of 16 qubits, 4 of which are used as address qubits, and the 12 data qubits encode the codons of both sequences using 6 bits each. To save on quantum resources, we ‘recycle’ 5 qubits in the middle of the circuit by applying a reset gate, which is available on most QPUs. The total circuit depth is 68 CX-gates, of which 48 are needed by QBArt itself, following Eq. (7). We perform this DNA matching experiment on the real 20-qubit trapped-ion QPU from Quantinuum, H1-1. The input sequence A is a random snippet from the COVID-19 genome strain39. Sequence B is a copy of A, but the 6 codons in positions 5 to 10 are randomly altered, as shown in Fig. 4(Right). At the expense of 600 shots and using the majority voting technique, we achieve an exact result for all 16 codon pairs. The results shown in Fig. 4 (Right, (a)) confirm that the 6 XOR bits are all 0 when the two codons match, and some are non-zero otherwise, following the ground-truth. The bit , indicating a match, is also correctly computed, as shown in Fig. 4(Right, (b)).
Hamming weight computation
The Hamming distance between two bit-strings tells us in how many places they differ from one another; hence, when applied to codon sequences, it is an essential tool for studying the evolution of the genetic code. The Hamming weight of a binary string is defined as the number of bits set to 1. In Experiment #1 we have already computed the binary XOR value between the two codons, stored at . We will now pass them to the Hamming weight algorithm to compute the desired Hamming distance. Experiment #2 computes the Hamming weights for a 3-bit sequence of length 16. We use QBArt with 4 address qubits and 3 data qubits to encode the input and 1 ancilla qubit. The complete QBArt circuit (Fig. 5 (Left)) uses 8 qubits, has a CX-depth of 28 cycles on an all-to-all connected QPU. The experimental results from H1-1 for a pseudo-random input sequence and using 300 shots agree with the ground-truth exactly, as shown in Fig. 5(Right).
We recognize that the quantum circuit in Fig. 5 (Left) does only ‘half’ of the job since it reduces only 3 inputs to 2 output bits . However, with enough resources, we can add a second copy of the same circuit acting in parallel on the output qubits from the circuit shown in Fig. 4 (Left) and compute the missing 2nd Hamming weight, to be stored on qubits . Then, we can apply a binary adder on two 2-bit inputs, using one of the known quantum circuits40, to obtain the total Hamming distance between the 2 6-bit codons.
Complex conjugate
The time evolution of a damped pendulum described by Eq. (13) is an example of a process described by the ordinary differential equation, ODE, in the complex domain. The real and imaginary components of the complex-valued amplitude C(t) are denoted as A(t) and B(t), respectively. They are plotted independently as a parametric trajectory in blue on 3 panels in Fig. 6 (Right). The purpose of Experiment #3 is to store the time-series on the QPU, compute the complex conjugate of the amplitude, , and recover the resulting new time-series through measurement.
13 |
where and the real parameters a, b, c, d are conveniently chosen to match the initial condition and .
We use the signed integer 5-bit representation for both components and , stacked as a single 10-bit input for the QBArt circuit (Fig. 6 (Left)). Next, we invert the sign of the -data and perform the measurement. This circuit uses 5 address qubits and 10 data qubits, with a CX-depth of 64. Only one cycle of X gates is needed to invert all 32 values stored in the Hilbert space. The output values are 1’s complementary and need to be decoded as such classically, back to signed integers. This method of computing 1’s complementary was proposed in the original NEQR paper26. However, to the best of our knowledge, we present the first practical demonstration of such computation using a real QPU. To recover all 32 10-bit values exactly, the H1-1 requires shots.
2D image
Any multi-dimensional indexed dataset can always be enumerated as a 1-dimensional sequence. Therefore, our proposed quantum data encodings can directly encode 2D images as well. Experiment #4 demonstrates the QCrank encoding of the black and white image of size 384 bits shown in Fig. 7a. The recovered image from the Quantinuum H1-1 QPU is shown in Fig. 7b. At the expense of 7000 shots, QCrank recovers 97% of the pixels correctly. The location of the 12 incorrect bits is random, as shown in Fig. 7c. This experiment shows that we can store, today, a non-trivial sized image on a 12 qubit system. Moreover, an image encoded with QBArt could be manipulated by a quantum algorithm, such as filtering13.
Simulations
In addition to the four experiments executed on H1-1, we explore the robustness and versatility of our proposed encodings with additional simulated experiments presented in “Further experiments using QCrank and QBArt” in the Supplementary Information. In particular, we demonstrate the feasibility of storing and retrieving an arbitrary waveform on a QPU. We generate a synthetic electrocardiogram (ECG) time-series of length 64, digitize it with the 6-bit resolution, and encode it using QBArt. We also study the dynamic range and recovery fidelity for QCrank as a function of the simulated noise and the number of shots.
Discussion
This work presents two significant contributions to practical realization of quantum data encoding and analysis. First, the parallel uniformly controlled rotation circuits (pUCR) significantly reduce the critical circuit depth () compared to a serial implementation. The pUCR circuit leverages concurrent execution of CX gates which leads to compact circuits that are well-suited for QPUs with a high degree of connectivity, such as those based on the ion trap technology. Second, we propose two data encoding methods that use pUCR circuits: QCrank which encodes continuous real data as rotation angles, and QBArt which encodes integer data in binary representation. Finally, we present an extensive collection of experiments conducted on different real QPUs with both QCrank and QBArt encodings. We demonstrate successful quantum data encoding and analysis at a considerably larger scale than achieved in previous studies. This is enabled by two new error mitigation strategies for QCrank and QBArt respectively, to correct the noisy hardware results.
Our experiments show that the Quantinuum H1-1 QPU can reliably prepare a QCrank state that encodes 384 black-and-white pixels on 12 qubits. We introduce an adaptive calibration routine to compensate for the hardware noise and achieve a 97% recovery fidelity using 7,000 shots. This QCrank state on , qubits encodes 128 real values. It is 16 more then the state-of-the-art QML experiments in9, which extracted from the MNIST images the 8-dimensional real feature vectors in order to encode them on quantum hardware. The data encoding method in9 allow for trade-offs between ancillary qubits and circuit depth. It is an interesting topic of future research to investigate if our circuits can allow for a similar trade-off.
Our experiments with QBArt show that the H1-1 QPU can, with near-perfect fidelity, (1) simultaneously encode two DNA sequences of 16 codons on 16 qubits, using 6 bits per codon, and compute the positions where the sequences are mismatched, (2) compute the Hamming weight of a sequence of 16 3-bit integers, and (3) compute the complex conjugate of a sequence of 32 complex values with real and imaginary parts both encoded with bit-depth 5. Furthermore, we successfully use a majority voting technique to reliably identify the correct results from the measured bit strings. Finally, we report the results of a 6 qubits QBArt encoding benchmark comparing the recovered value and sequence fidelity on Quantinuum, IonQ, and IBM QPUs. This experiment highlights the superiority of ion trap QPUs over superconducting QPUs for preparing a QBArt state. That is partially attributed to the qubits connectivity: additional swap gates are required to run a pUCR circuit on superconducting QPUs.
For a fixed number of qubits, the angle encoding in QCrank and FRQI24 can store more data than a binary encoding in QBArt and NEQR26. However, data processing of angle encodings is considerably more complex than computing on binary encodings where classical binary logic operations can be efficiently converted to reversible quantum operations1. Additionally, our experiments show that binary data can be recovered with greater fidelity and using an order of magnitude fewer shots compared to data stored in an angle encoding.
Our multiplexor pUCR gates are closely related to circuit implementations used for QROM/QRAM. For example, the implementation of the bucket brigade QRAM18 leverages parallel decompositions of commuting Toffoli gates which closely resemble the pUCR circuit for the special case . It is important to note, however, that our circuits have been designed for execution in the current NISQ era, whereas QRAM implementations typically target future fault-tolerant architectures. It is likely that our pUCR circuits are suboptimal in a fault-tolerant setting because the logical synthesis of the gates will lead to a large overhead compared to18.
One exciting topic for future study that our results hint at is the potential of the compact, parallel QCrank circuits in the context of hybrid algorithms such as Variational Quantum Algorithms (VQA)41 or Quantum Machine Learning (QML)42 tasks. In this context, the rotation angles in the QCrank circuit are considered free parameters that are variationally optimized in a quantum-classical hybrid iteration where the cost function is evaluated on the QPU.
Methods
Metrics of fidelity
We define three metrics to characterize the quality of the recovered results using QCrank and QBArt encodings on noisy QPUs:
- Dynamic range () is defined as the distance between the expectation values of the reconstructed angle (Eq. 5) for the first and last symbol. It is applicable only for QCrank with input quantized into K symbols
The domain of is [0, 1], where 1 corresponds to a perfect result and 0 means that pure noise is measured.14 Recovered value fidelity (RVF) is defined as the probability to recover the correct symbol at a given position in the sequence, averaged over the sequence.
Recovered sequence fidelity (RSF) is defined as the probability of all recovered values in a sequence being correct. In the simplest case, , with N being the length of the sequence.
Adaptive calibration for QCrank
Based on experiments using a noisy simulator, we observed that the dynamic range () is reduced with increasing gate infidelity, which leads to incorrect symbol reconstruction, as shown in Supplementary Fig. S1. Therefore, we developed an adaptive calibration method to compensate for these distortions. For each input symbol, , we measure the average reconstructed output ). We then define a lookup table with thresholds ,
15 |
set halfway between those K averages, shown as horizontal dotted lines in Supplementary Fig. S1. Next, we reanalyze the same experiment and assign the discrete reconstructed symbols using a heuristic function defined by the following lookup table:
16 |
Majority voting for QBArt
For measurements subject to a low noise level, only a few of the measured bits will be incorrect, resulting in either corrupted address or corrupted data bits. To compensate for this uncorrelated noise, for each measured address, we choose the reconstructed data to be the most probable value (MPV) of all the data sub-strings collected from the measured bit-strings. This procedure is equivalent to majority voting on the data bit-strings. As the errors on the address bit-strings manifest in the same way, MPV selection also suppresses it.
Supplementary Information
Acknowledgements
All authors were supported by the U.S. Department of Energy (DOE) under Contract No. DE-AC0205CH11231. DC and RVB were supported by the Office of Advanced Scientific Computing Research (ASCR) Exploratory Research for Extreme-Scale Science. This research used resources of the National Energy Research Scientific Computing Center (NERSC), a U.S. Department of Energy Office of Science User Facility located at Lawrence Berkeley National Laboratory. This research used resources of the Oak Ridge Leadership Computing Facility, which is a DOE Office of Science User Facility supported under Contract DE-AC05-00OR22725.
Author contributions
J.B. proposed quantum parallelization scheme, designed and executed experiments, and wrote the original draft of the paper. M.A. explored algorithms computing on quantum representations. R.V.B. contributed to the proposed research. T.P defined the research objectives and the scope of the paper, and oversaw the development of the work. D.C developed mathematical representation and the core code implementation of the proposed quantum algorithms. R.V.B, E.W.B, T.P., and D.C contributed to writing the paper. All the authors reviewed and edited the paper.
Data availibility
The data generated for the QCrank and QBArt experiments can be found at https://github.com/QuantumComputingLab/qpixlpp/tree/master/examples/SciRep2024_QBArt_QCrank_Data.
Competing interests
The authors declare no competing interests.
Footnotes
Publisher's note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Contributor Information
Talita Perciano, Email: tperciano@lbl.gov.
Daan Camps, Email: dcamps@lbl.gov.
Supplementary Information
The online version contains supplementary material available at 10.1038/s41598-024-53720-x.
References
- 1.Nielsen MA, Chuang IL. Quantum Computation and Quantum Information. Cambridge: Cambridge University Press; 2010. [Google Scholar]
- 2.Shor PW. Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM J. Comput. 1997;26:1484–1509. doi: 10.1137/s0097539795293172. [DOI] [Google Scholar]
- 3.Grover, L. K. A fast quantum mechanical algorithm for database search. In Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing - STOC ’96, 212–219, 10.1145/237814.237866 (ACM Press, New York, New York, USA, 1996).
- 4.Ciliberto C, et al. Quantum machine learning: A classical perspective. Proc. R. Soc. A Math. Phys. Eng. Sci. 2018;474:20170551. doi: 10.1098/rspa.2017.0551. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Abbas A, et al. The power of quantum neural networks. Nat. Comput. Sci. 2021;1:403–409. doi: 10.1038/s43588-021-00084-1. [DOI] [PubMed] [Google Scholar]
- 6.Huang H-Y, et al. Power of data in quantum machine learning. Nat. Commun. 2021;12:1–9. doi: 10.1038/s41467-021-22539-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 7.Liu Y, Arunachalam S, Temme K. A rigorous and robust quantum speed-up in supervised machine learning. Nat. Phys. 2021;17:1013–1017. doi: 10.1038/s41567-021-01287-z. [DOI] [Google Scholar]
- 8.Schuld M, Killoran N. Is quantum advantage the right goal for quantum machine learning? PRX Quantum. 2022;3:030101. doi: 10.1103/PRXQuantum.3.030101. [DOI] [Google Scholar]
- 9.Johri, S. et al. Nearest centroid classification on a trapped ion quantum computer. npj Quantum Inf., 10.1038/s41534-021-00456-5 (2021).
- 10.Yan F, Venegas-Andraca SE. Quantum Image Processing. Singapore: Springer Singapore; 2020. [Google Scholar]
- 11.Yao X-W, et al. Quantum image processing and its application to edge detection: Theory and experiment. Phys. Rev. X. 2017;7:031041. doi: 10.1103/PhysRevX.7.031041. [DOI] [Google Scholar]
- 12.Wang Z, Xu M, Zhang Y. Review of quantum image processing. Arch. Comput. Methods Eng. 2022;29:737–761. doi: 10.1007/s11831-021-09599-2. [DOI] [Google Scholar]
- 13.Jiang S, Zhou R-G, Hu W, Li Y. Improved quantum image median filtering in the spatial domain. Int. J. Theor. Phys. 2019;58:2115–2133. doi: 10.1007/s10773-019-04103-w. [DOI] [Google Scholar]
- 14.Li P, Shi T, Zhao Y, Lu A. Design of threshold segmentation method for quantum image. Int. J. Theor. Phys. 2020;59:514–538. doi: 10.1007/s10773-019-04346-7. [DOI] [Google Scholar]
- 15.Deutsch IH. Harnessing the power of the second quantum revolution. PRX Quantum. 2020;1:020101. doi: 10.1103/PRXQuantum.1.020101. [DOI] [Google Scholar]
- 16.Lloyd, S., Schuld, M., Ijaz, A., Izaac, J. & Killoran, N. Quantum embeddings for machine learning, 10.48550/arXiv.2001.03622 (2020).
- 17.Möttönen M, Vartiainen JJ, Bergholm V, Salomaa MM. Quantum circuits for general multiqubit gates. Phys. Rev. Lett. 2004 doi: 10.1103/PhysRevLett.93.130502. [DOI] [PubMed] [Google Scholar]
- 18.Paler A, Oumarou O, Basmadjian R. Parallelizing the queries in a bucket-brigade quantum random access memory. Phys. Rev. A. 2020;102:032608. doi: 10.1103/PhysRevA.102.032608. [DOI] [Google Scholar]
- 19.Schuld, M. & Petruccione, F. Quantum models as kernel methods. In Schuld, M. & Petruccione, F. (eds.) Machine Learning with Quantum Computers, 217–245, 10.1007/978-3-030-83098-4_6 (Springer International Publishing, Cham, 2021).
- 20.Babbush R, et al. Encoding electronic spectra in quantum circuits with linear t complexity. Phys. Rev. X. 2018;8:041015. doi: 10.1103/PhysRevX.8.041015. [DOI] [Google Scholar]
- 21.Giovannetti V, Lloyd S, Maccone L. Quantum random access memory. Phys. Rev. Lett. 2008;100:160501. doi: 10.1103/PhysRevLett.100.160501. [DOI] [PubMed] [Google Scholar]
- 22.Yan F, Iliyasu AM, Venegas-Andraca SE. A survey of quantum image representations. Quantum Inf. Process. 2016;15:1–35. doi: 10.1007/s11128-015-1195-6. [DOI] [Google Scholar]
- 23.Le PQ, Dong F, Hirota K. A flexible representation of quantum images for polynomial preparation, image compression, and processing operations. Quantum Inf. Process. 2011 doi: 10.1007/s11128-010-0177-y. [DOI] [Google Scholar]
- 24.Le, P. Q., Iliyasu, A. M., Dong, F. & Hirota, K. A flexible representation and invertible transformations for images on quantum computers. In New Advances in Intelligent Signal Processing, 179–202, 10.1007/978-3-642-11739-8_9 (Springer, Berlin, Heidelberg, 2011).
- 25.Khan RA. An improved flexible representation of quantum images. Quantum Inf. Process. 2019;18:201. doi: 10.1007/s11128-019-2306-6. [DOI] [Google Scholar]
- 26.Zhang Y, Lu K, Gao Y, Wang M. NEQR: A novel enhanced quantum representation of digital images. Quantum Inf. Process. 2013 doi: 10.1007/s11128-013-0567-z. [DOI] [Google Scholar]
- 27.Jiang N, Wang L. Quantum image scaling using nearest neighbor interpolation. Quantum Inf. Process. 2015;14:1559–1571. doi: 10.1007/s11128-014-0841-8. [DOI] [Google Scholar]
- 28.Sun, B. et al. A multi-channel representation for images on quantum computers using the RGB color space. In 2011 IEEE 7th International Symposium on Intelligent Signal Processing, 1–6, 10.1109/WISP.2011.6051718 (2011).
- 29.Sun, B., Iliyasu, A. M., Yan, F., Dong, F. Hirota, K. An RGB multi-channel representation for images on quantum computers. J. Adv. Comput. Intell. Intell. Informat. 10.20965/jaciii.2013.p0404 (2013)
- 30.Sang J, Wang S, Li Q. A novel quantum representation of color digital images. Quantum Inf. Process. 2016;16:42. doi: 10.1007/s11128-016-1463-0. [DOI] [Google Scholar]
- 31.Su J, Guo X, Liu C, Lu S, Li L. An improved novel quantum image representation and its experimental test on IBM quantum experience. Sci. Rep. 2021;11:1–13. doi: 10.1038/s41598-021-93471-7. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 32.Amankwah MG, Camps D, Bethel EW, Van Beeumen R, Perciano T. Quantum pixel representations and compression for -dimensional images. Sci. Rep. 2022;12:7712. doi: 10.1038/s41598-022-11024-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 33.Camps, D. & Van Beeumen, R. FABLE: Fast approximate quantum circuits for block-encodings. In 2022 IEEE International Conference on Quantum Computing and Engineering (QCE), 104–113, 10.1109/QCE53715.2022.00029 (2022).
- 34.Gilyen, A., Su, Y., Low, G. H. & Wiebe, N. Quantum singular value transformation and beyond: Exponential improvements for quantum matrix arithmetics. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, 193–204, 10.1145/3313276.3316366 (Association for Computing Machinery, 2019).
- 35.Martyn JM, Rossi ZM, Tan AK, Chuang IL. Grand unification of quantum algorithms. PRX Quantum. 2021;2:040203. doi: 10.1103/PRXQuantum.2.040203. [DOI] [Google Scholar]
- 36.Preskill, J. Quantum computing in the NISQ era and beyond. Quantum2, 79, 10.22331/q-2018-08-06-79 (2018).
- 37.Tomesh, T. et al. Supermarq: A scalable quantum benchmark suite, 10.48550/ARXIV.2202.11045 (2022).
- 38.Lubinski, T. et al. Application-oriented performance benchmarks for quantum computing, 10.48550/ARXIV.2110.03137 (2021).
- 39.Sah R, et al. Complete genome sequence of a 2019 novel coronavirus (SARS-CoV-2) strain isolated in Nepal. Microbiol. Resour. Announ. 2020;9:e00169-20. doi: 10.1128/MRA.00169-20. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 40.Cuccaro, S. A., Draper, T. G., Kutin, S. A. & Moulton, D. P. A new quantum ripple-carry addition circuit, 10.48550/arXiv.quant-ph/0410184 (2004).
- 41.Cerezo M, et al. Variational quantum algorithms. Nat. Rev. Phys. 2021;3:625–644. doi: 10.1038/s42254-021-00348-9. [DOI] [Google Scholar]
- 42.Biamonte J, et al. Quantum machine learning. Nature. 2017;549:195–202. doi: 10.1038/nature23474. [DOI] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Supplementary Materials
Data Availability Statement
The data generated for the QCrank and QBArt experiments can be found at https://github.com/QuantumComputingLab/qpixlpp/tree/master/examples/SciRep2024_QBArt_QCrank_Data.