Gradient Ascent Pulse Engineering (GRAPE) is a quantum optimal control technique based on gradient descent. It was originally developed to design pulse sequences for NMR spectroscopy, and has been used successfully to speed up quantum gates and to increase the fidelity of pulses in the presence of imperfections [1]}, [2]}, [3]}, [4]}. Given an initial state \(\mathinner {|{\psi (0)}\rangle }\) , a pulse duration \(T\)  and a Hamiltonian \(H\)  depending on controls \(u(t)\) , GRAPE can be used to find the optimal controls \(u(t)\) , minimizing \(J(\mathinner {|{\psi (T)}\rangle })\) , for an arbitrary objective function \(J\) . For this, a piecewise constant Ansatz for \(u(t)\)  is made, i.e. \(u(t) = u_j\)  if \(t \in [j\Delta t, (j+1)\Delta t]\)  and \(\Delta t = T/N\) , with \(N\)  the number of pieces. Typically, several hundreds of pieces are used. Minimizing \(J(\mathinner {|{\psi (T)}\rangle })\)  becomes an optimization problem over \(u_0,...,u_{N-1}\) . GRAPE provides a fast way to calculate all derivatives \(\partial J /\partial u_j\) , which then allows for the efficient use of a gradient descent algorithm to find a local minimum of the cost function. In our implementation, we use the Broyden–Fletcher–Goldfarb–Shanno algorithm [5]}, [6]} as the gradient descent method.
