GRAPE.jl
Gradient Ascent Pulse Engineering in Julia
Summary
The GRAPE.jl
package implements Gradient Ascent Pulse Engineering [1–3], a widely used method of quantum optimal control. The quantum state of a system can be described numerically by a complex vector $\ket{\Psi(t)}$ that evolves under a differential equation of the form
\[\def\ii{\mathrm{i}} \begin{equation}\label{eq:tdse} \ii \hbar \frac{\partial \ket{\Psi(t)}}{\partial t} = \hat{H}(\epsilon(t)) \ket{\Psi(t)}\,, \end{equation}\]
where $\hat{H}$ is a matrix (the Hamiltonian, most commonly) whose elements depend in some way on the control function $\epsilon(t)$. We generally know the initial state of the system $\ket{\Psi(t=0)}$ and want to find an $\epsilon(t)$ that minimizes some functional $J$ that depends on the states at some final time $T$, as well as running costs on $\ket{\Psi(t)}$ and values of $\epsilon(t)$ at intermediate times.
The defining feature of the GRAPE method is that it considers $\epsilon(t)$ as piecewise constant, i.e., as a vector of pulse values $\epsilon_n$, for the $n$'th interval of the time grid. This allows solving Eq. \eqref{eq:tdse} analytically for each time interval, and deriving an expression for the gradient $\partial J / \partial \epsilon_n$ of the optimization functional with respect to the values of the control field. The pulse values are then updated based on the gradient, in an efficient scheme detailed in Background (or the "TMIDR" short summary).
Contents
Related Software
GRAPE.jl
integrates with the JuliaQuantumControl ecosystem and, in particular, the following packages:
QuantumControl.jl
– The overall control framework, used to define the quantum control problem.GRAPE
is used by callingQuantumControl.optimize
withmethod = GRAPE
.QuantumPropagators.jl
– The numerical backend for simulating the piecewise-constant time dynamics of the system. Implements efficient schemes such as Chebychev propagation [4], but also can further delegate toDifferentialEquations.jl
QuantumGradientGenerators.jl
– Implementation of the gradient of a single-time-step evolution operator according to Goodwin and Kuprov [5], a key component of the GRAPE scheme as implemented here.
The GRAPE method ("discretize first") compares most directly to Krotov's method ("derive optimality first, discretize second") [6], implemented in Krotov.jl
with a compatible interface.
Other implementations of GRAPE
There have been a number of implementations of the GRAPE method in different contexts.
In the context of NMR:
SIMPSON
– Simulation program for solid-state NMR spectroscopy (C) [7]Spinach
– Spin dynamics simulation library (Matlab) [8]pulse-finder
– Matlab code for GRAPE optimal control in NMR [9]
More recent implementations, geared towards more general purposes like quantum information:
QuTIP
– Quantum Toolbox in Python [10]C3
– Toolset for control, calibration, and characterization of physical systems (Python) [11]QuOCS
– Python software package for model- and experiment-based optimizations of quantum processes [12]QuanEstimation
– Python-Julia-based open-source toolkit for quantum parameter estimation [13]
As a direct precursor to GRAPE.jl
:
QDYN
– Fortran 95 library and collection of utilities for the simulation of quantum dynamics and optimal control with a focus on both efficiency and precision
Features
The GRAPE.jl
package aims to avoid common shortcomings in existing implementations by emphasizing the following design goals and features:
Performance similar to that of Fortran [14], allowing to extend to quantum systems of large dimension. The numerical cost of the GRAPE method is dominated by the cost of evaluating the time evolution of the quantum system.
GRAPE.jl
delegates this to efficient piecewise-constant propagators inQuantumPropagators.jl
or the generalDifferentialEquations.jl
framework [15].Generality through the adoption of the concepts defined in
QuantumControl.jl
- Allow functionals that depend on an arbitrary set of "trajectories" $\{ |\Psi_k(t)⟩\}$, each evolving under a potentially different $\hat{H}_k$. In contrast to the common restriction to a single state $|\Psi⟩$ or a single unitary $\hat{U}$ as the dynamical state, this enables ensemble optimization for robustness against noise, e.g., Ref. [16]. The optimization over multiple trajectories is parallelized.
- Each $\hat{H}_k$ may depend on an arbitrary number of controls $\epsilon_l(t)$ in an arbitrary way, with a distinction between time-dependent "amplitudes" and "controls", going beyond the common assumption of linear controls, $\hat{H} = \hat{H}_0 + \epsilon(t) \hat{H}_1$.
Flexibility to work, via multiple dispatch, with any custom data structures for quantum states $|\Psi_k(t)⟩$ or the dynamic generators $\hat{H}_k(\{\epsilon_l(t)\})$, enabling a wide range of applications, from NMR spin systems to superconducting circuits or trapped atoms in quantum computing, to systems with spatial degrees of freedom, e.g., Ref. [17]. This also includes open quantum systems.
Arbitrary Functionals via semi-automatic differentiation [3]. The numerical scheme implemented in
GRAPE.jl
is derived from a generalization that calculates the gradient of the final-time functional via the chain rule with respect to the states $|\Psi_k(T)⟩$. This allows going beyond "standard functionals" based on overlaps with target states [1, 18] to any computable functional, including non-analytic functionals such as entanglement measures [19–21]. The consequence of this generalization is a boundary condition for the backward-propagation as $|\chi_k(T)⟩ = -\partial J_T/\partial ⟨\Psi_k(T)|$ instead of the target state in the traditional scheme. The state $|\chi_k(T)⟩$, as well as derivatives for any running costs, can optionally be obtained via automatic differentiation.
GRAPE.jl
is aimed at researchers in quantum control wanting flexibility to explore novel applications, while also requiring high numerical performance.
Contributing
See CONTRIBUTING.md
.
Consider using the JuliaQuantumControl Dev Environment.
History
See the Releases on Github.