I wonder what are magic states, and a magic state gadget. While I'm reading a paper, these terms frequently appear.

  • 4
    $\begingroup$ Could you please provide a link to the mentioned paper? $\endgroup$
    – JSdJ
    Commented Sep 7, 2020 at 14:14

3 Answers 3


Magic states are certain states that have very nice properties with respect to fault-tolerant quantum computation.

In the vast landscape of quantum gates, there is a crude but useful distinction to be made between Clifford gates and all other gates (also referred to as the inspired non-Clifford gates). The set of Clifford gates is in technical terms the normalizer of the Pauli group, which basically means that it's the set of operations that map the set of Pauli eigenstates to the set of Pauli eigenstates - as the Pauli operators and its eigenstates are very important in quantum computation, we also care deeply about the Clifford gates.

There is another reason why we care about Clifford gates. In the scope of Quantum Error correction (specifically stabilizer codes and Fault-tolerance), many Clifford operations on stabilizer codes can be implemented transversally. This is a certain way of implementing (logical) operations on codes that are more or less 'the easiest way' of fault-tolerant - making them highly desirable.

Unfortunately, it's impossible (as shown here) to have a complete universal gateset of operations with only transversal implementations, which means that at least one operation in the universal gateset needs to be implemented differently. As is often (but not necessarily) the choice, the set of Clifford operations (or rather, a generating set) is (chosen as) the transversal gates, and one other (non-Clifford) gate is implemented differently. Note that the Clifford gates together with any non-Clifford gate is a universal gate set. Usually, the set taken is Clifford + $T$, i.e. the Cliffords and the $T = R_{z}(\frac{\pi}{4})$ gate, the square root of $S$.

Implementing these non-clifford gates in a fault-tolerant manner is very tough and costly - there exist some methods that are on paper fault-tolerant but lack implementability in one way or another. Magic states are a way of circumventing the need for non-Clifford gates by preparing certain states that kind of 'encode' the non-Clifford action into the state. Intuitively, you can think of this as applying all the necessary non-Clifford gates in a computation in advance, resulting in the magic states; the rest of the computation can then be performed by using only Clifford gates, making the fault-tolerant implementation containable.

Without a reference I cannot be completely sure what is meant by a 'magic state gadget', but I think the authors are referring to a gadget that would perform magic state distillation. Such a procedure produces pure magic states from noisy magic states - it was shown that this can be performed in a reasonably scalable fashion, and moreover in a fault-tolerant fashion. This gives a blueprint of a fault-tolerant quantum computer with only Clifford gates (and the magic state distillation gadget).

Another option, as pointed out by forky40 and drumadoir, for what is meant by a 'magic state gadget' is the circuit that consumes the magic state to effectively implement the non-transversal gate. I won't go into detail here as forky40 already has a wonderful answer about this in this same thread.

Note that one needs a lot of magic states to perform computations - designs of quantum computers with magic states will most likely have the vast majority of its usable qubits be used for the distillation of magic states - the actual computation will almost be 'an afterthought'.

As a closing note, it may very well be that at some point all we care about in quantum computing resources is the distillation of magic states. This is of course an oversimplification, but I use it to emphasize the possible importance of these states.

  • $\begingroup$ Great answer, but saying “all Clifford operations on stabilizer codes can be implemented transversally” is unfortunately not true. The page you’ve linked does state that “for the 7-qubit code, the full logical Clifford group is accessible via transversal operations” but this is not true for all stabiliser codes $\endgroup$
    – drumadoir
    Commented Jun 28, 2023 at 9:30
  • $\begingroup$ Also I don’t think the gadget is one that would perform magic state distillation but rather the gadgets in forky40’s answer below, which use a magic state to perform gate teleportation, effectively applying a unitary operation to another state $\endgroup$
    – drumadoir
    Commented Jun 28, 2023 at 9:35
  • $\begingroup$ @drumadoir Thanks for your comment. Admittedly, it's been quite a while since I looked at stabilizer codes. I thought it was always possible to perform all Cliffords transversally up to some isometry in the codespace(s); thereby effectively 'choosing' what gates you get transversally, and which ones you have to implement with other means (hinted at in the next paragraph, where I say 'it is often the case'). I was probably wrong, I'll edit the text. $\endgroup$
    – JSdJ
    Commented Jun 30, 2023 at 7:37
  • $\begingroup$ @drumadoir Regarding your second point, you very well may be right, but we can never know for sure until the original author of the question replies (It's been almost 3 years, I don't expect it anymore). Either way, forky40's answer below (can't @ him) is wonderful and suits us very well I would say. I'll refer to his answer. $\endgroup$
    – JSdJ
    Commented Jun 30, 2023 at 7:39

In addition to the accepted answer and @user1271772's examples, here is a circuit primitive referred to explicitly as a "T-gate gadget" in [1] (originally appearing in [2]):

T-gate gadget: IMAGE SOURCE:arXiv:1601.07601

where application of the $S$ gate is conditioned on measuring a "1" on the ancilla. The way this works is, for $|A\rangle = \frac{1}{\sqrt{2}} (|0\rangle + e^{i\pi/4} |1\rangle)$, an input state $| \psi \rangle = a|0\rangle + b|1\rangle$ coming in from the left is transformed like:

$$ (a|0\rangle + b|1\rangle)(|0\rangle + e^{i\pi/4} |1\rangle) \rightarrow a|00 \rangle + a e^{i\pi/4} |01 \rangle + b|11\rangle + b e^{i\pi/4}|10 \rangle \\ = (a|0 \rangle + b e^{i\pi/4} |1\rangle )|0\rangle + (a e^{i\pi/4} |0\rangle + b|1\rangle)|1\rangle $$

If the ancilla is measured as "0", the input state is projected onto $(a|0 \rangle + b e^{i\pi/4} |1\rangle ) = T|\psi\rangle$ and the gate succeeds. If the ancilla is measured as "1" you apply an $S$ gate on the input register to get

$$ S(a e^{i\pi/4} |0\rangle + b|1\rangle) = (a e^{i\pi/4} |0\rangle + e^{i\pi/2} b|1\rangle) = e^{i\pi/4} (a |0\rangle + e^{i\pi/4} b|1\rangle) = e^{i\pi/4} T |\psi \rangle $$

which recovers the desired $T$ gate up to a global phase.

This process falls under the umbrella of gate teleportation (based on normal quantum teleportation) and basically lets you apply non-clifford gates if you have access to states that contain the essential information about the gate you want to apply - for instance, $|A\rangle = T\frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$ contains the effects of the $T$ gate that we want to apply.

[1] Bravyi, S., & Gosset, D. (2016). Improved classical simulation of quantum circuits dominated by Clifford gates. Physical review letters, 116(25), 250501.

[2] Zhou, X., Leung, D. W., & Chuang, I. L. (2000). Methodology for quantum logic gate construction. Physical Review A, 62(5), 052316.


Consider a quantum computer that can:

  • Prepare qubits in state $|0\rangle$
  • Apply unitary gates from the Clifford group
  • Measure qubits in the $X$, $Y$, and $Z$ bases

This seems ideal because:

  • We know how to implement all three functionalities quite easily (compared to more complicated gates or measurements)
  • We can design algorithms for such a quantum computer quite easily, since all gates and measurements are quite fundamental operations that everyone working in quantum information knows and understands.

But, the above quantum computer is not universal!

You just need one more functionality to make the above quantum computer universal though:

  • Be able to prepare a magic state

Examples of magic states are (here I give $H$-type and $T$-type magic states):

\begin{align} |H\rangle &\equiv \cos(\frac{\pi}{8})|0\rangle + \sin(\frac{\pi}{8})|1\rangle,\tag{1} \\ |T\rangle &\equiv\cos(\beta)|0\rangle + e^{i\pi/4}\sin(\beta)|1\rangle, \beta\equiv\frac{1}{2}\arccos(\frac{1}{\sqrt{3}}).\tag{2} \end{align}

The above example is not unique. In fact to make any universal quantum computer, you need to be able to prepare at least one magic state.

The term "magic state" was introduced in 2004 by Bravyi and Kitaev.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.