Skip to main content
Scientific Reports logoLink to Scientific Reports
. 2024 Feb 10;14:3435. doi: 10.1038/s41598-024-53720-x

Quantum-parallel vectorized data encodings and computations on trapped-ion and transmon QPUs

Jan Balewski 1, Mercy G Amankwah 1,2, Roel Van Beeumen 3, E Wes Bethel 4, Talita Perciano 5,, Daan Camps 1,
PMCID: PMC10858957  PMID: 38341454

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 learning49. Similarly, there has been considerable work in quantum image processing1014. 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 N=2n-dimensional vector x=x0,,xN-1. Basis encoding is mainly used when discrete data must be arithmetically manipulated in a quantum algorithm. In this case, x is a binary string obtained from the original classical data. For example, if the classical data is the vector [0, 1, 2, 3], then x=[00,01,10,11]. This binary string is encoded in the computational basis states of a qubit system, i.e., |x=|00011011. In the case of amplitude encoding, a (normalized) real- or complex-valued data vector x is directly encoded in a 2n-dimensional Hilbert space through the amplitudes of the state ixii. Finally, in an angle encoding, each xi in x is embedded through single-qubit rotations, for example, as icos(xi/2)0+sin(xi/2)1 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)2325, 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

ψ(x)=iici, 1

where ci is an encoding of the pixel colors in the qubit state and i 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 (UCR) gates17. A UCR is a multi-parameter, multi-qubit gate acting on na 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 2na rotation angles as there are 2na different basis states in the address register. For example, assuming Pauli-Y rotations,

Ry(ϕ):=e-iYϕ/2=cosϕ2-sinϕ2sinϕ2cosϕ2, 2

the unitary matrix corresponding to a UCRy gate with the final qubit as the data qubit is given by the following block diagonal matrix,

UCRy(α)=Ry(α0)Ry(α2na-1), 3

where α=α0,,α2na-1 is a vector of rotation angles. It follows that32

ψFRQI(α)=UCRy(α)(HnaI)0(na+1),=ii(cosαi20+sinαi21). 4

To recover α through projective measurement of ψFRQI(α) in the computational basis, we sample from the probability density function (PDF) |ψFRQI(α)|2=|c0,s0,,c2na-1,s2na-1|2, where ci=cosαi2 and si=sinαi2. The input angles α can be uniquely recovered by measuring the PDF,

αimeas=2arctan|si|2|ci|2,i[2na], 5

provided that αi[0,π]. The input data x should be rescaled to rotation angles in this restricted range, e.g., αi=xi/A, where A is a scaling factor such that the angles are mapped to [0,π].

A straightforward circuit implementation of the UCRy gate in Eq. (3) consists of 2na fully-controlled Ry gates, where, for i[2na], the rotation angle is given by αi and the na address qubits are controlled on the state i. An optimized circuit implementation existing of a depth-2na sequence of two-qubit CX gates and uncontrolled single-qubit Ry rotations17 reduces the quantum resources32 at the cost of an increased classical overhead to solve the linear system

θj=iWi,jαi,fori,j[2na], 6

for the rotation angles θ. The angles θi are the parameters that are used in Ry rotations of the compact circuit implementation for the UCRy 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 UCRy gates” in the Supplementary Information. It can be solved efficiently classically in O(NlogN) operations through a Fast Walsh-Hadamard Transform (FWHT)32, where N denotes the length of the input sequence.

Figure 1.

Figure 1

Different types of uniformly controlled rotation (UCR) gates with optimal connectivity graphs for qubits shown on the right. (a) Standard compact circuit implementation for a UCRy gate that was used in the QPIXL framework32 for 5 address and 1 data qubits. Square boxes denote single qubit Ry rotations. (b) All 3 possible realizations of the cyclic permuted UCRs for 3 address and 1 data qubits. (c) Parallel UCR for 3 address and 3 data qubits. The same 3 different permuted UCRy circuits using the common 3 address qubits and 3 different data qubits can be reordered to an equivalent circuit with the same CX depth as a single UCRy circuit. Blue rectangles indicate groups of 3 CX gates which can be executed concurrently in the same cycle.

In another related work, we proposed FABLE33, which leverages compact UCRy and UCRz 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 ci such as NEQR. We do consider both QCrank and QBArt in the broader context of encoding ordered data x in a quantum state following Eq. (1), where the ordering of x is imposed by the tensor product of states on the address i and data qubits ci. Eq. (1) can be viewed as a generic case of a vectorized data structure with i the index and ci encodes the value of xi, 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 UCRy gate17 with na=5 address qubits used in the QPIXL framework32. However, the UCRy 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 UCRy(na;s) as the circuit implementation of a uniformly controlled Ry rotation with na address qubits and cyclic permutations s[na]. We show all 3 possible realizations of cyclic permuted UCRs for 3 address qubits, i.e., s=0[0,1,2], s=1[1,2,0], and s=2[2,0,1]. Note that the different implementations of the UCRy gate require a permutation of the linear system (6) to compute the rotation angles. However, the angles can always be computed with an O(NlogN) algorithm. More details are provided in “Theoretical analysis of permuted UCRy gates” in the the Supplementary Information.

The benefit of the permuted UCRy 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 UCRy 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 UCRy circuit operating on 1 data qubit. That is possible because the single-qubit Ry rotations work on different qubits, and groups of CX gates act on different pairs of qubits. Consequently, both the Ry and CX gates mutually commute and can be reordered to enable concurrent execution. We call this a parallel uniformly controlled rotation gate or py(na,nd) with na address qubits and nd data qubits. The CX-depth of a py(na,nd) circuit is

dCX2nand/min(na,nd),fornd,na>0. 7

If ndna, 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 nd>na, we require nd UCR circuits but only na 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 nd/na, we can commute independent CX and Ry 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 py gate implementation, introduced in Fig. 1c, over a logically equivalent serial implementation that does not use the cyclic permuted UCRy but instead just combines unpermuted UCRy(na;0) 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 2.1× to 5× for the size of circuits we considered. This maps 1-to-1 to a similar reduction in data loading time.

Table 1.

Comparison of CX depth (dCX) for parallel versus serial implementations of the UCR gate on na=nd{4,5,6,8,10} qubits.

na (# address qubits) 4 5 6 8 10
nd (# data qubits) 4 5 6 8 10
dCX Parallel UCR 16 32 64 256 1025
Serial UCR 32 81 193 1025 5121
Reduction 2.1× 2.5× 3.0× 4.0× 5.0×

A py(na,nd)(α) gate implements the block diagonal unitary

Ry(α0,0)Ry(α0,nd-1)Ry(α2na-1,0)Ry(α2na-1,nd-1), 8

with α=αi,j a vector of nd×2na rotation angles that encode the data x.

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 py circuits to generate an encoding. To this end, we only have to prepend Hadamard gates acting on the register of address qubits of the py 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 py circuit diagram in Fig. 1c resembles a crankshaft in a combustion engine.

Figure 2.

Figure 2

High-level block diagram of the QCrank circuit encoding nd×2na real values α on a state using na+nd qubits.

Similar to Eq. (4), it follows from Eq. (8) that the QCrank circuit prepares the state:

ψqcrank(α)=12nai=02na-1ici,0ci,1ci,nd-1,ci,j=cos(αi,j/2)0+sin(αi,j/2)1, 9

where j[nd]. For a fixed index i and corresponding state i on the address qubits, the different rotation angles αi,0,,αi,nd-1 are encoded in the product state |ci,0|ci,nd-1. Consequently, the data recovery process can be decoupled into nd independent vectors of input parameters α:,0,,α:,nd-1, where α:,j 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 α:,j is retrieved. Formally,

ρFRQI(α:,j)=TrDk:kjρqcrank(α), 10

where Dk:kj is the Hilbert space of all data qubits except the jth, and ρFRQI and ρqcrank are the density matrices defined in the usual manner. Eq. (10) provides a procedure to reduce the PDF on na+nd qubits measured from QCrank to nd PDFs on na qubits for an FRQI encoding, for which we can recover the data using Eq. (5). As such, the state ψqcrank(α) can be used to encode a dataset x of size 2na×nd by mapping and/or rescaling real values xi,j to QCrank inputs αi,j[0,π]. 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, xmeas can in principle be measured up to arbitrary precision with the error scaling as Ns-1/2, where Ns is the number of shots. For a NISQ device, we cannot expect that the reconstruction error decreases monotonically just by increasing Ns. For example, slight under- or over-rotation during the Ry 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 g(·), called adaptive calibration,

αimeas=gαimeas,i[2na], 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 g(·) from calibration measurements is discussed in more detail in Methods.

Additionally, for the QCrank experiments discussed in this work, we limit the input data x from continuous to discrete variables. We assume that x consists of a sequence of values drawn from a discrete set [0,1,,K-1]. We call each possible input value a symbol and interpret K as the max value or log2(K) 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 xmeas, we only need to be able to distinguish K different αmeas values that are spaced πK apart. In practice, we choose K=8, 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 na. For example, assuming 8 address qubits and 16 data qubits, QCrank can store 28×16=212 real input values on a QPU using 24 qubits. To recover all 212 real values, we need to accurately measure probabilities for all 28=256 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 104 shots per bit-string. Hence, about 106 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 α{0,π}. It was noted in Figure 3 and Definition 6 in our previous work32 that serial UCRy 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 {0,1}’s instead of superposition of real numbers encoded as Ry 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.

Basic characteristics of the QPUs used for benchmarking. The listed average CX error is officially reported by the hardware providers at the time of circuit execution.

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.

Figure 3.

Figure 3

Reconstruction fidelity for the QBArt benchmark experiment that uses 4 4-bit integers loaded on 6 qubits. Data is shown for Quantinuum, IonQ, and IBMQ QPUs: (a) reconstructed value fidelity (b) reconstructed sequence fidelity. The H1-1 experiment with 50 shots was only performed for one input sequence, so no error bars are shown.

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.

QCrank and QBArt data processing experiments executed on Quantinuum H1-1.

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,

A=00,T=01,G=10,C=11, 12

and constructing the tensor product of 3 2-qubit states, e.g., ACT=001101 or ATG=000110. 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), ci[4096], allow the encoding of 2 codons as a quantum state a0a5b0b5, 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 pi are all 0 when the two codons match, and some are non-zero otherwise, following the ground-truth. The bit m0, indicating a match, is also correctly computed, as shown in Fig. 4(Right, (b)).

Figure 4.

Figure 4

(Left) Quantum circuit computing the match between two 16 elements long input sequence of 6-bit values A and B, encoded on qubits ai and bi, respectively. The QBArt unitary prepares the initial state. The 6 CX gates compute the XOR between bits of sequences element. The following 5 nested Toffoli gates set the output qubit m0 to state 1 if both 6-bit input pairs match. The intermediate XOR output result is also measured on qubits pi. (Right) Results obtained by the DNA sequence matching executed on Quantinuum H1-1 QPU. The algorithm correctly detects the differences between the 6 codons in positions 5 to 10, marked in red. (a) 6-bit XOR(A,B) output sequence and (b) measured match-bit, both follow the ground-truth.

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 pi. 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).

Figure 5.

Figure 5

(Left) Quantum circuit computing the Hamming weights (HW) for a sequence of 16 3-bit integers. QBArt unitary encodes the input sequence on qubits pi. The following 1st sub-ciruit computes the partial HW for inputs p1,p2. The 2nd one adds the value of p0 to the partial HW stored binary on qubits s0,s1. The final HWs are measured on qubits s0,s1, for all addresses. (Right) Results of Hamming weight computation for a sequence of 16 3-bit integers, executed on Quantinuum H1-1.

We recognize that the quantum circuit in Fig. 5 (Left) does only ‘half’ of the job since it reduces only 3 inputs p0,p1,p2 to 2 output bits s0,s1. However, with enough resources, we can add a second copy of the same circuit acting in parallel on the output qubits p3,p4,p5 from the circuit shown in Fig. 4 (Left) and compute the missing 2nd Hamming weight, to be stored on qubits s2,s3. 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 Ct on the QPU, compute the complex conjugate of the amplitude, Ct, and recover the resulting new time-series through measurement.

Ct=aexp(b+jc)t+c,CtC,fort[0,,31]At=Re(Ct),Bt=Im(Ct), 13

where j=-1 and the real parameters abcd are conveniently chosen to match the initial condition A0,B024 and A31,B311.

Figure 6.

Figure 6

(Left) QBArt circuit for Experiment #3 computing the complex conjugate of the input sequence At+jBtAt-jBt The values of A and -B are retrieved as signed int at the addresses encoded as unsigned int. (Right) Results of the complex conjugate on complex-valued time-series obtained on the H1-1 QPU are presented in magenta. The input is shown in blue. (a) and (b) show real and imaginary components of the pendulum amplitude, respectively. (c) depicts its trajectory as function of time. The conjugation operation inverts the sign of the imaginary component.

We use the signed integer 5-bit representation for both components At and Bt, stacked as a single 10-bit input for the QBArt circuit (Fig. 6 (Left)). Next, we invert the sign of the Bt-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 Bt values stored in the Hilbert space. The output -Bt 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 103 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.

Figure 7.

Figure 7

Demonstration of recovery of a black and white 384 pixels image using QCrank Experiment #4 executed on the Quantinuum H1-1 real QPU. (a) ground-truth image, (b) recovered image has 97% of correct pixels, (c) residual showing the locations of 12 incorrect pixels.

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 (dCX) 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 na=4, nd=8 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 na=nd=2. 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 Ry 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 (Dr) is defined as the distance between the expectation values of the reconstructed angle αmeas (Eq. 5) for the first and last symbol. It is applicable only for QCrank with input quantized into K symbols a0,,aK-1
    Dr=E(αmeas(aK-1))-E(αmeas(a0))α(aK-1)-α(a0). 14
    The domain of Dr is [0, 1], where 1 corresponds to a perfect result and 0 means that pure noise is measured.
  • 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, RSF(RVF)N, 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 (Dr) 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, ai, we measure the average reconstructed output E(αimeas). We then define a lookup table with K-1 thresholds τi,

τi=E(αimeas)+E(αi+1meas)2, 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 g(.),g:αmeasameas defined by the following lookup table:

g(αmeas)=a0,ifαmeas<τ0aK-1,ifαmeasτm-2aj,ifαmeas[τj,τj+1). 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

Supplementary Information. (1,014.1KB, pdf)

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 N-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

Supplementary Information. (1,014.1KB, pdf)

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.


Articles from Scientific Reports are provided here courtesy of Nature Publishing Group

RESOURCES