  In qubits made from a weakly anharmonic oscillator the leading source of
error at short gate times is leakage of population out of the two dimensional
Hilbert space that forms the qubit. In this paper we develop a general scheme
based on an adiabatic expansion to find pulse shapes that correct this type of
error. We find a family of solutions that allows tailoring to what is practical
to implement for a specific application. Our result contains and improves the
previously developed DRAG technique [F. Motzoi, et. al., Phys. Rev. Lett. 103,
110501 (2009)] and allows a generalization to other non-linear oscillators with
more than one leakage transition.
