  We present a systematic, perturbative method for correcting quantum gates to
suppress errors that take the target system out of a chosen subspace. It
addresses the generic problem of non-adiabatic errors in adiabatic evolution
and state preparation, as well as general leakage errors due to spurious
couplings to undesirable states. The method is based on the Magnus expansion:
by correcting control pulses, we modify the Magnus expansion of an
initially-given, imperfect unitary in such a way that the desired evolution is
obtained. Applications to adiabatic quantum state transfer, superconducting
qubits and generalized Landau-Zener problems are discussed.
