  Implementation of logical entangling gates is an important step towards
realizing a quantum computer. We use a gradient-based optimization approach to
find single-qubit rotations which can be interleaved between applications of a
noisy nonlocal gate to dramatically suppress arbitrary logical errors, while
steering the evolution operator towards the perfectly entangling subset of
SU(4) gates. The modularity of the approach allows for application to any
two-qubit system, regardless of the Hamiltonian or details of the experimental
implementation. This approach is effective for both quasi-static and
time-dependent $1/f^{\alpha}$ noise. We also show how the fidelity of the final
operation depends on both the fidelity of the local rotations and the noise
strength.
