Introduction

Remarkable progress in building quantum hardware1,2,3,4 has fueled the search for potential applications of both near-term and future error-corrected quantum computers5,6, particularly in the simulation of quantum many-body systems7,8 and in machine learning9,10,11,12. For example, the ability of quantum computers to perform linear algebraic operations more efficiently could provide potential speedups for classical machine learning tasks, such as the ordinary matrix inversion in linear regression models13. However, dedicated quantum algorithms for this purpose, such as the Harrow, Hassidim and Lloyd algorithm14, rely both on executing deep quantum circuits15 and on loading binary data into a quantum register16 to offer practical advantages, which is beyond the reach of currently available quantum hardware. To load classical data into a quantum register in a more resource-efficient manner and map their features into the high-dimensional Hilbert space to ease classification, quantum circuits parameterized by the input data have been devised and used in quantum support vector machines17,18 and quantum neural networks19. However, independent of the specific data embedding scheme, it is still an open question whether tasks aiming at the analysis of classical data can ever fully leverage a quantum computer’s capability to process classically unrepresentable amounts of data9.

Promising candidates to harness the capabilities of near-term quantum computers are therefore algorithms which process quantum data directly and for which there is no classical analog9,20. Quantum computers are beginning to reach a level at which their output states are too complex to be analyzed by classical means1, suggesting that machine learning techniques which directly process quantum data are expected to become an increasingly important tool to efficiently characterize and benchmark quantum hardware. Examples of specific applications thereof include the principal component analysis of density matrices21, quantum autoencoders22,23,24, the certification of Hamiltonian dynamics25,26, and the detection of entanglement correlations in quantum many-body states10,11,27,28,29.

In this work, we experimentally demonstrate the classification of quantum states with quantum neural networks11 by implementing a quantum algorithm designed to recognize signatures of topological quantum phases30,31,32. This challenging task is of great relevance for the study of quantum many-body systems33 such as high-temperature superconductors34. Previous work in this context has focused on recognizing topological quantum phases from (simulated) measurement data using classical machine learning techniques35,36,37,38. Furthermore, topological states have recently been prepared on quantum hardware and analyzed by measuring characteristic observables39,40,41 such as string order parameters. Here, we experimentally demonstrate a new paradigm to detect symmetry-protected topological states on a 7-qubit quantum device by preparing quantum states within and outside of the SPT phase and by further processing these states with a quantum convolutional neural network to perform quantum phase recognition. We have designed and experimentally implemented a QCNN that, despite being composed of finite-fidelity gates itself, outperforms the direct measurement of the string order parameter in correctly identifying the topological phase. This enhanced capability is achieved by constructing the QCNN to simultaneously measure a weighted sum of Pauli strings, the number of which grows exponentially with the system size N (see Supplementary Note 5). The structure of this effectively measured observable allows the QCNN to tolerate both X- and Z-type errors while processing weakly perturbed input states. Using the QCNN to measure this observable circumvents the need to measure its constituent terms individually.

Results

Model

As a model system we consider a family of cluster-Ising Hamiltonians42:

$$H=-\mathop{\sum }\limits_{i=1}^{N}\left({Z}_{i-1}{X}_{i}{Z}_{i+1}+{h}_{1}{X}_{i}+{h}_{2}{X}_{i}{X}_{i+1}\right).$$
(1)

Ground states of (1) either belong to a topological quantum phase, a paramagnetic (PM) phase, or an antiferromagnetic phase depending on the model parameters {h1, h2}. h1 and h2 parametrize the strength of an external field and a nearest-neighbor Ising-type coupling in the model. {Xi, Yi, Zi} are the Pauli operators acting on the spin at site i. We define \({Z}_{0}\equiv {Z}_{N+1}\equiv {X}_{N+1}\equiv {\mathbb{1}}\), which models a spin chain with open boundary conditions41.

In the thermodynamic limit, the bulk of the Hamiltonian H commutes with both even Pe = ∏iX2i and odd Po = ∏iX2i + 1 parity operators, and thus exhibits a \({{\mathbb{Z}}}_{2}\times {{\mathbb{Z}}}_{2}\) symmetry-protected topological quantum phase43, which falls into the same symmetry class as the S = 1 Haldane phase44. The SPT phase is distinguished from the paramagnetic and antiferromagnetic phase by a non-zero expectation value \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) of the string order parameter32:

$${{{{{{{\mathcal{S}}}}}}}}={Z}_{1}{X}_{2}{X}_{4}...{X}_{N-3}{X}_{N-1}{Z}_{N},$$
(2)

which is defined for an odd number of spins N. Corresponding to the experimental situation in this work, we have computed \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\), shown in Fig. 1a, using exact diagonalization for a system of N = 7 spins. Due to the finite system size, we obtain smooth transitions across the phase boundaries (white dashed lines) determined from the maxima in the second derivative of the energy expectation value 〈H〉 with respect to h233.

Fig. 1: Concept of the quantum phase recognition experiment.
figure 1

a Phase diagram displaying the numerically calculated expectation value of the string order parameter \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle =\left\langle {Z}_{1}{X}_{2}{X}_{4}{X}_{6}{Z}_{7}\right\rangle\) for ground states ρ of a cluster-Ising Hamiltonian (Eq. (1)) in the parameter space spanned by h1 and h2 for N = 7. The white dashed lines indicate the phase boundaries between the symmetry-protected topological (SPT) phase and the paramagnetic and antiferromagnetic phases, respectively. b An unknown state ρ drawn from the phase diagram in a is processed by a QCNN to recognize the phase to which it belongs. The QCNN consists of convolutional layers (C) decomposed into two-qubit gates (orange), of pooling layers (P) implemented as single-qubit operations conditioned on intermediate measurement outcomes (purple), a fully-connected circuit layer (FC), and the measurement of a single output qubit yielding outcome y.

Concept of the experiment

Conventionally, the phase to which an unknown quantum state ρ belongs is determined by measuring the expectation value of an order parameter \({{{{{{{\mathcal{S}}}}}}}}\), a process referred to as quantum phase recognition. However, when evaluating the expectation value \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) by simultaneously, but individually measuring the qubits in their respective basis and by averaging the outcomes over multiple repetitions of the experiment, the sampling complexity increases close to the phase boundaries11. Furthermore, under realistic conditions the state ρ, which we prepare on the quantum hardware by executing a state-preparation circuit, might be subject to errors, reducing the value of \(\langle {{{{{{{\mathcal{S}}}}}}}}\rangle\).

To overcome the aforementioned limitations, we perform quantum phase recognition by processing the trial states ρ with a QCNN. The structure of QCNNs, as recently proposed in Ref. 11, is inspired by classical convolutional neural networks widely used e.g., in image or speech recognition. A generic QCNN consists of alternating convolutional (C) and pooling (P) layers, followed by a fully-connected (FC) layer, as schematically shown in Fig. 1b. The combination of entangling gates applied between neighboring qubits in the convolutional layer, and single-qubit gates conditioned on the outcome of projective measurements in the pooling layer, reduces the number of qubits while retaining characteristic features of the input state vector. After repeating this procedure d times, a unitary operation in the FC layer maps the feature of interest onto a single output qubit. In general, QCNNs are parameterized and can be trained to identify specific features of interest.

In our particular case, the QCNN is designed to recognize string order and decide if the input state ρ belongs to the symmetry-protected topological phase or not. Instead of measuring the single string order parameters \({{{{{{{\mathcal{S}}}}}}}}\) as defined in Eq. (2), the output of the QCNN corresponds to the weighted sum of multiple string order parameters, the value of which is robust against local X and Z-type errors. The specific structure of the QCNN is inspired by the multiscale entanglement renormalization ansatz representation45 of the topological cluster state, which is the ground state of H(h1 = h2 = 0) = − ∑Zi−1XiZi+1. In this case, each pair of convolutional and pooling layers maps a (perturbed) cluster state onto a cluster state of reduced system size, see Supplementary Note 5 for more details. Compared to the originally proposed QCNN11, we modify the FC layer to augment its tolerance to errors and use several gate identities to implement operations in the P and FC layers in classical processing wherever possible. We thereby drastically reduce the quantum gate count and enhance the performance of the QCNN under NISQ conditions.

For our experimental study carried out on a 7-qubit device, we combine two complementary elements. First, we prepare approximate ground states of the cluster-Ising Hamiltonian H by executing variational state preparation circuits. Second, we use those states as an input to the QCNN to demonstrate its capability to recognize the SPT phase and compare it to directly measuring 〈S〉.

Variational state preparation

To prepare approximate ground states of the gapped one-dimensional Hamiltonian H44 for the entire parameter range {h1, h2} displayed in Fig. 1a, we use a low-depth, variational state preparation circuit U(θ) composed of three layers of single-qubit rotations Ry(θi) parametrized by 19 independent rotation angles θi and two layers of conditional-Z (CZ) gates interleaved with the single-qubit gates, see Fig. 2a46. We implement both types of gates directly on the quantum hardware, see Supplementary Note 4 in which we also provide a comparison to an alternative approach used in Ref. 39 to prepare ground states via an exact matrix product state representation of translationally invariant states.

Fig. 2: Variational ground state preparation.
figure 2

a Variational quantum circuit parametrized with 19 rotation angles θ used to prepare approximate ground states of the cluster-Ising Hamiltonian H. b Rotation angles θi found by an optimization algorithm on a conventional computer for three example states {h1, h2} in the paramagnetic (PM) {1.1, 1.4}, SPT {0.0, − 0.2}, and antiferromagnetic (AF) {0.8, − 1.4} phase. c Measured expectation values of the indicated operators (solid bars) along the qubit array in comparison to the simulated values (wire frames) for the three states prepared using the rotation angles in b. d Measured string order parameters \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) for all prepared variational states vs. Hamiltonian parameters h1 and h2. Open circles indicate the three example states presented in b and c.

To determine the variational parameters θ = {θ1, ..., θ19} corresponding to an approximate ground state of a specific H(h1, h2), we minimize the energy expectation value \(\left\langle H\right\rangle\) in a conventional computer simulation with respect to the simulated output state \(\left|{{{\boldsymbol{\theta}}}} \right\rangle =U({{{\boldsymbol{\theta}}}})\left|0\right\rangle\) by using a gradient based L-BFGS optimizer47. As an acceptance criterion for the convergence of the optimization algorithm, we compute the fidelity \(F={|\langle {\psi }_{0}| {\theta }_{{{{{{{{\rm{opt}}}}}}}}}\rangle |}^{2}\) of the variational state \(|{{{\boldsymbol{\theta}}}}_{{{{{{{{\rm{opt}}}}}}}}}\rangle\) with respect to the exact ground state \(\left|{\psi }_{0}\right\rangle\), which, for N = 7, can be found using exact diagonalization. We repeat the optimization procedure with different initial values until F exceeds 81% solely being limited by the finite variational circuit depth of m = 1, see Supplementary Note 4. To make the state preparation circuit less susceptible to T1 errors, we then compute an equivalent set of rotational angles \({\tilde{{{\boldsymbol{\theta}}}}}_{{{{{{{{\rm{opt}}}}}}}}}\) yielding the same \(U({\tilde{{{\boldsymbol{\theta}}}}}_{{{{{{{{\rm{opt}}}}}}}}})=U({{{\boldsymbol{\theta}}}}_{{{{{{{{\rm{opt}}}}}}}}})\)48, but keeping the individual qubits preferentially in their respective ground state in the beginning of the state preparation sequence, see Supplementary Note 4 for details. This procedure avoids rotation angles close to π in the first layer of single-qubit rotations, which becomes apparent in the three examples shown in Fig. 2b by the absence of large rotation angles in the first column. The example state from the PM phase features rotation angles summing to ~ ±π/2 for each qubit individually. For the example state from the SPT phase, all qubits are initially rotated by an angle close to ±π/2, which, together with the subsequent layers of entangling CZ gates, results in an approximate cluster state41.

For the rotation angles \({\tilde{{{\boldsymbol{\theta}}}}}_{{{{{{{{\rm{opt}}}}}}}}}\) found in computer simulation, we execute the corresponding state preparation circuits on a 7-qubit superconducting quantum device featuring individual control and readout of all qubits, see Supplementary Note 1 for details. We realize single-qubit rotations by applying microwave pulses of controlled amplitude and phase and implement two-qubit CZ gates with flux pulses bringing the state \(\left|11\right\rangle\) into resonance with the non-computational state \(\left|20\right\rangle\)49,50, where \(|{n}_{i},{n}_{j}\rangle\) denote the states of the involved qubits in the Fock basis. To assure that all qubits are in their respective ground state at the beginning of each sequence, we perform a preselection readout and reject those measurement runs in which we found at least one of the qubits to be in the excited state, resulting in an overall acceptance probability of ~91%. We perform measurements in the X basis by prepending an Ry(π/2) rotation to the respective qubits before performing standard dispersive readout in the Z basis. To mitigate the effect of readout infidelities on the order of 1.6% per qubit in averaged measurement observables, we multiply the vector of probabilities pi of sampling the bitstring xi by the inverse of the assignment probability matrix M to obtain \({\tilde{{{\boldsymbol{p}}}}}={M}^{-1}{{{\boldsymbol{p}}}}\), from which we evaluate expectation values, see Supplementary Note 2 for details.

To characterize our state preparation, we measure a set of local expectation values and compare the results with those obtained from Kraus operator simulations, which take qubit dissipation and dephasing, as well as measured CZ gate errors and nearest-neighbor residual ZZ coupling into account, see Fig. 2c. For states in the paramagnetic (antiferromagnetic) phase, we find, as expected, a non-zero magnetization \(\langle {X}_{i}\rangle\) along the entire spin chain with equal (alternating) sign. The key signature of states in the SPT phase is the non-zero expectation value of Pauli strings \(\left\langle {Z}_{i-1}{X}_{i}{Z}_{i+1}\right\rangle\). In all three cases, the average deviation between measured and simulated expectation values is below 5.8% and can likely be attributed to small additional coherent control errors, which we do not account for in the Kraus operator simulation.

To map out the full quantum phase diagram shown in Fig. 2d, we proceed with measuring the string order parameter \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) for 10 × 10 combinations of {h1, h2} by directly sampling 32,768 times from the output of the state preparation circuit as indicated in Fig. 3a. We find the measured phase diagram to show all qualitative features of the exactly calculated one shown in Fig. 1a. The reduction in the overall contrast, which becomes apparent in the different amplitude scaling of \(\langle {{{{{{{\mathcal{S}}}}}}}}\rangle\), stems from errors due to decoherence and two-qubit gate errors as confirmed by Kraus operator simulations, see Supplementary Note 4 for details. Most importantly, some of those errors can be tolerated when inferring the quantum phase of a prior unknown state by applying a QCNN algorithm rather than measuring \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) directly, as we show in the following.

Fig. 3: Quantum phase recognition circuits.
figure 3

a Quantum circuit for the case in which the qubits are measured in the indicated basis, directly after executing the state preparation circuit U(θ), to evaluate \({{{{{{{\mathcal{S}}}}}}}}={Z}_{1}{X}_{2}{X}_{4}{X}_{6}{Z}_{7}\). b QCNN circuit consisting of a convolutional layer (C) of CZ gates (orange), and a pooling (P) and fully-connected (FC) layer implemented as a measurement in the X basis with outcome x, followed by a Boolean function f(x), here, represented by a logic circuit expressed in terms of AND and XOR gates (purple). An example of an X (Z) error occurring on qubit six (four) and its propagation through the QCNN is highlighted in red (blue).

Quantum phase recognition

Instead of measuring the expectations \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) directly after state preparation, we now employ the QCNN to detect the SPT phase. For this purpose, we process the prepared quantum states by the QCNN depicted in Fig. 3b and evaluate the expectation value 2〈y〉 − 1 of the single output bit y, which corresponds to measuring the expectation value of a multiscale string order parameter \({{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}\) consisting of a weighted sum of Pauli strings, see Eq. (14) in Supplementary Note 5 for an explicit expression. Measuring the QCNN output \({{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}=2y-1\) instead of \({{{{{{{\mathcal{S}}}}}}}}\) is advantageous because weakly perturbed cluster states still yield \({{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}=+1\) while the same states have a finite probability to yield \({{{{{{{\mathcal{S}}}}}}}}=-1\) which reduces the fidelity of the respective expectation value. Due to this property, \({{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}\) attains a step-like behavior at phase boundaries for large system sizes leading to a reduced sampling complexity11. Using the QCNN allows us to measure all the individual strings in \({{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}\) simultaneously, thereby reducing the number of measurement terms compared to a direct sampling of all Pauli strings, by an amount which scales exponentially with the QCNN system size N. For the system size N = 7 considered in our experiment the number of individual strings in \({{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}\) is 10, see Supplementary Note 5 for details.

We construct the QCNN by making two modifications to the quantum circuit proposed in Ref. 11. First, we perform the pooling and fully-connected layers as a Boolean function f(x) after having performed a projective measurement. This approach requires only a constant depth quantum circuit irrespective of the qubit number, which greatly reduces the total quantum gate count in comparison to preceding QCNN circuits while yielding the same output value. We explicitly show in Supplementary Note 5 that the modified QCNN circuit is fully equivalent to the original circuit in which all operations are implemented with quantum gates. While this modification is applicable to the exact QCNN circuit optimized for our particular model system, the implementation of a generic parametrized QCNN may not allow for a similar reduction of quantum gates. Second, we extend the fully-connected layer to map the measured bitstring x = (x1, x3, x4, x5, x7) onto a single output bit y, such that it not only tolerates X errors, but also Z errors, provided the errors are sufficiently sparse. For example, an X error occurring on qubit six and a Z error on qubit four prior to the convolutional layer invert bits x5, x7 and x4, which is corrected by the function f(x), see the red and blue colored paths in Fig. 3b. With this modification, the number of measurements that would be needed to determine \(\langle {{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}\rangle\) without employing the QCNN is also much larger than in previously proposed versions11, for which all the involved Pauli strings can be obtained from measuring in only two different bases, see Supplementary Note 5. The constant-depth quantum circuit plays a crucial role in the QCNN as it allows us to simultaneously sample all quasi-local observables Zi−1XiZi+1. The samples contain information about the long-range correlations between these quasi-local observables, which enables us to efficiently determine \(\langle {{{{{{{{\mathcal{S}}}}}}}}}_{{{{{{{{\rm{M}}}}}}}}}\rangle\) using classical processing.

To investigate the QCNN’s tolerance to errors in more detail, we sample x after having performed the convolutional layer for two different ground states chosen from the SPT and PM phase, respectively, and obtain the probability distributions shown in Fig. 4a. For the state in the SPT phase (top panel), we find a high probability of 0.47 to sample (00000), which is expected because the ideal cluster state corresponding to the ground state of H(h1 = h2 = 0) is mapped onto \(\left|{+}{+}{+}{+}{+}\right\rangle\) by the disentangling CZ gates of the quantum convolutional layer. However, due to the non-zero value of h1 = 0.2 and the presence of noise in the quantum circuit, we also measure other bitstrings with non-zero probability, most notably (10000). Most importantly, a large fraction of those bitstrings is correctly mapped onto y = 1 by the function f, thereby counteracting a quantum phase misclassification in those cases. For the paramagnetic example (bottom panel), we find the sampled bitstrings to be more uniformly distributed and, correspondingly, y to result equally likely in 0 or 1. In both examples, we find the measured probability distributions to be in good agreement with the simulated ones, taking decoherence, two-qubit gate imperfections and readout errors into account.

Fig. 4: Performance of the QCNN.
figure 4

a Probability to sample bitstrings x after having applied the convolutional layer (compare Fig. 3b) for the two indicated Hamiltonian parameter sets {h1, h2}. Bitstrings mapped onto 1 (0) by the function f(x) are colored in orange (purple) and the expected probabilities from a Kraus operator simulation in the corresponding light color, whereas the ideal values are depicted as black wire frames. b Expectation value \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle =\left\langle {Z}_{1}{X}_{2}{X}_{4}{X}_{6}{Z}_{7}\right\rangle\) measured directly after variational state preparation (compare Fig. 3a) vs. h2 for fixed h1 = 0.2, in comparison to the ideal values (solid line) and simulated values taking decoherence into account (dashed line). The SPT phase is indicated in light gray. c Expectation value \(2\left\langle y\right\rangle -1\) measured after applying the QCNN for the same parameters as in b compared to values extracted from a Kraus operator simulation of the QCNN circuit (dashed line) and the ideal value (solid line).

We finally quantify the performance of the QCNN in correctly identifying the SPT phase by comparing the value 2〈y〉 − 1 obtained from the QCNN to the value \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) obtained from direct sampling, see Fig. 4b, c. In particular, we determine both quantities across the phase boundaries separating the SPT phase (light gray) from the paramagnetic and antiferromagnetic phases, respectively, by varying h2 for constant h1 = 0.2. In both cases the measured expectation values (dots), which we obtain from 32,768 individual samples, approach zero for the paramagnetic and antiferromagnetic phases and take a non-zero value reaching 0.70 in the SPT phase. Compared to the ideal values (solid lines) and as a result of error events, the overall fidelity is reduced - an effect which is well-explained by Kraus operator simulations of the respective quantum circuits (dashed lines), which also identify two-qubit gate imperfections as the most prominent error contributor, see Supplementary Note 4 for details on the simulations. Most importantly, we find the average difference of the measured QCNN output values 2〈y〉 − 1 from the ideal curve to be 0.23, while the average difference of the directly measured values of \(\left\langle {{{{{{{\mathcal{S}}}}}}}}\right\rangle\) is 0.34. This enhancement of performance provides clear evidence for the robustness of the QCNN against errors.

Discussion

By implementing a QCNN on a superconducting quantum processor, we have demonstrated its capability to efficiently recognize quantum phases. With further advances in qubit number and circuit depth, we expect QCNNs to become an important diagnostic tool to characterize output states of NISQ devices, which are increasingly challenging to analyze with classical computing. Such applications will benefit from the predicted increased sampling complexity at phase boundaries11, at which the QCNN enhances the distinguishing power for assigning states to different quantum phases. While this enhancement is not yet accessible for the system size considered here, larger systems will be able to benefit from it, see Supplementary Note 5. Additionally, the scaling advantage can be understood by expressing the output of a QCNN by an equivalent weighted sum of string order parameters, the number of which scales exponentially with N. The QCNN thus allows one to simultaneously measure the sum of all those terms. An interesting direction to be explored in future work includes the trainability of parameterized QCNNs. This also becomes relevant in the context of using QCNNs to learn optimal strategies for quantum error correction.