The remaining non-Clifford multi-qubit rotations are performed by consuming a (logical) magic state [1]}, [2]}, as shown in fig:noncliffgate. Since logical T-gates are not native to the surface code, a high-quality logical magic state must be injected into the computation. Magic state distillation [3]} can be used to produce a high quality encoded magic state starting from several lower quality ones. As the distillation is resource intensive, several algorithms for the minimization of the number of non-Clifford operations can be used during compilation [4]}, [5]}, [6]}, [7]}, [8]}, [9]}, [10]}.
Running a compiled logical quantum algorithm essentially decomposes into two stages. First, the non-Clifford logical rotations are implemented. Each one of these consumes a distilled logical magic state and requires the measurement of a multi-qubit logical Pauli operator and of single-qubit logical \(\bar{X}\)  operators. Depending on the measurement outcomes, some additional Pauli operations may need to be implemented. These can be commuted to the end of the circuit, in a procedure known as modifying the Pauli frame [11]}.
Second, once all the non-Clifford operations have been performed, the multi-qubit logical Pauli measurements are performed.
