  We extend error mitigation to the case where the qubits are logically encoded
in a quantum error correcting code. Here the noise to be corrected enters
through the magic states needed to achieve universality. In this setting, we
generalize the concept of robustness of magic to the quantum-assisted
robustness of magic (QRoM), which is a magic measure relative to the available
quantum resources. We show how the QRoM quantifies the sampling overhead of
(quasiprobability-based) error mitigation algorithms as a function of the noise
parameter, interpolating between classical simulation based on the
Gottesman-Knill theorem and an ideal quantum computer. Furthermore, classical
simulation and error mitigation can be seen as special instances of
quantum-assisted simulation. In this task, fewer, noisier quantum resources
boost classical simulations of a larger, ideal quantum computation with an
overhead quantified by the QRoM. Finally we extend the error mitigation
protocol beyond the ideal scenario by allowing residual noise on the
fault-tolerant components of the circuit.
