Realizing a quantum generative adversarial network using a programmable superconducting processor

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 multi-qubit 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 intermediate-scale quantum devices, thus paving the way for experimental explorations of quantum advantages in practical applications with near-term quantum technologies.

Generative adversarial networks are an emerging technique with wide applications in machine learning [1], which have achieved dramatic success in a number of challenging tasks including image and video generation [2]. When equipped with quantum processors, their quantum counterparts-called quantum generative adversarial networks (QGANs)-may even exhibit exponential advantages in certain machine learning applications [3][4][5][6][7][8][9]. 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 multi-qubit 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 intermediate-scale quantum devices, thus paving the way for experimental explorations of quantum advantages in practical applications with near-term quantum technologies.
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 [10][11][12][13]. 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 [3,[11][12][13][14][15][16]. An intriguing example concerns quantum generative adversarial networks (QGANs) [3], where near-term quantum devices have the potential to showcase quantum supremacy [17] with reallife practical applications.
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 [3]. 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. Different versions of QGANs have been proposed [3][4][5][6][7][8][9]. Recently, a proof-of-principle experimental QGAN demonstration has been reported [7], showing that the generator can indeed be trained via the adversarial learning process to replicate the statistics of the single-qubit quantum data output from a quantum channel simulator. Yet, in this experiment the gradient, which is crucial for training the QGAN, was estimated numerically by the finitedifference method with a classical computer. This finitedifference approach induces an inaccuracy to the gradient and therefore may significantly retard the convergence to the equilibrium point [15]. In addition, the quantum states involved in this experiment were all singlequbit states, and entanglement, a characterizing feature of quantumness and a vital resource for quantum advantages, was absent during the learning process [12].
In this paper, 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. 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 [18][19][20][21]. 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.
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. 1 (a), 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 θ G and θ D , respectively, the loss function V is written as where N is the total number of data samples selected for training and S D,R n (S D,G n ) 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 θ D according to θ i+1 D = θ i D +α D ∇ θD V , where i is the iteration step index and ∇ θ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 θ i+1 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 [22]. In our experiment, we employ a even simpler method-the Hadamard test quantum algorithm [23]to obtain the gradient. 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 next) [24]. 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.
The above mentioned QGAN is experimentally realized on a superconducting quantum processor using 5 frequency-tunable transmon qubits labeled as Q j for j = 0 to 4, where all qubits are interconnected by a central bus resonator as illustrated in Fig. 1 (b). The role arrangement of Q 0 to Q 4 can be visualized by the exemplary experimental sequence shown in Fig 1 (c). 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 D,R/G n = σ z 1 /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 supplementary materials (SM) [24] and Ref. [25].
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 all-to-all interactions are described in the dispersive regime by the effective Hamil- [25], where σ + j (σ − 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 ENT = e −iHIτ , 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 two-qubit U ENT fixed at around 50 ns for G and the three-qubit one fixed at around 55 ns for D [24]. We note that, in this hardware-efficient realization of the QGAN, the entangling operators can be any device-tailored operations that generate sufficient entanglement.
As laid out in Fig. 1 (c), the entangling operators U ENT are interleaved with the single-qubit X and Z rotations, which successively rotate Q j around x-and z-axis in the Bloch sphere by angles of θ x j,l,m and θ z j,l,m , 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 single-qubit rotations, for a balance between the learning fidelity and efficiency. For example, to learn the XOR gate, the circuit layer depths are set to be 2 and 3 for G and D respectively, as shown in Fig.1 (c).
The QGAN learning process is guided by the gradient of the loss function with respect to θ G and θ D . To ob-  x/z j,l,m , where l is the layer index, m ∈ {G, D}, and the superscript (x or z) refers to the axis in the Bloch sphere around which the state of Qj is rotated by the angle θ. Shown is the training sequence on G to optimize its parameter θ x 3,1,G based on the quantum gradient subroutine, which includes two Hadamard gates (H), two controlled rotation gates, and a π/2 rotation around x-axis (X/2). In this instance, both Q1-Q2 and Q3-Q4 store the input label, and D's output score is encoded in Q1 by S D,R/G n = σ z 1 /2 + 1/2, which can be obtained by directly measuring Q1. Q0's σ z 0 gives the score derivative with respect to the rotational angle parameter right before the first controlled rotation gate, i.e., ∂ σ z 1 /∂θ x 3,1,G = − σ z 0 for the sequence displayed here. The first controlled rotation gate can be either a controlled X (CNOT) or controlled Z (CZ) gate depending on the single-qubit rotation axis it follows as shown in the lower right box.
tain these gradients, we adopt a quantum method called Hadamard test [4,23], which is illustrated in the sequence instance in Fig. 1 (c). For the partial derivative with respect to the parameter θ x j,l,m (θ z j,l,m ), we insert the first controlled-X (Z) gate right after the single-qubit X (Z) rotation containing this parameter, with Q j as the target. The second controlled-Z gate is applied at the end of the training sequence with Q 1 as the target. The partial derivative of Q 1 's σ z 1 , which relates to D's output score, is given by ∂ σ z 1 /∂θ j,l,m = − σ z 0 , which can be directly obtained by measuring Q 0 and used in computing the gradient of the loss function. See SM [24] for more details about the experimental realizations of the controlled-X (Z) gates, as well as the theoretical and experimental verifications of the quantum gradient method.
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.2 (a), the mixed state for Q 3 reads , which is generated by applying two single-qubit 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 2 parameters describing the single-qubit X rotation angles during the training, while D remains the one shown in Fig.1 (c) 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. 2 (a). 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 a b D,G Training steps D,R ( ) QGAN performance in learning a mixed state. a, Tracking of the loss function V , the output scores S D,R/G , and the state fidelity between R/G's output states F during the adversarial training procedure with learning rates αD = 0.8 and αG = 0.6. The alternate training stages of D and G are marked by red and white regions, respectively. In each stage, the maximum step number is limited to 50 for D and 100 for G. Inset: the quantum circuit for generating ρR for Q3. The same circuit is also used for G, with random initial guesses for the two rotational angles which are then optimized. b, The real and imaginary parts of the output density matirces of R (black frames) and the final G (solid bars).
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 [3,4]. The training process is characterized by the similarity between datasets generated by G and R, which is quantified by the state fidelity As shown in Fig 2 (a), F 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 2 (b), which yields a state fidelity of around 0.999. 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. We use the computational basis state |0 and |1 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. 3 (a), with the evolutions of two representative parameters construcing D and G shown in Fig. 3 (b). 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. 3 (a).
In conclusion, we have experimentally implemented a multi-qubit QGAN equipped with a quantum gradient algorithm on a programmable superconducting processor. The results clearly show the feasibility of QGAN for learning data with both classical and quantum statistics. 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 near-term quantum devices across different physical platforms. Our implementation paves the way to the much-anticipated computing paradigm with combined quantum-classical processors, and holds the intriguing potential to realize practical quantum supremacy [17] with noisy intermediate-scale quantum devices [26]. Supplementary Material for "Realizing a quantum generative adversarial network using a programmable superconducting processor"

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 to 4, are actively used in this work. 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 qubit-state measurement, and all the qubits can be measured simultaneously using the frequencydomain multiplexing technique. Details about the fabrication process, circuits layout, and quantum manipulation of the device can be found in Ref. [1,2].
Single-qubit operations and qubit-state measurements are performed at each qubit's idle frequency ω j,idle as listed in Table S1. These frequencies are carefully arranged to minimize the crosstalk effects. Other important parameters of the five qubit are also listed in Table S1, with their corresponding benchmarking data shown in Fig. S1. Both the X and X/2 gates are designed following the DRAG theory [3] with a length of 30 ns and a full width half maximum of 15 ns. Their fidelities are no less than 0.9976 characterized by randomized benchmarking (Fig. S1 (c)). Repeated readout pulses, which are 1.5 µs in length, are demodulated at room temperature, yielding the I − Q points for each qubit on the complex plane forming two blobs to differentiate its states |0 and |1 (Fig. S1 (d)). The probabilities of correctly reading out each qubit in |0 and |1 monitored over 40 hours are shown in Fig. S1 (e), with the corresponding mean values listed in Table S1.

MULTI-QUBIT ENTANGLING GATES
The multi-qubit entangling gates that comprise G and D in our QGANs are generated by tuning all the involved qubits on-resonance 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 three-qubit 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 g 2 /∆. g is defined as the average qubit-resonator cou-  Figure S1. Qubits characteristics. a, Qubit energy relaxation time measurement. The black solid lines are fits for P1,j of Qi according to the exponential decay equation, P1,j ∝ exp(−t/T1,j). b, Qubit Ramsey Gaussian dephasing time measurement. The red dots are experimental data with its envelope of Ramsey fringe fitted by P * 1,j ∝ 0.5 + exp[−t/2T1,j−(t/T * 2,j ) 2 ], shown by the black solid lines. c, RB characterizing the fidelities of X/2 and X gates. Plotted are the corrected |0 -state probabilities of the five qubits averaged over k = 30 sequences for the reference (red), the X/2 gates interleaved with the reference (green), and the X gates interleaved with the reference (blue) as functions of the numbers of gates. Dots are experimental data and lines are fits by the exponential decay equation. d, The measured normalized I-Q values in the I-Q plane, where blue (red) dots are obtained by repetitively preparing the qubit in |0 (|1 ) states and demodulating the corresponding readout signals. e, The |0 and |1 -state measurement fidelities of the five qubits with error bars, denoted respectively by F0,j (blue) and F1,j(red) as a function of training time.
pling strength and ∆ denotes the detuning between the interaction frequency and resonator frequency. λ/2π are around -2.48 MHz and -2.27 MHz for the two-and threequbit cases, respectively.
To characterize the obtained gates, quantum process tomography (QPT) is performed by preparing a full set of 6 n input states n j {I, ±X/2, ±Y /2, X} (here n denotes the number of qubits) and measuring the resulting output states with quantum state tomography (QST). We present the ideal and experimental process matrices χ id and χ exp for the two-and three-qubit entangling gates in Fig. S2 (a) and (b), finding the gate fidelities tr(χ exp χ id ) of 0.9716±0.0110 and 0.9456±0.0154 respectively.  Table S1. Qubits characteristics. ω j,idle is the idle frequency of Qj where single-qubit state preparation and measurement are implemented. Typical coherence parameters of the j-th qubit (Qj), including energy relaxation time T1,j and Ramsey Gaussian dephasing time T * 2,j are measured at the idle frequency, respectively. Fidelities of the X/2 and X gates on Qj are characterized by randomized benchmarking at its idle frequency ω j,idle . F0,j (F1,j) is the typical |0 (|1 )-state measurement fidelity for Qj, which is then used to correct the measured qubit probabilities for eliminating the readout errors.

TWO-QUBIT CONTROLLED GATES
Two types of controlled gates, i.e., controlled-X (CNOT) and controlled-Z (CZ) gates, are frequently used to fulfill the quantum gradient subroutine in QGANs. Both gates are made from a two-qubit phase gate U phase whose unitary matrix is shown in Fig. S3 (a), combined with some single-qubit gates as shown in Fig. S3 (b) and Q0 -Q4 Figure S3. Process matrices of two-qubit gates. a, The unitary matrix of the two-qubit U phase gate. b, The quantum circuit for constructing the CNOT gate, which consists of a U phase gate and six single-qubit gates. The first (above) qubit acts as the control qubit. c, The quantum circuit for constructing the CZ gate, which consists of a U phase gate and eight single-qubit gates. The first qubit acts as the control qubit. d, e, f, & g The real components of the process matrices χexp (solid bars) and ideal χ ideal (black frames) of U phase (left), CNOT (middle) and CZ (right) gates obtained by QST for different pairs of qubits, i.e., Q0-Q1, Q0-Q2, Q0-Q3, and Q0-Q4. The first qubit in the pairs always acts as the control qubit. All process fidelities calculated by tr(χexpχ ideal ) can be found in Table S2.
(c). The experimental realization of the U phase gate can be found in Ref. [4]. For different pairs of qubits, the U phase gates have lengths of 159, 141, 170, and 162 ns respectively. Ideal and experimental process matrices for all the related gates measured by QPT are shown in Fig. S3 (d) to (g), with the corresponding fidelities listed in Table S2.

THE GRADIENT VERIFICATION
The gradient is a critical ingredient required in the optimization procedure of generative adversarial networks (GANs). In this work, a quantum algorithm known as the Hadamard test is implemented experimentally for the first time to obtain the gradient. Now we introduce the basic idea of this algorithm.
A general parameterized quantum circuit for a multi-  Table S2. Fidelities of two-qubit quantum logical gates. ωI is the working point of the U phase gate. FU , Fcnot, and Fcz denote the process fidelities of U phase , CNOT, and CZ gates obtained by QPT, respectively. Figure S4. Hadamard test. a, Parameterized quantum circuit. The system consists of a bunch of qubits and is initialized in |ψ . N unitaries, which are denoted as UN:1 = UN UN−1 · · · Uj · · · U2U1, are applied to the system sequentially. Each unitary is parameterized by Uj = e − i 2 θ j h j , where hj = h † j is the Hamiltonian of the operation. The expectation value of an observable O is measured at the end of the circuit. b, An instance circuit of Hadamard test, which is executed by introducing an ancillary qubit. To measure the gradient of O with respect to θj, a controlled-hj gate is inserted after Uj, and a controlled-O gate is appended at the end of the parameterized quantum circuit. The gradient is encoded in the expectation value σ z of the ancillary qubit as explained in the text.
qubit system is depicted in Fig. S4 (a). The circuit consists of N unitaries labeled as U j for j = 1 to N and outputs the expectation value of an observable O. U j can be written as e − i 2 θj hj where h j = h † j is the Hamiltonian of the system during the operation. Our goal is to measure ∇ θ O , i.e., the gradient of O with respect to θ, where θ = [θ 1 , θ 2 , ..., θ j , ..., θ N ]. According to the parameter shift rules, we can measure the analytic gradient with the 'classical linear combinations of unitaries (CLCU)' method [6] which requires the direct detection of O .
Alternatively, we can add an ancillary qubit and measure the gradient indirectly by the Hadamard test algorithm. An instance circuit of the Hadamard test to measure the partial derivative of O with respect to θ j is shown in the circuit of Fig. S4 (b). For the input state |0 ⊗ |ψ , the corresponding output state of the circuit is The expectation value of the ancillary qubit's σ z is given by The proof of the last equation can be found in Ref. [5]. As such, the partial derivative of O can be measured as − σ z of the ancillary qubit. In our experiment, since the parameterized unitaries are all single-qubit gates, only two-qubit controlled gates are required to obtain the quantum gradient (QG). Nevertheless, the ability to realize two-qubit controlled gates between the ancillary qubit and all the other qubits in the system is still a nontrivial task and relies on the all-to-all connectivity of the quantum processor. We test the QG approach with a simple parameterized quantum circuit as shown in Fig. S5 (a), where we first rotate Q 1 around the x-axis by an angle θ and then measure its σ z 1 . Our goal is to measure the gradient of σ z 1 with respect to θ, i.e., ∂ σ z 1 /∂θ. The variation of σ z 1 versus θ is directly measured, with the results shown in Fig. S5 (b). Based on this measurement, we can calculate ∂ σ z 1 /∂θ by the CLCU approach, and the result is shown in Fig. S5 (d). In comparison, we can also calculate the gradient by adopting the QG circuit as shown in Fig. S5 (c) and measure σ z 0 of Q 0 . The gradient can be obtained by ∂ σ z 1 /∂θ = − σ z 0 with the results shown in Fig. S5 (d). Due to the infidelities of our two-qubit controlled gates, the quantum gradient is slightly smaller than the ideal value. In practice, there may be a delay between the two controlled gates which will introduce a dephasing error to Q 0 and affect the accuracy of QG. Such an error can be reduced experimentally by the single-qubit dynamical decoupling (1Q-DD) technique [4], which is realized by applying a continuous microwave drive resonantly on the qubit with a π-phase shift in the middle. To check that, we deliberately introduce a delay of τ = 800 ns in between the two controlled gates, and compare the results with and without the 1Q-DD protection. The Rabi frequency of the driving field in 1Q-DD is set to Ω/2π = 2 MHz in the experiment. An obvious enhancement is observed as expected.  Figure S5. Gradient verification. a, A simple parameterized quantum circuit for testing QG. Our goal is to measure the gradient of σ z 1 with respect to θ, i.e., ∂ σ z 1 /∂θ. b, Experimental (blue squares) and ideal (red line) results for running the parameterized quantum circuit with different θ. The values of ∂ σ z 1 /∂θ can be calculated by the classical linear combination of unitaries (CLCU) or quantum gradient (QG) approach. c, The circuit for measuring gradient with QG approach. d, Results for the gradients measured in different cases. Except for the ideal gradient (red line) and that calculated by the CLCU approach (blue squares), we also present the experimental results computed by the QG circuit for τ = 0 ns (black squares), τ = 800 ns without (green squares) and with (cyan squares) 1Q-DD protection respectively.

PULSE SEQUENCES FOR MEASURING THE QUANTUM GRADIENT
The pulse sequence for measuring the gradient of σ z 1 to θ x 1,1,D -the first parameter of Q 1 in D -during the training process of XOR gate is shown in Fig. S6. Dur-ing the time between two controlled gates, we implement 1Q-DD technique on Q 0 to protect it from dephasing as introduced in the previous section.  Figure S6. Pulse sequence for measuring QG. Shown are the control signals of all five qubits for measuring the gradient of σ z 1 with respect to the angle of Q1's XY rotation, which corresponds to the pulse in the dashed circle. The twoqubit controlled gates, including CNOT and CZ, are located in the semitransparent blue blocks, while the two-and threequbit entangling gates are covered by the semitransparent red shadows. In the yellow block, two weak microwave driving fields with opposite phases are applied successively to protect Q0 from dephasing. The Rabi frequency of the driving field is set to Ω/2π = 2 MHz in the experiment.

STABILITY DURING TRAINING
The stabilities of qubit operations are of great importance for the successful running of our QGANs. Except for the readout fidelities as shown in Fig. S1 (e), we also monitor the performances of multi-qubit gates during a 40-hour training time. Instead of benchmarking the gates by QPT which is rather time-consuming, we select several representative states as inputs and monitor the corresponding output states by measuring the probabilities of all the qubits in |1 . The results for the U phase gates on four pairs of qubits, i.e., Q 0 -Q 1 , Q 0 -Q 2 , Q 0 -Q 3 and Q 0 -Q 4 , are presented in Fig. S7 (a)-(d). The variations of probabilities for all those gates are no more than 0.036. The results for two-and three-qubit entangling gates applied on Q 3 -Q 4 and Q 1 -Q 2 -Q 3 are shown in Fig. S7 (e) and (f), with the variations of probabilities being 0.063 and 0.057 respectively. All results show that the performance of our multi-qubit gates is sufficiently stable during the QGANs training.