Abstract
Magic states are the resource that allows quantum computers to attain an advantage over classical computers. This resource consists in the deviation from a property called stabilizerness which in turn implies that stabilizer circuits can be efficiently simulated on a classical computer. Without magic, no quantum computer can do anything that a classical computer cannot do. Given the importance of magic for quantum computation, it would be useful to have a method for measuring the amount of magic in a quantum state. In this work, we propose and experimentally demonstrate a protocol for measuring magic based on randomized measurements. Our experiments are carried out on two IBM Quantum Falcon processors. This protocol can provide a characterization of the effectiveness of a quantum hardware in producing states that cannot be effectively simulated on a classical computer. We show how from these measurements one can construct realistic noise models affecting the hardware.
Similar content being viewed by others
Introduction
In the era of Noisy Intermediate Scale Quantum Computers (NISQs)1 it is of paramount importance to be able to characterize the proposed quantum hardware in order to check how good these machines are in performing quantum computation with the purpose of attaining an advantage over classical computers. This paper shows how to perform accurate and robust measurements of the stabilizer Rényi entropy, which in turn is known to quantify the resource known as “magic”2.
It is well known that the preparation of stabilizer states, the implementation of Clifford gates and measurements in the computational basis can be made fault tolerant3,4,5,6,7,8,9. However, computers based on the Clifford resources can be efficiently simulated on classical computers10,11,12,13, similarly to what happens for matchgate circuits (MGCs). This means that the power of quantum advance requires resources beyond the Clifford group, like the Phase π/8 gate (T gate) or the Toffoli gate and non-Gaussian states for the MCGs14,15. The precious resource that makes quantum computers special is colloquially dubbed as ‘magic’ and a resource theory of magic has been developed in recent years2,3,4,16,17,18,19,20,21,22,23,24,25,26,27.
It is a striking fact that these resources are difficult to implement3,5,28,29,30,31,32,33. The very reason why these resources are powerful makes them fragile. Moreover, the amount of these resources that needs to be used in a computation must be calibrated accurately: just like entanglement34, too much magic is not useful for quantum computation (see Supplementary Note 1), see also21. Moreover, decoherence is not magic preserving, and it can both increase or decrease the amount of magic in a system, as we will show in the experiments. To the extent that decoherence is spoiling quantum computation, then one needs the amount of magic created and manipulated throughout the computation to be accurate: in this paper, we prove that an excess amount of unwanted magic makes the task of distinguishing the state ψ from a random state an exponentially difficult task, see Supplementary Note 1 for the proof. Moreover, since inaccurate Clifford gates can produce magic, the presence of excess magic is in fact a signal of noise. We exploit this fact to show that the measurement of magic can be used to quantify and characterize the noise in the quantum circuit. It is thus important to be able to quantify this resource and measure it to characterize the fitness of real quantum hardware. Unfortunately—until recently—proposed measures of magic4,17,22,35 have been based on extremization procedures and no experimental measurement scheme has been proposed.
In this work, we propose and experimentally demonstrate a protocol based on randomized measurements36,37,38,39,40,41,42,43,44,45,46,47,48,49 to measure magic in a quantum system with n qubits and to characterize quantum hardware. We adopt the magic measure called stabilizer 2-Rényi entropy defined as2
where \(W(\psi ):= {{{\rm{tr}}}}(Q{\psi }^{\otimes 4})\), Q ≔ d−2∑PP⊗4, and d = 2n, where the sum is taken over all multi-qubit strings of Pauli operators, applied to four copies of the state, and \({S}_{2}(\psi )=-{\log }_{2}{{{\rm{tr}}}}{\psi }^{2}\) is the 2-Rényi entropy. In order to measure M2 we propose an improved protocol compared to the one presented in ref. 2 as it only involves randomized one-qubit measurements instead of global multi-qubit measurements, with obvious advantages in terms of errors and quantum control.
As M2 depends on the state ψ, a direct evaluation of M2 would be possible by knowing all the expectation values \({{{\rm{tr}}}}(P\psi )\) of multi-qubit Pauli strings in the state ψ. This, of course, is equivalent to tomography and it is very expensive as it involves the evaluation of d2 expectation values for a total cost in resources scaling as \({{{\mathcal{O}}}}({d}^{3})\). Here, we employ a protocol based on randomized measurements which does not rely on tomographic techniques. Remarkably, randomized measurement protocols are highly favorable compared to state tomography38,39,41,43. As we shall see, we will employ a number of resources scaling as \({{{\mathcal{O}}}}({\epsilon }^{-2}{d}^{2})\) for an estimate with error ϵ.
Results
The protocol
The protocol consists in first drawing a string of random one-qubit Clifford operations, namely \(C{ = \bigotimes }_{i = 1}^{n}{c}_{i}\) and applying it to four copies of the state of interest. The protocol extracts correlations between these copies. Indeed, the quantity of interest in the first term of Eq. (1) can then be computed as
The formula above features the expectation value over the randomized measurements of the Clifford operator C on states of the computational basis sa and the Hamming weight \(\parallel \overrightarrow{{{{\bf{s}}}}}\parallel\) of the string s1 ⊕ s2 ⊕ s3 ⊕ s4. The quantity \(P({{{{\bf{s}}}}}_{a}| C)={{{\rm{tr}}}}(C\psi {C}^{{\dagger} }{{{{\bf{s}}}}}_{a})\) represents the probability of finding the computational basis state sa when measuring the state CψC†. The second term in Eq. (1) is the usual 2-Rényi entropy and can be measured by randomized measurements using the techniques of ref. 41. An important feature of our protocol is the fact that it only needs randomized operations over the Clifford group instead of the full unitary group as in ref. 38. In fact, by collecting the occupation probabilities P(CψC†∣sa) one can estimate both W(ψ) and the purity P(ψ) together thanks to the fact that the Clifford group forms a 2-design. See Methods. The operational meaning of the protocol is the following: randomized measurement protocols are usually conducted on a (Haar) random basis. Here we select a (local) stabilizer basis. Clifford rotations constitute the free resources for magic state resource theory. General unitaries would result in a change in quantum magic. Clifford orbits of a given quantum state instead are filled out by iso-magic states. A Clifford randomized measurement protocol measures the magic of the entire Clifford orbit, rather than of a single quantum state.
The experiments have been conducted on two IBM Quantum Falcon processors: a 5 qubit system, ibmq_quito and a 7 qubit system ibmq_casablanca50.
The experiment can be schematized as follows (see Fig. 1). Starting with a n-qubit state initialized in the \({\left\vert 0\right\rangle }^{\otimes n}\) state, we pass it through a unitary quantum circuit U resulting in the state preparation \(\left\vert \psi \right\rangle\). We want to characterize the fitness of such a circuit in providing a state with the promised magic. At this point, one extracts n one-qubit Clifford operations ci, applies them to the state \(\left\vert \psi \right\rangle\), and measures the state in the computational basis.
At this point, we want to analyze the scaling of the cost of necessary resources, both analytically and numerically. The experiment is repeated NM times for every string \(C{ = \bigotimes }_{i = 1}^{n}{c}_{i}\) in order to collect statistics to compute the occupation probabilities P(CψC†∣sa). Then, in order to compute the expectation value over the whole Clifford group \({{\mathbb{E}}}_{C}\), one samples the Clifford group with NU elements. In order to sample the Clifford group properly and to build sufficient statistics we simulate numerically the total number of measurements needed for M2, i.e. NTOT = NM × NU. By evaluating the variance of the estimator for W, through the use of standard statistical analysis (Bernstein inequality), one can bound the probability of making an error ϵ as a function of the total resources NU × NM employed. In Methods, we prove that by employing a total number of resources \({{{\mathcal{O}}}}({\epsilon }^{-2}{d}^{2})\) the randomized measurement protocol is able to estimate the purity within an error ≤ϵ and the stabilizer purity within an error ϵd−1. These theoretical bounds can be optimized by numerical analysis. The optimal number of unitaries NU and of measurements NM is found by numerical simulations imposing that the relative error on the theoretical value of stabilizer purity to be below 12% and an average value of the purity greater than 0.88, thus imposing a relative error of 12% on the purity as well. An important remark is that both NU and NM depend on the state ψ. Remarkably, low-magic states (like the states in the computational basis—which have exactly zero magic) require a higher NU × NM compared to states with high magic, see Supplementary Table I in Supplementary Note 4.
In order to characterize the fitness of a quantum processor in producing resources beyond stabilizer states, we adopt the model of a t-doped Clifford circuit51,52,53. This circuit consists of a block of Clifford gates in which t non-Clifford gates are injected. The non-Clifford gates we inject are \({P}_{\vartheta }=\left\vert 0\right\rangle \left\langle 0\right\vert +{e}^{i\vartheta }\left\vert 1\right\rangle \left\langle 1\right\vert\) gates: these constitute the resources that are injecting magic in the system, while the Clifford circuits are free resources. For ϑ = π/2 one obtains the phase flip gate that still belongs to the Clifford group and thus is a free resource. The value ϑ = π/4 instead, the so-called T gate, yields the maximal amount of magic achievable for a Pϑ gate. The T-gates will be called the “magic seeds” of the quantum circuit. These circuits are efficient in entangling so the output state of the circuit is in general not a trivial product state but a state that is both entangled and possesses magic.
Measuring magic
We start with the characterization of the quantum processor on single-qubit states, and thus without entanglement. The single-qubit magic states are obtained by applying Pϑ on the states \(\left\vert +\right\rangle =\frac{1}{\sqrt{2}}(\left\vert 0\right\rangle +\left\vert 1\right\rangle )\) obtaining \(\left\vert {P}_{\vartheta }\right\rangle \equiv {P}_{\vartheta }\left\vert +\right\rangle =\frac{1}{\sqrt{2}}(\left\vert 0\right\rangle +{e}^{i\vartheta }\left\vert 1\right\rangle )\) whose stabilizer 2-Rényi entropy reads \({M}_{2}(\left\vert {P}_{\vartheta }\right\rangle )=-{\log }_{2}\left(\frac{7+\cos (4\vartheta )}{8}\right)\), achieving its maximum for \({M}_{2}(\left\vert {P}_{\pi /4}\right\rangle )=1-{\log }_{2}3/2\) and its minimum for \({M}_{2}(\left\vert {P}_{\pi /2}\right\rangle )=0\).
The results of the experiment on the ibmq_quito are shown in Fig. 2. As we can see, the experimental data are in very good accordance with the theoretical prediction for the target state, showing the fitness of ibmq_quito in preparing single-qubit magic states. Decoherence effects are also very low, as we can see from the purity, see Fig. 2.
We now proceed to the more difficult task of characterizing a quantum processor capable of preparing entangled states. Starting from the computational basis state \({\left\vert 0\right\rangle }^{\otimes n}\), i.e. the input state of the quantum processor, we first apply a layer of Hadamard H-gates to obtain \({\left\vert +\right\rangle }^{\otimes n}={H}^{\otimes n}{\left\vert 0\right\rangle }^{\otimes n}\). Then, we apply T-gates on n1 qubits, with n1 = 0, … , n. The T-gates inject magic into the system. For n1 = n, the state obtained is the maximal magic product state achievable. If one wants to pump more magic into the system, one needs to create some entanglement between the qubits. To do so, we apply a layer of CX-gates, i.e. Clifford entangling 2-qubit gates defined as CXi,j = Ii ⊗ (Ij + Xj) + Zi ⊗ (Ij − Xj) and nested in the following way: CXn−1,nCXn−2,n−1 ⋯ CX1,2. Then we can inject some more magic in the system by applying another layer of n2T-gates with n2 = 1, … , n − 1 followed by another layer of CX: CX1,2 ⋯ CXn−2,n−1CXn,n−1. For the pictorial representation of the previously described architecture see Fig. 3. At the end of the state preparation, the magic seeds in the circuit are t = n1 + n2 and the state prepared is the \(\left\vert {\Gamma }_{({n}_{1},{n}_{2})}^{(n)}\right\rangle\)-state, where 1 ≤ t ≤ 2n − 1. In the following, we fill in T-gates starting from (0, 1), then (n1, 1) with (n1, = 1, … , n; n2 = 1), and finally (n, n2), with n2 = 2, … , n − 1. With this prescription, the label t uniquely describes the circuit. For example, t = 4 on a system with n = 6 qubits means three T-gates on the first layer and one T-gate on the second layer, see Fig. 3. The optimal number of NU, NM for a system with n = 3, 4, 5 qubits can be found in Supplementary Table I in Supplementary Note 4 and Fig. 7 in “Methods.”
In a system with n qubits, we can prepare the states \(\vert {\Gamma }_{t}^{(n)}\rangle\) with t = 1, … , 2n − 1. The results of the experiment for n = 3, 4, 5 are shown in Figs. 4, 5, and 6, respectively. We can see that, for larger values of n, the purity of the prepared state is compromised, due to decoherence. The measured experimental values of magic shoot off the theoretical prediction, especially for low magic states. Somewhat counterintuitively, the experimental value of magic is higher than the theoretical one. As we mentioned above, spurious injection (or subtraction) of magic can happen for two reasons. Inaccurate implementation of the Clifford gates—and thus turning them into non-free resources—or noise affecting them, or decoherence. That is, our experimental characterization of how magic is created in a quantum circuit tests not only the quantity of magic, but the accuracy with which the desired magic is created. The fact that the circuit must not only create magic, but must do it so with a certain accuracy, allows us to use the experimental data obtained from our protocol to characterize the noise affecting the system. A first insight comes from the realization, see Figs. 4, 5, and 6 that the noise is affecting more the preparation of low-magic states than that of high-magic states, mostly because of imperfection in the implementation of the resource-free Clifford gates like the CX gate. Let us see how we can characterize the noise affecting the system. A very general error model for the target state ψ is through a quantum channel \({{{\mathcal{E}}}}(\psi ):= {\sum }_{i}{q}_{i}{P}_{i}\psi {P}_{i}\). Random states are a good model for high-magic states2 and thus, to understand why the noise affecting the system does not disturb the magic injected in high-magic states, we compute the average difference in magic between a random state ψ and the noisy state \({{{\mathcal{E}}}}(\psi )\) as: \({\langle \delta M\rangle }_{{\rm{Haar}}}:= {\langle | M({{{\mathcal{E}}}}(\psi ))-M(\psi )| \rangle }_{{\rm{Haar}}}\). Calculation shows (see Supplementary Note 2) that \({\langle \delta M\rangle }_{{\rm{Haar}}}={{{\mathcal{O}}}}({S}_{2}({{{\bf{q}}}}))\). In other words, at high levels of magic, this quantity is robust under the noise model provided that the distribution q = {qi} is low in entropy S2(q).
Guided by this result, we model the noise in two factors (i) noise in state preparation due to decoherence and (ii) imperfection in the realization of the ci gates in the randomized measurement. This latter error is unitary. We then tune the factors quantifying the noise in our model to match the difference between the experimentally measured and the theoretically predicted amounts of magic.
The ansatz for the (non-unitary) quantum channel \({{{{\mathcal{N}}}}}_{p}\) affecting the state preparation is
where Zi is a phase flip error on the i-th qubit happening with probability (1 − p)/n. This channel is not the simple phase-flip channel as the probability p in principle depends on the target state \(\left\vert \psi \right\rangle\). The imperfection in the gates ci is modeled by the unitary phase displacement \({c}_{i}\to {c}_{i}^{\varepsilon }\equiv {c}_{i}{P}_{\varepsilon }{c}_{i}^{{\prime} }\), where use the Pε-gate described above. The measured stabilizer purity will be denoted by \({W}_{{\rm{exp}}}(\left\vert \psi \right\rangle )\).
Our ansatz on how the noise affects the measurement results is then \({W}_{{\rm{exp}}}(\left\vert \psi \right\rangle )\mathop{=}\limits^{!}{{{\rm{tr}}}}({\psi }_{p}^{\otimes 4}{Q}_{2}^{\varepsilon \otimes n})\) where \({Q}_{2}^{\varepsilon }\) represents the correction to the projector onto the single-qubit stabilizer code due to the gate imperfection error ε. The two free parameters p and ε can be determined experimentally, see Supplementary Note 2.
Several points are in order here. First, notice that the purity \({{{\rm{tr}}}}{\psi }_{p}^{2}\) is protected against gate imperfection errors, so it can be measured independently. Second, one can measure the ε error directly by measuring the purity of the initial state \({\left\vert 0\right\rangle }^{\otimes n}\), thus avoiding the decoherence effect altogether. The values of the stabilizer 2-Rényi entropy given by the noise model are represented by the Gray squares in Figs. 4, 5, and 6 which show that they provide a better approximation to the experimental data, an approximation which in fact improves as the number of T gates in the circuit increases. By measuring the stabilizer 2-Rényi entropy, thus, we provide a characterization of the noise model and an estimate of its parameters p, ε.
Discussion
Magic is a quantity of central importance for quantum computation: no quantum advantage can be obtained without it. This paper showed how to measure the amount of magic produced by a quantum circuit in terms of stabilizer Rényi entropy, and evaluated experimentally how that amount of magic scales as a function of the number of T-gates in the circuit. A central result of our experimental demonstration is that it is not enough just to create magic: the circuit must create an “accurate amount” of magic. Imperfectly implemented Clifford gates inject or subtract uncontrolled/unwanted magic into the circuit: just as excess entanglement can hinder the ability of a quantum circuit to perform some desired task34, uncontrolled excess magic can result in the degradation of the performance of a quantum computation. Generating the correct amount of stabilizer Rényi entropy is thus an important component of the certification process for quantum hardware. More generally, in a quantum device, e.g. a circuit based on superconducting qubits, there can be errors beyond decoherence, like gate implementation errors, or other unitary errors. Typically, these errors are investigated through gate fidelity while the loss of purity is a good figure of merit to quantify decoherence. However, not always gate fidelity is available as a tool. As we can see in Figs. 4 and 6, an inaccurate level of magic compared to the theoretical one signals the presence of unitary errors: a measurement of magic can then be used as a further tool to evaluate the accuracy of an experimental set-up.
Methods
Theoretical framework
In ref. 2, we proved that a global randomized measurements protocol can be employed to measure the stabilizer 2-Rényi entropy for multiqubit states.
Here, we make a decisive improvement by establishing a protocol that only requires local measurements. Local measurements are usually the best measurements in terms of quantum control an experimenter has access to. Let us recall the definition of stabilizer 2-Rényi entropy: for ψ a n-qubit quantum state, the stabilizer 2-Rényi entropy of ψ is defined as \({M}_{2}(\psi ):= -{\log }_{2}W(\psi )-{S}_{2}(\psi )-\log d\), where \(W(\psi ):= {{{\rm{tr}}}}(Q{\psi }^{\otimes 4})\), \({S}_{2}(\psi )={{{\rm{tr}}}}(T{\psi }^{\otimes 2})\) and the operator T is the swap operator while Q ≔ d−2∑PP⊗4. The local randomized measurements protocol we introduce here aims at measuring W(ψ) and P(ψ) by only using single qubit gates and then measuring the qubits in the computational basis. In this way, we reduce access to multi-qubit gates that are typically noisier and whose control is poorer. The logic behind any randomized measurement protocol is to reconstruct operators (e.g., the swap operator for the purity or higher order permutations for higher order purities, see refs. 36,38,39,40,43,54,55) from correlations between randomized measurements. The measurement is randomized by means of Clifford single qubit gates. It is fundamental to use Clifford gates as magic is invariant under these unitary operations. The ideal experimental protocol for measuring simultaneously W(ψ) and P(ψ) is (see Fig. 1 for a pictorial schematization):
-
(I)
pick NU random local Clifford operators \(C{ = \bigotimes }_{i = 1}^{n}{c}_{i}\) where \({c}_{i}\in {{{{\mathcal{C}}}}}_{1}\) are single qubit Clifford gates. For each C do:
-
(i)
obtain the desired state ψ from the quantum circuit U,
-
(ii)
apply C on the state ψC ≡ CψC†,
-
(iii)
measure in the computational basis,
-
(iv)
redo steps (i), (ii) and (iii) NM times to estimate the occupation probabilities \({\rm{Pr}}({\psi }_{C}| s)\equiv {{{\rm{tr}}}}(\left\vert s\right\rangle \left\langle s\right\vert {\psi }_{C})\) for s = 1, … , 2n,
-
(i)
-
(II)
Estimate the probabilities \(\tilde{{\rm{Pr}}}({\psi }_{C}| s)\) by measuring the frequencies of obtaining the bit-string s2 in the state ψC. The estimator \(\tilde{{\rm{Pr}}}({\psi }_{C}| s)\) for such probability converges to the true probability Pr(ψC∣s) in the limit NM → ∞.
-
(III)
Obtain P(ψ) and W(ψ) can be computed from the ideal probabilities Pr(ψC∣s) by:
$$P(\psi )=\frac{1}{2{4}^{n}}\mathop{\sum}\limits_{C\in {{{{\mathcal{C}}}}}_{1}^{\otimes n}}\mathop{\sum }\limits_{{s}_{1},{s}_{2}=1}^{{2}^{n}}{O}_{2}({s}_{1},{s}_{2}){\rm{Pr}}({\psi }_{C}| {s}_{1}){\rm{Pr}}({\psi }_{C}| {s}_{2})$$(4)$$\begin{array}{ll}W(\psi )=\frac{1}{2{4}^{n}}\mathop{\sum}\limits_{C\in {{{{\mathcal{C}}}}}_{1}^{\otimes n}}\mathop{\sum }\limits_{{s}_{1},\ldots ,{s}_{4}=1}^{{2}^{n}}{O}_{4}({s}_{1},{s}_{2},{s}_{3},{s}_{4}){\rm{Pr}}({\psi }_{C}| {s}_{1})\\\qquad\quad{\rm{Pr}}({\psi }_{C}| {s}_{2}){\rm{Pr}}({\psi }_{C}| {s}_{3}){\rm{Pr}}({\psi }_{C}| {s}_{4})\end{array}$$(5)
the weighting coefficients O2(s1, s2) and O4(s1, s2, s3, s4) are obtained in the following way. First, define two diagonal operators defined in \({{{{\mathcal{H}}}}}^{\otimes 2}\) and \({{{{\mathcal{H}}}}}^{\otimes 4}\) respectively:
Let us now prove Eqs. (4) and (5) and show the exact form of O2 and O4. Let us rewrite Eqs. (4) and (5) writing the purity as \(P(\psi )={{{\rm{tr}}}}(T{\psi }^{\otimes 2})\) and \(W(\psi )={{{\rm{tr}}}}(Q{\psi }^{\otimes 4})\)
from the above equation is clear that the task is to find two diagonal operators \({\hat{O}}_{2}\) and \({\hat{O}}_{4}\) whose local Clifford average gives T and Q respectively. Recalling that \(T=\frac{1}{{2}^{n}}{({{\mathbb{1}}}^{\otimes 2}+{X}^{\otimes 2}+{Y}^{\otimes 2}+{Z}^{\otimes 2})}^{\otimes n}\), and \(Q=\frac{1}{{4}^{n}}{({{\mathbb{1}}}^{\otimes 4}+{X}^{\otimes 4}+{Y}^{\otimes 4}+{Z}^{\otimes 4})}^{\otimes n}\), it is sufficient to find two single qubit diagonal operators \({\hat{o}}_{2}\) and \({\hat{o}}_{4}\) living in \({{\mathbb{C}}}^{2\otimes 2}\) and \({{\mathbb{C}}}^{2\otimes 4}\) respectively, such that their Clifford average gives \({T}_{1}\equiv \frac{1}{2}({{\mathbb{1}}}^{\otimes 2}+{X}^{\otimes 2}+{Y}^{\otimes 2}+{Z}^{\otimes 2})\) and \({Q}_{1}\equiv \frac{1}{4}({{\mathbb{1}}}^{\otimes 4}+{X}^{\otimes 4}+{Y}^{\otimes 4}+{Z}^{\otimes 4})\) respectively. At this point, it is straightforward to verify that one should choose \({\hat{o}}_{2},{\hat{o}}_{4}\) to be
To conclude the proof is sufficient to write \({\hat{o}}_{2}\) and \({\hat{o}}_{4}\) in the computational basis to restore the forms of Eqs. (4) and (5). It’s easy to verify:
where \({s}_{k}={s}_{k}^{1}{s}_{k}^{2}\ldots {s}_{k}^{n}\) a n-length bit string for k = 1, 2, 3, 4 and ⊕ is the logic sum between bits.
Statistical analysis
In this section, we discuss the effect of a finite number of realizations of the experiment. In our scheme, statistical errors arise from two factors: (i) a partial sampling of the local (single qubit) Clifford group, that is, NU < 24n, and (ii) the finite number of measurement shots NM per unitary selected to estimate the occupation probability \(\tilde{Pr}({\psi }_{C}| s)\), introduced in the previous section, that converge to the true probability only in the limit NM → ∞. The total number of resources is thus NU × NM. We assume that different rounds of random local unitary and different shots for a given unitary are generated independently and identically distributed. One describes the i-th shot for a given sampled unitary C as \({\tilde{s}}_{C}(i)\) which takes value \(\left\vert s\right\rangle \left\langle s\right\vert\) with probability \({\rm{Pr}}({\psi }_{C}| s)\equiv {{{\rm{tr}}}}(\left\vert s\right\rangle \left\langle s\right\vert C\psi {C}^{{\dagger} })\). An unbiased estimator for the stabilizer purity is given by:
where \({\tilde{W}}_{C}(\psi ):= {\left(\begin{array}{c}{N}_{M}\\ 4\end{array}\right)}^{-1}{\sum }_{i < j < k < l}{{{\rm{tr}}}}({\tilde{s}}_{C}(i)\otimes {\tilde{s}}_{C}(j)\otimes {\tilde{s}}_{C}(k)\otimes {\tilde{s}}_{C}(l){\hat{O}}_{4})\). Let us prove that it is an unbiased estimator:
where we used the fact that \({{\mathbb{E}}}_{s}{\tilde{s}}_{U}(i)\equiv {\sum }_{s}\left\vert s\right\rangle \left\langle s\right\vert Pr({\psi }_{C}| s)={\psi }_{C}\). Our task now is to bound the number of resources needed to estimate W within an error ϵ. We compute the variance given a finite number of shot measurements NM and a finite sample NU of the local Clifford group. The variance of the estimator \(\tilde{W}(\psi )\) can be written as:
After some lengthy algebra (see Supplementary Note 3), it is possible to bound the above variance as:
Finally, we make use of Bernstein’s inequality to bound the probability of an estimation within an error ϵ:
In the regime of interest, i.e., d ≫ 1 and NM ≫ 1 the variance scales like \({{{\rm{Var}}}}[\tilde{W}(\psi )]\lesssim \frac{1}{{N}_{U}}\left(\frac{{c}_{1}}{\sqrt{d}}+\frac{{c}_{2}}{{N}_{M}}\right)\), where c1, c2 are two constants. Setting \({N}_{M}={{{\mathcal{O}}}}(\sqrt{d})\), in order to have an error ϵ, and an exponentially small probability to fail, the total number of resources NU × NM for the stabilizer purity scales as \({{{\mathcal{O}}}}({\epsilon }^{-2})\).
At this point, a comment is necessary. The stabilizer purity is bounded between \({d}^{-2}\le \tilde{W}(\psi )\le {d}^{-1}\), which means that, to have a faithful measurement of W(ψ), the error ϵ must be (at least) exponentially small in the number of qubits, ϵ ~ d−1. This makes the number of resources exponentially large in n. Similarly, for the purity P(ψ) (see Supplementary Note 3), setting \({N}_{M}={{{\mathcal{O}}}}(\sqrt{d})\), the variance is \({{{\rm{Var}}}}[\tilde{{{\mathrm{Pur}}}\,}(\psi )]={{{\mathcal{O}}}}(d{N}_{U}^{-1})\). Thus the number of resources to estimate the purity up to an error ϵ scales as \({{{\mathcal{O}}}}({\epsilon }^{-2}\sqrt{{d}^{3}})\).
Therefore, employing a total number of resources
the randomized measurement protocol is able to estimate the purity within an error ≤ϵ and the stabilizer purity within an error ϵd−1. In the next section, we describe the experimental protocol used to perform the experiments on IBM quantum processors.
Experimental protocol
To measure the magic of multiqubit states on a quantum processor via statistical correlations between randomized measurements we need three steps: (i) state preparation, (ii) the application of NU random local Clifford unitaries to sample the local n-qubit Clifford group, whose dimension is ∣Cloc(2n)∣ = 24n, and (iii) NM projective measurements to estimate the probabilities \({\tilde{P}}_{M}({\psi }_{C}| s)\). Then, the experimental purity and stabilizer purity are measured as:
We proved that one needs \({N}_{U}\times {N}_{M}={{{\mathcal{O}}}}({\epsilon }^{-2}{d}^{2})\) total measurements to estimate the stabilizer purity within a error ϵ−1d−1. Since we obtained such an accuracy guarantee through crude bounds, we expect fewer resources to be spent. We thus follow the protocol employed in41 to find the optimal number of unitaries NU and measurements NM. We first build a preliminary 10 × 10 grid and make 100 numerical simulation for 10 different values of NU = 8, … , 1024 and 10 different values NM = 32, … , 1024 (the latter taken with logarithmic spacing) for 2 extreme states, namely the input state \({\left\vert 0\right\rangle }^{\otimes n}\) and the final doped Clifford state \(\left\vert {\Gamma }_{2n-1}^{(n)}\right\rangle\), see Fig. 3. Then, for each value of NU and NM we compute the average \(\overline{{W}_{{N}_{U},{N}_{M}}(\left\vert \psi \right\rangle )}\) over 100 different realizations, the average purity \(\overline{{P}_{{N}_{U},{N}_{M}}(\left\vert \psi \right\rangle )}\) and the average percent distance \({\delta }_{{N}_{U},{N}_{M}}\) from the average
To obtain the optimal number of NU and NM for the given states \({\left\vert 0\right\rangle }^{\otimes n}\) and \(\vert {\Gamma }_{2n-1}^{(n)}\rangle\), we set a threshold on the average distance \({\delta }_{{N}_{U},{N}_{M}}\) and on the average purity \(\overline{{P}_{{N}_{U},{N}_{M}}(\left\vert \psi \right\rangle )}\):
-
(i)
\({\delta }_{{N}_{U},{N}_{M}}(\left\vert \psi \right\rangle ) < 12 \%\)
-
(ii)
\(| \overline{{P}_{{N}_{U},{N}_{M}}(\left\vert \psi \right\rangle )}-1| < 12 \%\)
and pick the pair of NU, NM satisfying conditions (i) and (ii) minimizing their product NUNM, i.e. the optimal number of resources. Indeed the product of NUNM is the number of physical times that one redoes the actual experiment and thus the number of necessary resources to perform an experiment. Remarkably, the number of unitaries NU and the number of measurements NM do depend on the state of interest \(\left\vert \psi \right\rangle\). In particular, denoting \({N}_{U}^{t = 2n-1},{N}_{M}^{t = 2n-1}\) and \({N}_{U}^{t = 0},{N}_{M}^{t = 0}\) the number of resources for \(\left\vert {\Gamma }_{2n-1}^{(n)}\right\rangle\) and \({\left\vert 0\right\rangle }^{\otimes n}\) respectively, we find \({N}_{U}^{t = 2n-1} \,<\, {N}_{U}^{t = 0}\) and \({N}_{M}^{t = 2n-1} \,<\, {N}_{M}^{t = 0}\). These findings suggest that the optimal number of resources NU × NM do depend on the number t of magic seeds, i.e. T-gates, thrown in the circuit. Thus, in order to find optimal values for NU and NM for all the states of interest \(\left\vert {\Gamma }_{t}^{(n)}\right\rangle t=1,\ldots ,2n-1\), we build a linear spaced 10 × 10 grid for 10 different value of NU ranging in \([{N}_{U}^{t = 2n-1},\ldots ,{N}_{U}^{t = 0}]\) and 10 different values of NM ranging in \([{N}_{M}^{t = 2n-1},\ldots ,{N}_{M}^{t = 0}]\) for fixed n; then we make 100 numerical simulations and pick the optimal number of resources satisfying conditions (i) and (ii). In this way, we are able to determine the optimal number of resources state by state, see Supplementary Table I in Supplementary Note 4 for the results. The data are fitted to depend exponentially upon the number t of magic-seeds, as NTOT = 2a+b[(2n−1)−t], see Fig. 7. The experimental errors on the estimated P(ψ) and W(ψ) are chosen to be the standard error of the average over NU, i.e. over the local Clifford operators used to estimate these two quantities from randomized measurements (see Supplementary Note 4).
Data availability
The authors declare that the main data supporting the findings of this study are available within the article and its Supplementary Information files. Extra data sets are available upon reasonable request.
References
Preskill, J. Quantum computing in the NISQ era and beyond. Quantum 2, 79 (2018).
Leone, L., Oliviero, S. F. E. & Hamma, A. Stabilizer Rényi entropy. Phys. Rev. Lett. 128, 050402 (2022).
Campbell, E. T. & Browne, D. E. Bound states for magic state distillation in fault-tolerant quantum computation. Phys. Rev. Lett. 104, 030503 (2010).
Campbell, E. T. Catalysis and activation of magic states in fault-tolerant architectures. Phys. Rev. A 83, 032317 (2011).
Campbell, E. T., Anwar, H. & Browne, D. E. Magic-state distillation in all prime dimensions using quantum reed-muller codes. Phys. Rev. X 2, 041021 (2012).
Campbell, E. T., Terhal, B. M. & Vuillot, C. Roads towards fault-tolerant universal quantum computation. Nature 549, 172–179 (2017).
Campbell, E. T. Enhanced fault-tolerant quantum computing in d-level systems. Phys. Rev. Lett. 113, 230501 (2014).
Campbell, E. T. & Howard, M. Unified framework for magic state distillation and multiqubit gate synthesis with reduced resource cost. Phys. Rev. A 95, 022316 (2017).
Campbell, E. T. & Howard, M. Unifying gate synthesis and magic state distillation. Phys. Rev. Lett. 118, 060501 (2017).
Knill, E. & Laflamme, R. Theory of quantum error-correcting codes. Phys. Rev. A 55, 900–911 (1997).
Gottesman, D. The Heisenberg representation of quantum computers. Preprint at arXiv https://doi.org/10.48550/arXiv.quant-ph/9807006 (1998).
Gottesman, D. Theory of fault-tolerant quantum computation. Phys. Rev. A 57, 127–137 (1998).
Aaronson, S. & Gottesman, D. Improved simulation of stabilizer circuits. Phys. Rev. A 70, 052328 (2004).
Hebenstreit, M., Jozsa, R., Kraus, B., Strelchuk, S. & Yoganathan, M. All pure fermionic non-gaussian states are magic states for matchgate computations. Phys. Rev. Lett. 123, 080503 (2019).
Hebenstreit, M., Jozsa, R., Kraus, B. & Strelchuk, S. Computational power of matchgates with supplementary resources. Phys. Rev. A 102, 052604 (2020).
Veitch, V., Mousavian, S. A. H., Gottesman, D. & Emerson, J. The resource theory of stabilizer quantum computation. New J. Phys. 16, 013009 (2014).
Howard, M. & Campbell, E. Application of a resource theory for magic states to fault-tolerant quantum computing. Phys. Rev. Lett. 118, 090501 (2017).
Ahmadi, M., Dang, H. B., Gour, G. & Sanders, B. C. Quantification and manipulation of magic states. Phys. Rev. A 97, 062332 (2018).
Wang, X., Wilde, M. M. & Su, Y. Quantifying the magic of quantum channels. New J. Phys. 21, 103002 (2019).
Seddon, J. R. & Campbell, E. T. Quantifying magic for multi-qubit operations. Proc. R. Soc. A. 475, 20190251 (2019).
Liu, Z.-W. & Winter, A. Many-body quantum magic. PRX Quantum 3, 020333 (2022).
Seddon, J. R., Regula, B., Pashayan, H., Ouyang, Y. & Campbell, E. T. Quantifying quantum speedups: Improved classical simulation from tighter magic monotones. PRX Quantum 2, 010345 (2021).
White, C. D., Cao, C. & Swingle, B. Conformal field theories are magical. Phys. Rev. B 103, 075145 (2021).
Qassim, H., Pashayan, H. & Gosset, D. Improved upper bounds on the stabilizer rank of magic states. Quantum 5, 606 (2021).
Koukoulekidis, N. & Jennings, D. Constraints on magic state protocols from the statistical mechanics of Wigner negativity. npj Quantum Inf. 8, 1–13 (2022).
Hahn, O. et al. Quantifying qubit magic resource with Gottesman-Kitaev-Preskill encoding. Phys. Rev. Lett. 128, 210502 (2022).
Saxena, G. & Gour, G. Quantifying multiqubit magic channels with completely stabilizer-preserving operations. Phys. Rev. A 106, 042422 (2022).
Anwar, H., Campbell, E. T. & Browne, D. E. Qutrit magic state distillation. New J. Phys. 14, 063006 (2012).
Campbell, E. T., Anwar, H. & Browne, D. E. Magic-state distillation in all prime dimensions using quantum reed-muller codes. Phys. Rev. X 2, 041021 (2012).
Bravyi, S. & Haah, J. Magic-state distillation with low overhead. Phys. Rev. A 86, 052329 (2012).
Dawkins, H. & Howard, M. Qutrit magic state distillation tight in some directions. Phys. Rev. Lett. 115, 030501 (2015).
Bravyi, S., Smith, G. & Smolin, J. A. Trading classical and quantum computational resources. Phys. Rev. X 6, 021043 (2016).
Hastings, M. B. & Haah, J. Distillation with sublogarithmic overhead. Phys. Rev. Lett. 120, 050504 (2018).
Gross, D., Flammia, S. T. & Eisert, J. Most quantum states are too entangled to be useful as computational resources. Phys. Rev. Lett. 102, 190501 (2009).
Beverland, M., Campbell, E., Howard, M. & Kliuchnikov, V. Lower bounds on the non-Clifford resources for quantum computations. Quantum Sci. Technol. 5, 035009 (2020).
van Enk, S. J. & Beenakker, C. W. J. Measuring \({{{\rm{Tr}}}}{\rho }^{n}\) on single copies of ρ using random measurements. Phys. Rev. Lett. 108, 110503 (2012).
Tran, M. C., Dakić, B., Laskowski, W. & Paterek, T. Correlations between outcomes of random measurements. Phys. Rev. A 94, 042302 (2016).
Elben, A., Vermersch, B., Dalmonte, M., Cirac, J. I. & Zoller, P. Rényi entropies from random quenches in atomic hubbard and spin models. Phys. Rev. Lett. 120, 050406 (2018).
Elben, A., Vermersch, B., Roos, C. F. & Zoller, P. Statistical correlations between locally randomized measurements: a toolbox for probing entanglement in many-body quantum states. Phys. Rev. A 99, 052323 (2019).
Vermersch, B., Elben, A., Sieberer, L. M., Yao, N. Y. & Zoller, P. Probing scrambling using statistical correlations between randomized measurements. Phys. Rev. X 9, 021061 (2019).
Brydges, T. et al. Probing rényi entanglement entropy via randomized measurements. Science 364, 260–263 (2019).
Ketterer, A., Wyderka, N. & Gühne, O. Characterizing multipartite entanglement with moments of random correlations. Phys. Rev. Lett. 122, 120505 (2019).
Elben, A. et al. Mixed-state entanglement from local randomized measurements. Phys. Rev. Lett. 125, 200501 (2020).
Knips, L. et al. Multipartite entanglement analysis from random correlations. npj Quantum Inf. 6, 51 (2020).
Ketterer, A., Imai, S., Wyderka, N. & Gühne, O. Statistically significant tests of multiparticle quantum correlations based on randomized measurements. Phys. Rev. A 106, 010402 (2022).
Zhou, Y., Zeng, P. & Liu, Z. Single-copies estimation of entanglement negativity. Phys. Rev. Lett. 125, 200502 (2020).
Cian, Z.-P. et al. Many-body chern number from statistical correlations of randomized measurements. Phys. Rev. Lett. 126, 050501 (2021).
Imai, S., Wyderka, N., Ketterer, A. & Gühne, O. Bound entanglement from randomized measurements. Phys. Rev. Lett. 126, 150501 (2021).
Rath, A., van Bijnen, R., Elben, A., Zoller, P. & Vermersch, B. Importance sampling of randomized measurements for probing entanglement. Phys. Rev. Lett. 127, 200503 (2021).
IBM Quantum. https://quantum-computing.ibm.com/ (2021).
Zhou, S., Yang, Z.-C., Hamma, A. & Chamon, C. Single T gate in a Clifford circuit drives transition to universal entanglement spectrum statistics. SciPost Phys. 9, 87 (2020).
Leone, L., Oliviero, S. F. E., Zhou, Y. & Hamma, A. Quantum chaos is quantum. Quantum 5, 453 (2021).
Oliviero, S. F. E., Leone, L. & Hamma, A. Transitions in entanglement complexity in random quantum circuits by measurements. Phys. Lett. A 418, 127721 (2021).
Elben, A. et al. Cross-platform verification of intermediate scale quantum devices. Phys. Rev. Lett. 124, 010504 (2020).
Elben, A. et al. Many-body topological invariants from randomized measurements in synthetic quantum matter. Sci. Adv. 6, 3666 (2020).
Acknowledgements
The authors thank Benoȋt Vermersch, Agata Branczyk, Roberto Schiattarella, and Aurora Langella for inspiring discussions and comments. L.L., S.F.E.O., and A.H. acknowledge support from NSF award no. 2014000. The authors also thank the anonymous referees for their constructive comments and suggestions that helped to improve the manuscript. The work of L.L. and S.F.E.O. was supported in part by College of Science and Mathematics Dean’s Doctoral Research Fellowship through fellowship support from Oracle, project ID R20000000025727. S.L. was supported by DARPA, AFOSR, and ARO under a Blue Sky grant.
Author information
Authors and Affiliations
Contributions
All authors developed the idea for the experiment; S.F.E.O. and L.L. developed the theory, performed the measurements, and analyzed the data. All authors contributed to the discussions and interpretations of the results and wrote the manuscript.
Corresponding author
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
Oliviero, S.F.E., Leone, L., Hamma, A. et al. Measuring magic on a quantum processor. npj Quantum Inf 8, 148 (2022). https://doi.org/10.1038/s41534-022-00666-5
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s41534-022-00666-5
This article is cited by
-
The randomized measurement toolbox
Nature Reviews Physics (2022)