Abstract
Generative adversarial networks are an emerging technique with wide applications in machine learning, which have achieved dramatic success in a number of challenging tasks including image and video generation. When equipped with quantum processors, their quantum counterparts—called quantum generative adversarial networks (QGANs)—may even exhibit exponential advantages in certain machine learning applications. Here, we report an experimental implementation of a QGAN using a programmable superconducting processor, in which both the generator and the discriminator are parameterized via layers of single and twoqubit quantum gates. The programmed QGAN runs automatically several rounds of adversarial learning with quantum gradients to achieve a Nash equilibrium point, where the generator can replicate data samples that mimic the ones from the training set. Our implementation is promising to scale up to noisy intermediatescale quantum devices, thus paving the way for experimental explorations of quantum advantages in practical applications with nearterm quantum technologies.
Introduction
The interplay between quantum physics and machine learning gives rise to an emergent research frontier of quantum machine learning that has attracted tremendous attention recently^{1,2,3,4}. In particular, certain carefully designed quantum algorithms for machine learning, or more broadly artificial intelligence, may exhibit exponential advantages compared to their best possible classical counterparts^{2,3,4,5,6,7,8}. An intriguing example concerns quantum generative adversarial networks (QGANs)^{7}, where nearterm quantum devices have the potential to showcase quantum supremacy^{9} with reallife practical applications. Indeed, applications of QGANs with potential quantum advantages in generating highresolution images^{10,11}, loading classical data^{12}, and discovering small molecular drugs^{13} have been investigated actively at the current stage.
The general framework of QGANs consists of a generator learning to generate statistics for data mimicking those of a true data set, and a discriminator trying to discriminate generated data from true data^{7,12,14,15,16,17,18}. The generator and discriminator follow an adversarial learning procedure to optimize their strategies alternatively and arrive at a Nash equilibrium point, where the generator learns the underlying statistics of the true data and the discriminator can no longer distinguish the difference between the true and generated data. In a previous QGAN experiment^{16}, the generator is trained via the adversarial learning process to replicate the statistics of the singlequbit quantum data output from a quantum channel simulator. However, the implementation of quantum gradient, which is crucial for training QGANs^{6}, is still absent. In addition, the involvement of entanglement in QGANs, which is a characterizing feature of quantumness and a vital resource for quantum supremacy, has not yet been achieved during the learning process^{3}.
In this article, we add these two crucial yet missing blocks by reporting an experiment realization of a QGAN based on a programmable superconducting processor with multiple qubits and alltoall qubit connectivity previously reported in ref. ^{19}. Superconducting qubits are a promising platform for realizing QGANs, owing to their flexible design, excellent scalability, and remarkable controllability. In our implementation, both the generator and discriminator are composed of multiqubit parameterized quantum circuits, also referred to as quantum neural networks in some contexts^{20,21,22,23}. Here, we benchmark the functionality of the quantum gradient method by learning an arbitrary mixed state, where the state is replicated with a fidelity up to 0.999. We further utilize our QGAN to learn an classical XOR gate, and the generator is successfully trained to exhibit a truth table close to that of the XOR gate.
Results
Framework of QGAN algorithm
We first introduce a general recipe for our QGAN and then apply it to two typical scenarios: learning quantum states and the classical XOR gate. The overall structure of the QGAN is outlined in Fig. 1a, which includes an input label, a real source (R), a generator (G), a discriminator (D), and a quantum gradient subroutine. The input label sorts the training data stored in R, and also instructs G to generate data samples mimicking R. D receives the label and corresponding data samples from either G or R, and then evaluates with appropriate scores, based on which a loss function V is constructed to differentiate between R and G. The adversarial training procedure is repeated in conjugation with the quantum gradient subroutine, which yields the partial derivatives of V with respect to the parameters constructing D or G, so as to maximize V for the optimal configuration of D and to minimize V for the optimal G in terms of the chosen values of the constructing parameters.
Specifically, denoting the sets of parameters constructing G and D as \({\overrightarrow{\theta }}_{{{{\rm{G}}}}}\) and \({\overrightarrow{\theta }}_{{{{\rm{D}}}}}\), respectively, the loss function V is written as
where N is the total number of data samples selected for training and \({S}_{n}^{{{{\rm{D}}}},{{{\rm{R}}}}}\) (\({S}_{n}^{{{{\rm{D}}}},{{{\rm{G}}}}}\)) represents the score of the nth data sample from R (G) evaluated by D. G and D are trained alternately with D being trained first. In D’s turn, we maximize the loss function by iteratively optimizing \({\overrightarrow{\theta }}_{{{{\rm{D}}}}}\) according to \({\overrightarrow{\theta }}_{{{{\rm{D}}}}}^{i+1}={\overrightarrow{\theta }}_{{{{\rm{D}}}}}^{i}+{\alpha }_{{{{\rm{D}}}}}{\nabla }_{{\overrightarrow{\theta }}_{{{{\rm{D}}}}}}V\), where i is the iteration step index and \({\nabla }_{{\overrightarrow{\theta }}_{{{{\rm{D}}}}}}V\) denotes the gradient vector of the loss function at the ith step; we train G by minimizing the square of the loss function with an iteration relation \({\overrightarrow{\theta }}_{{{{\rm{G}}}}}^{i+1}={\overrightarrow{\theta }}_{{{{\rm{G}}}}}^{i}{\alpha }_{{{{\rm{G}}}}}{\nabla }_{{\overrightarrow{\theta }}_{{{{\rm{G}}}}}}{V}^{2}\). The learning rates can be adjusted by tuning α_{D} and α_{G} which are typically on the order of unity.
An important quantity that plays a vital role in training our QGAN is the gradient of the loss function with respect to a given parameter. Interestingly, owing to the special structures of our quantum circuits for the generator and the discriminator, a common approach to obtain such a gradient is to shift the corresponding parameter by ±π/2 and measure the loss function at the shifted values^{24}. In our experiment, we employ an effective quantum method—the Hadamard test quantum algorithm^{25}—to obtain the gradient for the first time. This algorithm can reduce half of the time in comparison with the common approach to finish the training, at the expense of an additional auxiliary qubit and two controlled gates (see Supplementary Note 4 for more details). At each round of the training process, the parameters of the discriminator (or generator) are updated simultaneously after the gradients for all parameters are obtained, and a quantum process tomography (QPT) is performed to characterize the overlap fidelity between the generated data based on the updated parameters and the true data.
Experimental implementation of QGAN
The above mentioned QGAN is experimentally realized on a superconducting quantum processor using five frequencytunable transmon qubits labeled as Q_{j} for j = 0–4, where all qubits are interconnected by a central bus resonator as illustrated in Fig. 1b. The role arrangement of Q_{0}–Q_{4} can be visualized by the exemplary experimental sequence shown in Fig. 1c. Q_{0} is to assist the quantum gradient subroutine. Q_{1}–Q_{2} stores the label which is passed to D, with the output score encoded in Q_{1} by \({S}_{n}^{{{{\rm{D}}}},{{{\rm{R/G}}}}}=\langle {\sigma }_{1}^{z}\rangle /2+1/2\). For the experimental instances with G inserted, Q_{3}–Q_{4} also stores the label as the input to G and the output data sample from G is passed to D via Q_{3}; for the experimental instances with R in replacement of G, only Q_{3} stores the data sample from R as designated by the label. Details of the device parameters can be found in the “Methods” section and Supplementary Note.
By tuning the qubits on resonance but detuned from the bus resonator in frequency, these qubits can be all effectively connected, which enables the flexible realizations of the multiqubit entangling gates among arbitrarily selected qubits. The alltoall interactions are described in the dispersive regime by the effective Hamiltonian \({H}_{{{{\rm{I}}}}}=\sum {\lambda }_{jk}({\sigma }_{j}^{+}{\sigma }_{k}^{}+{\sigma }_{j}^{}{\sigma }_{k}^{+})\), where \({\sigma }_{j}^{+}\) (\({\sigma }_{j}^{}\)) denotes the raising (lowering) operator of Q_{j}, and λ_{jk} is the effective coupling strength between Q_{j} and Q_{k} mediated by the bus resonator. Evolution under this Hamiltonian for an interaction time τ leads to the entangling operator with the form of \({U}_{{{{\rm{ENT}}}}}={{\rm {e}}}^{i{H}_{{{{\rm{I}}}}}\tau }\), which can steer the interacting qubits into highly entangled state. In our QGAN, the parameterized quantum circuits that comprise G and D leverage the naturally available multiqubit U_{ENT}s, with the interaction time of the twoqubit U_{ENT} fixed at around 50 ns for G and the threequbit one fixed at around 55 ns for D. We stress that, compared to architectures with limited connectivity^{8,9,26}, the alltoall connectivity for the device used in this experiment could reduce the total circuit depths (hence the running time) in implementing both the generator and discriminator, which is a crucial merit given that the coherence time is limited.
As laid out in Fig. 1c, the entangling operators U_{ENT} are interleaved with the singlequbit X and Z rotations, which successively rotate Q_{j} around x and zaxis in the Bloch sphere by angles of \({\theta }_{j,l,m}^{x}\) and \({\theta }_{j,l,m}^{z}\), where l is the layer index and m ∈ {G, D}. The lengths of the X and Z rotations are fixed at 30 and 20 ns, respectively. Taking into account the experimental imperfections, we perform numerical simulations to decide the depths of the interleaved layers consisting of U_{ENT} and the singlequbit rotations, for a balance between the learning fidelity and efficiency, see Supplementary Discussion for the discussion of the circuit depth. For example, to learn the XOR gate, the circuit layer depths are set to be n = 2 and 3 for G and D, respectively, as shown in Fig. 1c.
The QGAN learning process is guided by the gradient of the loss function with respect to \({\overrightarrow{\theta }}_{{{{\rm{G}}}}}\) and \({\overrightarrow{\theta }}_{{{{\rm{D}}}}}\). To obtain these gradients, we adopt the method of Hadamard test^{14,25}, which is illustrated in the sequence instance in Fig. 1c. For the partial derivative with respect to the parameter \({\theta }_{j,l,m}^{x}\) (\({\theta }_{j,l,m}^{z}\)), we insert the first controlledX (Z) gate right after the singlequbit X (Z) rotation containing this parameter, with Q_{j} as the target. The second controlledZ gate is applied at the end of the training sequence with Q_{1} as the target. The partial derivative of Q_{1}’s \(\langle {\sigma }_{1}^{z}\rangle\), which relates to D’s output score, is given by \(\partial \langle {\sigma }_{1}^{z}\rangle /\partial {\theta }_{j,l,m}^{x(z)}=\langle {\sigma }_{0}^{z}\rangle\), which can be directly obtained by measuring Q_{0} and used in computing the gradient of the loss function. More details about the experimental realizations of the controlledX (Z) gates, as well as the theoretical and experimental verifications of the quantum gradient method are presented in Supplementary Note 4.
Learning an arbitrary singlequbit quantum state
To benchmark the functionality of the quantum gradient method and the learning efficiency of our QGAN circuit, we first train an arbitrary mixed state as data which is a simulation of quantum channel. As shown in the inset of Fig. 2a, the mixed state for Q_{3} reads \({\rho }_{{{{\rm{R}}}}}=\left(\begin{array}{ll}0.7396&0.0431+0.3501i\\ 0.04310.3501i&0.2604\end{array}\right)\), which is generated by applying two singlequbit X rotations (with the rotation angles of 1.35 on Q_{3} and 0.68 on Q_{4}) followed by the U_{ENT} gate on Q_{3} and Q_{4}. Correspondingly, G is set up with a single layer and two parameters describing the singlequbit X rotation angles during the training, while D remains the one shown in Fig. 1c with 3 layers and all 18 parameters being trained. The trajectories of the loss function and scores of data from R/G during the training process are recorded and plotted in Fig. 2a. We optimize D at the beginning of the training to enlarge the distance between S^{D,R} and S^{D,G}. At the end of this turn, D can discriminate datasets from R and G with the maximum probability. In G’s turn, S^{D,G} moves towards S^{D,R} which means that G is learning the behavior of R. Each turn ends when the optimal point of the loss function is reached, or the iteration number goes over a preset limit. As the adversarial learning process goes on, the value of the loss function oscillates from turn to turn and eventually converges to 0 indicating that the learning arrives at a Nash equilibrium point, where G is able to produce a mixed state ρ_{G} which resembles ρ_{R} and D can no longer distinguish between them^{7,14}. The training process is characterized by the similarity between datasets generated by G and R, which is quantified by the state fidelity \(F({\rho }_{{{{\rm{R}}}}},{\rho }_{{{{\rm{G}}}}})={{{\rm{Tr}}}}(\sqrt{{\rho }_{{{{\rm{R}}}}}}{\rho }_{{{{\rm{G}}}}}\sqrt{{\rho }_{{{{\rm{R}}}}}})\), As shown in Fig. 2a, The average fidelity increases rapidly with the iteration steps, indicating the effectiveness of the adversarial learning. The density matrices ρ_{R} and the final ρ_{G} are plotted in Fig. 2b, which yields a state fidelity of around 0.999. We mention that the QGAN demonstrated in our experiment is distinct from quantum tomography or state preparation in essential ways. Here, we carry out the tomography process merely to benchmark the performance of the QGAN. In practical applications of QGAN with more qubits, this tomography process is not necessary and one may use other more efficient approaches to measure the performance.
Learning the statistics of an XOR gate
Now we apply the recipe to train the QGAN to replicate the statistics of an XOR gate, which is a classical gate with input–output rules 00 → 0, 01 → 1, 10 → 1, and 11 → 0. The input bit values store as labels in Q_{1} and Q_{2}, which is performed to let the discriminator know the corresponding input state of the state generated by the generator. We use the computational basis state \(\left0\right\rangle\) and \(\left1\right\rangle\) to encode the classical data 0 and 1, respectively. We randomly initialize the parameters of both D and G, and then update them alternately following the rules outlined above. The trajectories of the key parameters benchmarking the QGAN performance during the training process are plotted in Fig. 3a, with the evolutions of two representative parameters constructing D and G shown in Fig. 3b. Again, the loss function exhibits a typical oscillation during the adversarial process, and the training reaches its equilibrium after about 190 steps with an average state fidelity of 0.927. In addition, after training G successfully exhibits a truth table close to that of an XOR gate, as shown in the inset of Fig. 3a. Note that the fidelity of trained XOR gate is lower than the fidelity of the above mentioned single qubit mixed state. Due to the complexity of learning task, generator consisting of more layers and parameters is employed for training XOR gate, which would introduce more twoqubit gate infidelities and decoherence error during the learning.
Discussion
We have experimentally implemented a multiqubit QGAN equipped with a quantum gradient algorithm on a programmable superconducting processor. The results demonstrate the feasibility of QGAN in learning data with both classical and quantum statistics for small system sizes. The parameterized quantum circuits for constructing quantum generators and discriminators do not require accurate implementations of specific quantum logics and can be achieved on the nearterm quantum devices across different physical platforms. QGAN has farreaching effects in solving the quantum manybody problem, which can directly extend to the optimal control and selfguided quantum tomography, especially when the system size goes large^{27,28}. Our implementation paves the way to the muchanticipated computing paradigm with combined quantumclassical processors, and holds the intriguing potential to realize practical quantum supremacy^{9} with noisy intermediatescale quantum devices^{29}.
We note that there might be challenges with the random initialization and hardware efficient forms of G and D with large depth. For instance, for larger circuits we may need larger depths to gain enough representation power. As a result, the coherence time in our experiment needs to be increased. Moreover, another possible challenge for larger circuits is the so called “barren plateaus” problem, namely that the gradient might be vanishing for most of the parameter regions (see ref. ^{20,21,22,23} for more details). In fact, these challenges are the common ones facing most of the current experiments on variational quantum circuits. We also would like to mention that when scale beyond a handful of qubits, G and D can be replaced by deep quantum netural networks^{30} and the corresponding gradient may as well be efficiently evaluated by the backward propagation algorithm^{31}, similar to the case of training classical deep neural networks.
Methods
Details about the quantum device
Our experimental device is a superconducting circuit consisting of 20 transmon qubits interconnected by a central bus resonator with frequency fixed at around ω_{R}/2π ≈ 5.51 GHz. Five qubits, denoted as Q_{j} for j = 0–4, are actively used in this work. The frequencies of the used qubits are carefully arranged to minimize any possible unwanted interactions and crosstalk errors among qubits during singlequbit operations. Each qubit has its own microwave control and flux bias lines for implementations of XY and Z rotations, respectively. Meanwhile, each qubit is dispersively coupled to its own readout resonator for qubitstate measurement, and all the qubits can be measured simultaneously using the frequencydomain multiplexing technique.
Multiqubit entangling gates generation
The multiqubit entangling gates that comprise G and D in our QGANs are generated by tuning all the involved qubits onresonance at around 5.165 GHz, which is detuned from the resonator frequency by 345 MHz. Singlequbit phase gates, which are realized by amplitudeadjustable Z square pulses with a width of 20 ns, are added on each qubit before and after the interaction process to cancel out the dynamical phases accumulated during it. In our experiment, the two and threequbit entangling gates contain Q_{3}, Q_{4} and Q_{1}, Q_{2}, Q_{3} respectively. The characteristic interaction time t_{gate} is fixed at π/4∣λ∣, where λ is negative and approximately equals to \({\widetilde{g}}^{2}\)/Δ. \(\widetilde{g}\) is defined as the average qubitresonator coupling strength and Δ denotes the detuning between the interaction frequency and resonator frequency. λ/2π are around −2.48 and −2.27 MHz for the two and threequbit cases, respectively.
Data availability
The raw experimental data for generating the plots in this paper are available upon reasonable request.
References
Carleo, G. et al. Machine learning and the physical sciences. Rev. Mod. Phys. 91, 045002 (2019).
Sarma, S. D., Deng, D.L. & Duan, L.M. Machine learning meets quantum physics. Phys. Today 72, 48–54 (2019).
Biamonte et al. Quantum machine learning. Nature 549, 195–202 (2017).
Dunjko, V. & Briegel, H. J. Machine learning & artificial intelligence in the quantum domain: a review of recent progress. Rep. Prog. Phys. 81, 074001 (2018).
Gao, X., Zhang, Z.Y. & Duan, L.M. A quantum machine learning algorithm based on generative models. Sci. Adv. 4, eaat9004 (2018).
Harrow, A. & Napp, J. Lowdepth gradient measurements can improve convergence in variational hybrid quantumclassical algorithms. Phys. Rev. Lett. 126, 140502 (2021).
Lloyd, S. & Weedbrook, C. Quantum generative adversarial learning. Phys. Rev. Lett. 121, 040502 (2018).
Havlicek, V. et al. Supervised learning with quantumenhanced feature spaces. Nature 567, 209–212 (2019).
Arute, F. et al. Quantum supremacy using a programmable superconducting processor. Nature 574, 505–510 (2019).
Rudolph, M. S., Bashige, N. T., Katabarwa, A., Johr, S. & Peropadre, B. Generation of high resolution handwritten digits with an iontrap quantum computer. Preprint at bioRxiv https://arxiv.org/abs/2012.03924 (2020).
Huang, H.L. et al. Experimental quantum generative adversarial networks for image generation. Phys. Rev. Appl. 16, 024051 (2021).
Zoufal, C., Lucchi, A. & Woerner, S. Quantum generative adversarial networks for learning and loading random distributions. npj Quantum Inf. 5, 103 (2019).
Li, J., Topaloglu, R. & Ghosh, S. Quantum generative models for small molecule drug discovery. Preprint at bioRxiv https://arxiv.org/abs/2101.03438 (2021).
DallaireDemers, P.L. & Killoran, N. Quantum generative adversarial networks. Phys. Rev. A 98, 012324 (2018).
Zeng, J., Wu, Y., Liu, J.G., Wang, L. & Hu, J. Learning and inference on generative adversarial quantum circuits. Phys. Rev. A. 99, 052306 (2019).
Hu, L. et al. Quantum generative adversarial learning in a superconducting quantum circuit. Sci. Adv. 5, eaav2761 (2019).
Romero, J. & AspuruGuzik, A. Variational quantum generators: generative adversarial quantum machine learning for continuous distributions. Adv. Quantum Technol. 4, 2000003 (2021).
Anand, A., Romero, J., Degroote, M. & AspuruGuzik, A. Experimental demonstration of a quantum generative adversarial network for continuous distributions. Preprint at bioRxiv https://arxiv.org/abs/2006.01976 (2020).
Song, C. et al. Generation of multicomponent atomic Schrödinger cat states of up to 20 qubits. Science 365, 574–577 (2019).
McClean, J. R., Boixo, S., Smelyanskiy, V. N., Babbush, R. & Neven, H. Barren plateaus in quantum neural network training landscapes. Nat. Commun. 9, 4812 (2018).
Cerezo, M., Sone, A., Volkoff, T. & Coles, P. J. Cost function dependent barren plateaus in shallow quantum neural networks. Nat. Commun. 12, 1791 (2021).
Skolik, A., McClean, J. R., Mohseni, M., Smagt, P. & Leib, M. Layerwise learning for quantum neural networks. Quantum Mach. Intell. 3, 5 (2021).
Huembeli, P. & Dauphin, A. Characterizing the loss landscape of variational quantum circuits. Quantum Sci. Technol. 6, 025011 (2021).
Schuld, M., Bergholm, V., Gogolin, C., Izaac, J. & Killoran, N. Evaluating analytic gradients on quantum hardware. Phys. Rev. A. 99, 032331 (2019).
Mitarai, K. & Fujii, K. Methodology for replacing indirect measurements with direct measurements. Phys. Rev. Res. 1, 013006 (2019).
Kandala, A. et al. Hardwareefficient variational quantum eigensolver for small molecules and quantum magnets. Nature 549, 242–246 (2017).
Chapman, R. J., Ferrie, C. & Peruzzo, A. Experimental demonstration of selfguided quantum tomography. Phys. Rev. Lett. 117, 040402 (2016).
Rambach, M. et al. Robust and efficient highdimensional quantum state tomography. Phys. Rev. Lett. 126, 100402 (2021).
Preskill, J. Quantum computing in the NISQ era and beyond. Quantum 2, 79 (2018).
Beer, K. et al. Training deep quantum neural networks. Nat. Commun. 11, 808 (2020).
Goncalves, C. Quantum neural machine learning: backpropagation and dynamics. NeuroQuantology 15, 22 (2016).
Acknowledgements
Devices were made at the Nanofabrication Facilities at Institute of Physics in Beijing and National Center for Nanoscience and Technology in Beijing. The experiment was performed on the quantum computing platform at Zhejiang University. This work was supported by National Basic Research Program of China (Grants Nos. 2017YFA0304300, 2016YFA0302104 and 2016YFA0300600), National Natural Science Foundation of China (Grants Nos. 11934018 and 11725419), the Zhejiang Province Key Research and Development Program (Grant No. 2020C01019), the startup fund from Tsinghua University (Grant No. 53330300320), the Shanghai Qi Zhi Institute, and Strategic Priority Research Program of Chinese Academy of Sciences (Grant No. XDB28000000).
Author information
Authors and Affiliations
Contributions
Z.A.W., D.L.D., and H.F. proposed the idea. K.H., C.S., K.X., and Q.G. conducted the experiment, with help from Z.B.L., J.G.T., and H.W.; K.H. and Z.A.W. performed the numerical simulation, with help from H.F.; H.L. and D.Z. fabricated the device; K.H., Z.A.W., C.S., Z.W., D.L.D., H.W., and H.F. cowrote the manuscript. All authors contributed to the experimental setup, discussions of the results, and development of the manuscript.
Corresponding authors
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Supplementary information
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Huang, K., Wang, ZA., Song, C. et al. Quantum generative adversarial networks with multiple superconducting qubits. npj Quantum Inf 7, 165 (2021). https://doi.org/10.1038/s41534021005031
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s41534021005031
Further reading

ScQ cloud quantum computation for generating GreenbergerHorneZeilinger states of up to 10 qubits
Science China Physics, Mechanics & Astronomy (2022)