Experimental Implementation of a Quantum Autoencoder via Quantum Adders
Yongcheng Ding Lucas Lamata Mikel Sanz Xi Chen Enrique Solano







Department of Physics, Shanghai University, 200444 Shanghai, China
Department of Physical Chemistry, University of the Basque Country UPV/EHU, Apartado 644, E-48080 Bilbao, Spain

Department of Physical Chemistry, University of the Basque Country UPV/EHU, Apartado 644, E-48080 Bilbao, Spain

Department of Physical Chemistry, University of the Basque Country UPV/EHU, Apartado 644, E-48080 Bilbao, Spain

Department of Physics, Shanghai University, 200444 Shanghai, China

Department of Physical Chemistry, University of the Basque Country UPV/EHU, Apartado 644, E-48080 Bilbao, Spain
IKERBASQUE, Basque Foundation for Science, Maria Diaz de Haro 3, E-48013 Bilbao, Spain
Department of Physics, Shanghai University, 200444 Shanghai, China







Quantum autoencoders allow for reducing the amount of resources in a quantum computation by mapping the original Hilbert space onto a reduced space with the relevant information. Recently, it was proposed to employ approximate quantum adders to implement quantum autoencoders in quantum technologies. Here, we carry out the experimental implementation of this proposal in the Rigetti cloud quantum computer employing up to three qubits. The experimental fidelities are in good agreement with the theoretical prediction, thus proving the feasibility to realize quantum autoencoders via quantum adders in state-of-the-art superconducting quantum technologies.


Experimental Implementation of a Quantum Autoencoder via Quantum Adders
     Enrique Solano
    December 30, 2023
=======================================================================



A quantum autoencoder is a quantum device which can reshuffle and compress the quantum information of a subset of a Hilbert space spanned by initial n-qubit states onto n' qubit states with n'<n <cit.>. This approach may allow one to employ fewer quantum computing resources <cit.>. On the other hand, recently it was proven that a general quantum adder performing the equal weight superposition of two unknown quantum states is forbidden in general <cit.>. Nevertheless, the design and implementation of approximate quantum adders has led to some connections beyond expectation <cit.>, which may have applications in different fields of quantum technologies. In particular, one can define quantum autoencoders based on implementations of approximate quantum adders <cit.>.

An approximate quantum adder can be obtained in different ways. One example is the so-called basis quantum adder that perfectly adds the computational basis states and approximately their superpositions. Another possibility is to optimize the quantum adders via genetic algorithms <cit.>, which automatically provide optimal quantum adders in the context of limited gate numbers by carrying our a “natural selection” process according to the average fidelity, or cost function. A specific case of a quantum adder optimized by genetic algorithms was carried out with the experimental quantum computing platform provided by IBM Quantum Experience <cit.>. Furthermore, probabilistic quantum adders have been experimentally realized in different quantum platforms <cit.> However, the experimental realization of a quantum autoencoder via quantum adders, as originally proposed in Ref. <cit.>, has not yet been carried out.

Here we experimentally realize a quantum autoencoder via quantum adders based on the proposal in Ref. <cit.>, employing the Rigetti cloud quantum computer<cit.>. The main insight in Ref. <cit.> is that one could attain a perfect autoencoder and quantum compressor for any input state if a perfect quantum adder was available. It is clear that one could complete the encoding by a hypothetical unitary operation U that would add two input states, U|ψ_1⟩|ψ_2⟩∼|ψ_1⟩+|ψ_2⟩. U would provide the mapping of quantum information of tensor products of two, or in general n, single-qubit states onto a single qubit, that literally would realize the process of encoding. Then, one could decode the state by the inverse operation U^† and retrieve the initial state. Because of linearity, this method would also work for superpositions of the initial input states. However, an ideal quantum adder was proven to be forbidden by the basic principles of quantum mechanics <cit.>, which leads, logically, to the nonexistence of a perfect quantum autoencoder that realizes the encoding and decoding of any input state. Here, optimized approximate quantum adders will be the alternative strategy for producing a quantum autoencoder. We realize the quantum autoencoder according to the two types of quantum adders in the preceding discussion, via an experiment carried out in the Rigetti cloud quantum computer. We also analyze and experimentally implement the encoding of specific 2-qubit gates onto a single qubit gate.



A basis adder is a device introduced in Ref. <cit.> that is defined to perfectly add the computational basis states and approximately their superpositions, according to

    [ U|000⟩=|000⟩, U|010⟩=|01+⟩, U|100⟩=|10+⟩,; U|110⟩=|001⟩, U|001⟩=|110⟩, U|011⟩=|01-⟩,;               U|101⟩=|10-⟩, U|111⟩=|111⟩, ]


where the first two qubits in the lhs are the states for adding, the third one is an ancillary qubit and the last qubit in the rhs encodes the outcome state of the adding operation. The initial ancilla is always set to be |0⟩, but we introduce the extension of |1⟩ because the previous definition of U should include all the possible states of the computational basis for defining the gate univocally.

One of the most important criteria for analyzing a quantum device performance is its fidelity. The fidelity of the quantum adder U is defined through the output density matrix ρ_out as

    [                       F=(|Ψ_id⟩⟨Ψ_id|ρ_out),; ρ_out=_12(U|ψ_1⟩⟨ψ_1|⊗|ψ_2⟩⟨ψ_2|⊗|0⟩⟨0|U^†), ]

where |Ψ_id⟩=1/N(|ψ_1⟩+|ψ_2⟩) is the ideal outcome of the sum, N to be the normalization coefficient N= norm(|ψ_1⟩+|ψ_2⟩) and _12 means that the partial trace is taken over the first two qubits. In Ref. <cit.>, a subset of all possible input states was chosen for consistency, namely, |ψ_i⟩, i=1,2 were defined as |ψ_i⟩=(cosθ_i,sinθ_i)^ and the angles θ_i∈{0,π/2}. The operation U was defined as

    U=U_^(1̅,2)U_^(1̅,3)U_^(23̅,1)U_^(1̅,3)
    × U_^(1̅,2)U_^(1,2)U_^(2,3)U_^(1,2).

Here, U_^(i,j) denotes the controlled-NOT gate in which the ith qubit is the control and the jth is the target, U_^(ij,k) denotes the Toffoli gate with ith and jth qubits to be the control and kth to be the target which is also known as CCNOT. U_ is the controlled-Hadamard gate which prepares a superposition, while the bar symbol on the control qubit means that |0⟩ and |1⟩ play their role inversely in this qubit. The whole protocol of the basis adder U can be represented by the quantum circuit in Fig. <ref>. X, S and R_α(θ) refer to the Pauli X gate (also known as NOT gate), the phase gate (also known as √(Z)) and the rotations of θ in the Pauli α matrix, respectively.


The implementation of the previous basis quantum adder on Rigetti Forest requires the encoding of the quantum circuit in Fig. <ref> onto the cloud quantum computer provided by Rigetti. We give an example for {θ_1,θ_2}={0,0}. Qubits provided by the platform are distributed according to a certain topology such that we choose the qubits which are convenient for our quantum adder and autoencoder. In other platforms it may be the case that not all gates are available in the APIs such that we also introduce a method to adapt our quantum adder to other implementations. For the maximum compatibility, we choose universal quantum gates with different degrees of freedom which is a strategy provided by IBM Q Experience, another well-known cloud quantum computer for which rotation matrices are not directly presented but still accessible by advanced gates. A generic single-qubit quantum gate with three degrees of freedom is called U_3. With three arbitrary parameters U_3(θ,ϕ,λ)={[cosθ/2, -exp(iλ)sinθ/2],[exp(iϕ)sinθ/2,exp(iλ)exp(iϕ)cosθ/2)]}, this gate covers all the rotation operations on the Bloch sphere, including the rotation matrices about the x, y and z axes. Accordingly, U_1(θ), the single-qubit gate with one degree of freedom can be obtained by a U_3(0,0,θ)={[1,0],[0,exp(iθ)]}. Thus, the rotation matrix can be represented by U_3 gate or U_1 gate which are given as R_x(θ)=U_3(θ,-π/2,π/2), R_y(θ)=U_3(θ,0,0) and R_z(θ)=U_1(θ). 


We depict a scheme for the quantum autoencoder based on an approximate quantum adder in Fig. <ref>, following Ref. <cit.>. For any encoding process, a 2-qubit product state in the considered region |ψ_1⟩⊗|ψ_2⟩, i) apply the adding operation given by the approximate quantum adder U onto this state with the ancilla state initialized to |0⟩, ii) use quantum memories to store the first and second qubit after the adding operation and output |ψ_out⟩ for any task such as quantum transport, quantum communication, as well as single-qubit operations encoding an initial 2-qubit gate, iii) retrieve the decoded or modified 2-qubit state by applying U^† onto the memory qubits and the output state. We point out that the employment of memories is only necessary in case one would want to retrieve the original encoded states. In former quantum autoencoder paradigms <cit.>, the decoding part was not considered given that the encoding was irreversible. In this sense, with our approach one may also disregard the memory qubits in the situation where one only aims at compressing the information. Nevertheless, being the quantum adder operation unitary, it allows one for inverting it in case one would need to retrieve the original states. This is a novel feature of our approach.



In the case of a quantum autoencoder in Fig. <ref>, the quantum memories for the output first two entries will be needed in case one would like to perform a decoding, because U^† could retrieve the input 2-qubit subspace with higher fidelity, as far as the |ψ_out⟩ state is appropriately modified (or left invariant) by local gates in the process. A possibility of this approach is to encode possible original 2-qubit gates onto single-qubit ones according to specific quantum adders. Ref. <cit.> discussed the encoding of a CZ gate (represented by diag(1,1,1,-1)) onto a single-qubit gate. Here, we additionally provide a theoretical analysis for encoding a larger variety of 2-qubit gates. One issue that we point out is that the memory qubits are not needed in case the decoding part is not necessary in the corresponding application of our quantum autoencoder. As in previous proposals for quantum autoencoders, often the aim is not to encode and then decode but rather to just encode the original subspace onto a smaller system.

The encoding of a certain 2-qubit gate onto a single-qubit gate in the compressed space depends both on the gate itself and the subspace on which it acts. Obviously, a 2-qubit gate acting on the complete 2-qubit Hilbert space cannot be mapped onto a single-qubit gate perfectly. However, in certain cases, a 2-qubit gate can be reduced to a single-qubit one applied in between the encoding circuit and decoding circuit on the ancilla qubit. A 2-qubit gate can be represented by a controlled-U gate or a series of controlled-U gates, i.e., the SWAP gate satisfies U_=U_^1,2U_^2,1U_^1,2. Here, we encode the Controlled-U gate defined by U_=I_2×2⊕ U. We apply a CU gate onto the input |00⟩ and |11⟩ with the mapping of Eq. <ref>. After the perfect encoding according to the basis quantum adder, the 2-qubit gate can be replaced by a single-qubit gate Ũ that satisfies

    [   (U_⊗ I_2×2)U_adder|00⟩=U_adder(I_2×2⊗ I_2×2⊗Ũ)|00⟩,;   (U_⊗ I_2×2)U_adder|11⟩=U_adder(I_2×2⊗ I_2×2⊗Ũ)|11⟩,; (U_⊗ I_2×2)|00⟩=U_adder(I_2×2⊗ I_2×2⊗Ũ)U_adder^†|00⟩,; (U_⊗ I_2×2)|11⟩=U_adder(I_2×2⊗ I_2×2⊗Ũ)U_adder^†|11⟩,;                                                       ]

where Ũ denotes a hypothetical unitary matrix and U_adder is the basis adder. Solving the equations leads to U=Ũ, namely, that a controlled-U gate can be encoded to a U gate on the ancilla qubit. However, we have the restriction that the controlled-U gate can only be encoded perfectly when U is a diagonal matrix, U= diag(1,a), where a is an arbitrary phase. In this way, controlled-T, T^†, S, S^† and Z can be encoded on Rigetti Forest. These five gates can be represented by the U_1 gate with different θ, such that we can also build the controlled-U gates in the way shown in Fig. <ref> on other platforms which do not explicitly provide these gates.





 Although not all of the 2-qubit gates can be encoded perfectly, this encoding method may still be useful to some extent, for example, a lab with quantum memory and a universal quantum computer could send the |ψ_out⟩ state through a quantum communication channel if the receiver does not have the availability of a 2-qubit gate. Another possibility is that information encoded in qudits can also be decoded onto qubits with single-qubit gates. Therefore, many possible applications of this formalism provide a strong tool for quantum technologies.

The implementation of U^† to realize the decoding circuit is not difficult. One can perform the conjugate transpose matrices of those quantum gates in the encoding circuit one by one, but inversely. We notice that the conjugate transpose matrices of rotation gates satisfy R_α(θ)^†=R_α(-θ) that can also be represented by U_3 or U_1 gates trivially. We show the experimental results with Rigetti cloud quantum computer in Tables <ref>, <ref>, and <ref>, including the fidelity of the basis quantum adder, the encoding of 2-qubit gates and the encoding-decoding protocol for different input states. Those experimental data are collected for calculating the classical fidelities which are listed in the columns labeled by “Up-to-date”, meaning that the result stands for the latest achievements of the Rigetti cloud quantum computer. Different from simulations on QVM <cit.>, it is impossible to obtain the wave functions or the density matrices after the operation. The only available result is the distribution after taking a certain number of measurements, i.e. 1024 shots for an input which is large enough and statistically meaningful. The more shots you take, the frequency distribution is more likely to be the probability distribution, and we can come up with an estimation of this distribution, q_i, with those data. After estimating q_i by the data and calculating p_i according to ideal expectation, we obtain the classical fidelity F=∑_i√(p_i q_i) for each input or measurements on different directions instead of the quantum fidelity from tomography because of the limitation of resources.

In these tables, we also simulated the influence of noisy gates and readout error on fidelity on the classical simulator by Rigetti, QVM <cit.>. Here, we introduce amplitude damping and dephasing with the Kraus model <cit.>. Amplitude damping channels are imperfect identity maps with Kraus operators K_1= diag(1,√(1-p)), K_2=((0,√(p)),(0,0)) where p is the probability of state |1⟩ damping to state |0⟩. This error is mainly characterized through the qubit T_1 time. For a single qubit, the dephasing Kraus operators are K_1= diag(√(1-p),√(1-p)), K_2= diag(√(p),-√(p)) where p=1-exp(-T_2/T_gate) is the probability that the qubit is dephased over the time interval of interest.  Kraus operators that represent amplitude damping and dephasing are taken into consideration when we calculate the fidelity F̃ according to Eq. <ref>. Qubit-readout error is also introduced in our simulation. The two error mechanisms we choose are: i) classical readout bit-flip error that transmission line noise makes a |0⟩ look like a |1⟩ or vice versa, ii) T_1-readout error due to the damping of |1⟩ to |0⟩ during readout. In the noisy gate and readout error simulation, we try to simulate a well-developed quantum computation platform with high fidelity for both quantum gate and readout which may be realized in the near future, so the results are listed in columns labeled by “Advanced”. For T_1 and T_2 errors, we set p=0.003 and consider both a damping identity gate and a dephasing identity gate after an operation to any qubit. For Toffoli gates, we decomposed them into Hadamard, phase, CNOT, and T gates <cit.>. The classical readout has a possibility of F_flip=p_00=p_11=0.99 to avoid bit-flip error. Also, we include an extra damping identity gate before measurement to realize T_1-readout error. Usually, 2-qubit gates have a much smaller fidelity than the single-qubit gate, so we assume that F_=0.99 in the noise simulation. In this way, an advanced QPU that may be released in several years is simulated by the QVM, and its fidelity can be forecasted by F_ adv=F̃× F_^N_× F_flip, with F̃, F_^N_ and F_flip to be easily calculated and adjustable in technical parameters.

Fidelities in these tables are in good agreement with theoretical predictions. In the case of the quantum autoencoder based on basis quantum adder and the basis quantum adder itself, there is a significant number of CNOT gates in the circuit, resulting in accumulation of 2-qubit gate errors. Some features can be concluded from the data, namely, 1) the Kraus model we introduced is reasonable; due to the T_1 error, a single qubit is likely to damp from |1⟩ to |0⟩, which indicates that if the ideal result is expected to be |0⟩, or closer to |0⟩ on Bloch sphere, then the fidelity tends to be higher than the case of |1⟩; 2) the 2-qubit gate error causes a homogeneous distribution of quantum states that leads to a high fidelity when we are expecting a homogeneous distribution as the ideal result, and this answers the phenomenon that the advanced QPU in our simulation has lower fidelities than the up-to-date QPU under some certain inputs. This is not a breach of self-consistency but a disadvantage of a quantum autoencoder based on the basis quantum adder that motivates us to propose a better protocol with higher average fidelity and stable performance under different inputs.








Quantum autoencoder  via quantum adder optimized by genetic algorithms.– According to the preceding discussion, approximate quantum adders can be also optimized with genetic algorithms. Genetic algorithms (GAs) are a family of algorithms for optimization by the principle of natural selection in biology which were firstly introduced by Alan Turing <cit.> and developed rapidly in the following decades. These algorithms have wide applications in science and technology <cit.> and recently have been proposed for quantum simulation and quantum information <cit.> as an alternative method to other optimization techniques. For example, gate decomposition problems can be represented by the genetic code in the language of GAs.

Genetic algorithms provides a certain solution of gate decomposition with the maximum number of gates and its structure of single- and 2-qubit gates. They can be useful for practical purposes in the present or recent future quantum implementations via superconducting circuits, trapped ions, and quantum photonics, which employ a limited amount of resources. We follow the scheme of Fig. <ref> and choose now the quantum adder given by GA, as first proposed in Ref. <cit.>. We translate the quantum circuit to a sequence of instructions and the average fidelity to fitness function to simulate the process of natural selection.



The quantum adder we choose to build the quantum autoencoder is gate-limited by 20 and contains only 2 CNOTs, following Ref. <cit.>, with average theoretical fidelity of 90% and a minimum of 79.2%. We can also encode the controlled-U_1 gate with a U_1 gate as we did before but in this case the encoding will be imperfect. One may use genetic algorithms to design a sequence of single-qubit gates between the encoding and decoding circuit with a certain input and noise configuration for encoding a 2-qubit gate and achieve high fidelity without universality. The decoding circuit is shown in Fig. <ref> while the result of our measurements is shown in Tables <ref> and <ref>. We can see that with the quantum autoencoder optimized by genetic algorithms, the experimental fidelities are much higher than the original circuit while keeping the features we mentioned before. With this protocol, an advanced QPU will have a more stable performance as well as higher average fidelity under different inputs according to our simulation.











Discussion.– We have experimentally realized quantum autoencoders via approximate quantum adders in the Rigetti cloud quantum computer, which may be useful to compress quantum information. By directly designing a quantum autoencoder via a so-called basis quantum adder, we can realize the encoding and decoding process with high fidelity and also the perfect encoding of several 2-qubit quantum gates. By generating optimized gate-limited quantum autoencoders via genetic algorithms, we can realize quantum autoencoders with less quantum gates but still provide high fidelity. It should be also noticed that theoretically we can achieve higher fidelity with more quantum gates via genetic algorithms but the gate error should also be taken into consideration. This implies that we should have a balance between more theoretical fidelity provided by more gates, and less fidelity caused by gate errors, and optimize the gate number according to the gate fidelities provided by the corresponding experimental quantum computing platform. Our experiment is complementary to other experimental realizations of previous models of quantum autoencoders via quantum photonics <cit.>.

The authors acknowledge the use of Rigetti Forest for this work. The views expressed are those of the authors and do not reflect the official policy or position of Rigetti, or the Rigetti team. We also acknowledge support from Spanish MINECO/FEDER FIS2015-69983-P, Ramón y Cajal Grant RYC-2012-11391, Basque Government IT986-16, and the projects OpenSuperQ (820363) and QMiCS (820505) of the EU Flagship on Quantum Technologies. This material is also based upon work supported by the U.S. Department of Energy, Office of Science, Office of Advance Scientific Computing Research (ASCR), under field work proposal number ERKJ335. This work was also partially supported by the NSFC (11474193),
the Shuguang Program (14SG35), the program of Shanghai Municipal Science and Technology Commission (18010500400 and 18ZR1415500), and the Program for Eastern Scholar.

99
KimAuto
K. H. Wan, O. Dahlsten, H. Kristjansson, R. Gardner, and M. S. Kim, npj Quantum Information 2017,  3, 36.
Aspuru-GuzikAuto
J. Romero, J. P. Olson, and A. Aspuru-Guzik, Quantum Sci. Technol. 2017, 2, 045001.
codingPRA
B. Schumacher, Quantum coding, Phys. Rev. A 1995, 51, 2738.
NandC
M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information (Cambridge University Press, Cambridge, UK, 2000).
Srep2015
U. Alvarez-Rodriguez, M. Sanz, L. Lamata, and E. Solano, Sci. Rep. 2014, 5, 11983.
QMes2017
R. Li, U. Alvarez-Rodriguez, L. Lamata, and E. Solano, Quantum Meas. Quantum Metrol. 2017, 4, 1.
gatti
G. Gatti, D. Barberena, M. Sanz, and E. Solano, Sci. Rep. 2017, 7, 6964.
encoderarXiV
L. Lamata,  U. Alvarez-Rodriguez, J. D. Martín-Guerrero, M. Sanz, and E. Solano, Quantum Sci. Technol. 2019, 4, 014007.
Turing
A. M. Turing, Mind 1950, 59, 433.
HuPRA
X.-M. Hu, M.-J. Hu, J.-S. Chen, B.-H. Liu, Y.-F. Huang, C.-F. Li, G.-C. Guo, and Y.-S. Zhang Phys. Rev. A 2016, 94, 033844.
LietalPRA
K. Li, G. Long, H. Katiyar, T. Xin, G. Feng, D. Lu, and R. Laflamme, Phys. Rev. A 2017, 95, 022334.
Dogra
S. Dogra, G. Thomas, S. Ghosh, and D. Suter, Phys. Rev. A 2018, 97, 052330.
RigettiForest https://www.rigetti.com/forest
rigetti
J. M. Chow, J. Gambetta, A. D. Corcoles, S. T. Merkel, J. A. Smolin, C. Rigetti, S. Poletto, G. A. Keefe, M. B. Rothwell, J. R. Rozen, M. B. Ketchen, and M. Steffen, Phys. Rev. Lett. 2012, 109, 060501.
krausbook
K. Kraus. States, Effects, and Operations: Fundamental Notions of Quantum Theory. Lecture Notes in Physics, Vol. 190. Springer-Verlag, Berlin, 1983.
krauspaper
K. Kraus. Phys. Rev. D 1987 35, 3070.
GAbook
L. D. Chambers, Practical Handbook of Genetic Algorithms (CRC Press, Boca Raton, FL, 1998).
GAPRL
U. Las Heras, U. Alvarez-Rodriguez, E. Solano, M. Sanz, Phys. Rev. Lett. 2016, 116, 230504.
Tischler A. Pepper, N. Tischler, and G. J. Pryde, Phys. Rev. Lett. 2019, 122, 060501. 


