Source-linked AI summary
Krotov: A Python implementation of Krotov's method for quantum optimal control
Michael H. Goerz, Daniel Basilewitsch, Fernando Gago-Encinas, Matthias G. Krauss, Karl P. Horn, Daniel M. Reich, Christiane P. Koch
TL;DR
Accurate quantum operations in increasingly complex systems require suitable external control fields. This paper presents a Python implementation of Krotov’s method and reports monotonic convergence in the continuous-time limit. Its conclusion emphasizes fast initial convergence and suitability for time-continuous controls.
Problem
Quantum technologies require accurate operations in increasingly complex systems, motivating methods for designing suitable external fields.
Source: §1 · p. 2Method
The paper presents a Python implementation of Krotov’s method with example use cases for quantum optimal control.
Source: §6 · p. 25Results
Krotov’s method guarantees monotonic convergence in the continuous-time limit, and the package conclusion highlights fast initial convergence and aptitude for time-continuous controls.
Source: §4.3 · p. 20, §6 · p. 25Takeaways & Limitations
Ensemble optimization over perturbed systems yields controls robust over a wide range of system perturbations.
Source: §3.3 · p. 15A rigorous spectral constraint requires solving a Fredholm equation of the second kind, which has not yet been implemented numerically.
Source: §5 · p. 24
Abstract
from arXiv · showhide
We present a new open-source Python package, krotov, implementing the quantum optimal control method of that name. It allows to determine time-dependent external fields for a wide range of quantum control problems, including state-to-state transfer, quantum gate implementation and optimization towards an arbitrary perfect entangler. Krotov's method compares to other gradient-based optimization methods such as gradient-ascent and guarantees monotonic convergence for approximately time-continuous control fields. The user-friendly interface allows for combination with other Python packages, and thus high-level customization. The package is being developed at https://github.com/qucontrol/krotov
1 Introduction
Quantum optimal control helps design external fields for accurate operations in increasingly complex quantum systems. The paper introduces an open-source Python implementation of Krotov’s method to address the lack of such an implementation, with examples for varied control problems and a focus on clarity despite possible performance limits.
1 Introduction
- Quantum optimal control designs external fields for accurate operations, supporting technologies such as quantum computing and sensing.The field has been adapted to quantum information science, with control calculations standard for state preparation and gate implementation.Source: §1 · p. 2
- Krotov’s method updates controls sequentially and guarantees monotonic convergence, but an open-source implementation had been lacking.The package provides that implementation.Source: §1 · p. 3
- Python, QuTiP, and Jupyter support an accessible, customizable, and reproducible workflow for quantum-control exploration.QuTiP already includes GRAPE and CRAB implementations.Source: §1 · p. 3
- The package targets students and researchers with examples that illustrate typical control problems and Krotov’s method.It addresses open-system dynamics as well as closed systems and may aid NISQ technology development.Source: §1 · p. 3
- For hard problems requiring thousands of iterations, Python may be too slow, so compiled implementations may be preferable.Pure Python typically performs two to three orders of magnitude slower than compiled scientific-computing languages; the package emphasizes clarity and can serve as a reference implementation.Source: §1 · p. 3
2 Overview of Krotov’s method and the krotov package
This section outlines Krotov’s iterative control-field updates for minimizing a quantum-control objective and the Python interfaces provided by the krotov package, illustrated by two-level state transfer that improves from 0.049 to approximately 0.999 with monotonic functional convergence up to time-discretization effects.
2.1 The quantum control problem
- Quantum control uses time-dependent fields in a system’s Hamiltonian to steer its evolution toward targets such as state transfers or quantum gates.The method can address multiple states and distinct Hamiltonians, and open-system dynamics can be represented with density matrices and a Liouvillian.Source: §2.1 · p. 4
2.2 Optimization functional
- The optimization functional combines a final-time objective and a control-field running cost, with an optional state-dependent cost that the package does not support.The state-dependent term can encode time-dependent targets or penalize subspace population; subspace population can also be penalized using a non-Hermitian Hamiltonian.Source: §2.2 · pp. 5–6
2.3 Iterative control update
- The field update scales with the update shape and inverse step width, which control update magnitude and can preserve boundary conditions or leave selected time intervals unchanged.A step width that is too large can cause numerical instability, while one that is too small can slow convergence.Source: §2.3 · pp. 6–7
2.4 Example: state-to-state transition in a two-level system
- In the example, krotov.optimize_pulses accepts objectives, pulse options, a time grid, a propagator, and a chi constructor to define the optimization.The expm propagator constructs the evolution operator by matrix exponentiation and can be useful for debugging at dimensions greater than 10, though it is inefficient for larger Hilbert spaces; the chi constructor sets the backward-propagation boundary condition and encodes the final-time functional.Source: §2.4 · pp. 9–10
- The example’s total functional J falls from 9.51e-01 at iteration 0 to 1.07e-03 at iteration 18, with ΔJ=-6.91e-04 at iteration 18.The example checks for a functional value below 10^-3 and for monotonic decrease between iterations.Source: §2.4 · pp. 11–12
- The optimization converged in 18 iterations after reaching the termination criterion J_T < 1e-3.The reported run lasted 38 seconds.Source: §2.4 · p. 12
- The total-functional change is guaranteed to be negative, giving monotonic convergence up to time-discretization effects.As optimization converges, control-field changes become smaller, and the chosen update shape preserves smooth switch-on and switch-off from zero at t = 0 and t = 5.Source: §2.4 · p. 12
- Population transfer rose from 0.049 under the guess control to ≈0.999 under the final optimized control.The figure shows the population dynamics across iterations, with opacity increasing through the final control.Source: Figure 1 · p. 13, §2.4 · p. 13
3 Common optimization tasks
The section shows how krotov supports common quantum-control tasks, from complex-valued fields and gate optimization to robustness and non-convex objectives.
3.1 Complex-valued controls
- For complex controls in the rotating-wave approximation, optimize real and imaginary parts as separate fields with corresponding control Hamiltonians.For simple state-to-state or gate optimization, transforming target states into the rotating frame before constructing the terminal co-states is described as straightforward and numerically efficient.Source: §3.1 · p. 13
3.2 Optimization towards a quantum gate
- Gate objectives can target closed- or open-system gates, local-equivalence classes, or arbitrary perfect entanglers.For an open-system iSWAP example, three density matrices suffice, with relative weights 20:1:1; local-equivalence and arbitrary-perfect-entangler objectives may require a second-order update.Source: §3.2 · p. 14
3.3 Ensemble optimization as a way to ensure robust controls
- Ensemble optimization averages objectives across perturbed system Hamiltonians, producing shared control pulses that are robust over a wide range of perturbations.The example samples variations in Rydberg coupling and energy while accounting for decay and dephasing in Liouville space.Source: §3.3 · p. 15
3.4 Optimization of non-linear problems or non-convex functionals
- For arbitrary-perfect-entangler optimization with a non-convex functional, a second-order Krotov update is required to guarantee monotonic convergence.A first-order update may nevertheless converge in practice and costs fewer numerical resources, so the authors advise trying it first and using second order if insufficient.Source: §3.4 · pp. 15, 17
4 Comparison of Krotov’s method and other optimization methods
The section compares iterative open-loop optimization methods and explains how their update schemes, control parametrizations, and problem constraints guide method choice.
4.1 Iterative schemes from variational calculus
- Variational-calculus methods derive control conditions using co-states as Lagrange multipliers, but their continuous-time implicit equations require iterative solution and time discretization.The concurrent update uses states and co-states from the previous iteration and does not guarantee monotonic convergence, requiring a line search; other schemes can guarantee monotonicity through a modified functional.Source: §4.1 · pp. 17–18
4.3 GRadient Ascent Pulse Engineering (GRAPE)
- GRAPE discretizes the functional before applying variational calculus, then updates discrete control amplitudes using a concurrent gradient scheme.GRAPE lacks a monotonic-convergence guarantee, though GRAPE-LBFGS empirically usually converges monotonically; it is advantageous for physically piecewise-constant controls.Source: §4.3 · pp. 19–20
4.2 Krotov’s method
- Krotov’s sequential update guarantees monotonic convergence in the continuous-time limit without a line search, while its convergence advantage over concurrent GRAPE disappears near the optimum.The Krotov construction requires no ad-hoc functional modification and can be extended to non-convex functionals using a second-order construction.Source: §4.2 · p. 18, §4.3 · p. 20
4.4 Gradient-free optimization
- Gradient-free optimization is suited to few-parameter controls and can optimize non-analytic functionals without backward propagation or state storage.CRAB uses a low-dimensional random basis and can get stuck in local minima; DCRAB re-parametrizes controls when this occurs, while gradient-free methods can also pre-optimize guess pulses.Source: §4.4 · p. 21
4.5 Choosing an optimization method
- Choose among gradient-free methods, GRAPE, and Krotov according to parameter count, control discretization, and whether the functional’s derivatives are tractable.Gradient-free methods suit fewer than about 20 parameters or difficult gradients and can improve guess pulses; GRAPE suits discrete controls, while Krotov suits approximately time-continuous controls when the state derivative is available.Source: §4.5 · p. 23
4.3 GRadient Ascent Pulse Engineering (GRAPE)
- For analytic control coefficients, GROUP or GOAT may be suitable; GOAT avoids piecewise-constant discretization error but scales linearly in memory and/or CPU with parameter count.The section notes GOAT is best used below 100 parameters and can support optimization to extremely high fidelities.Source: §4.3 · p. 21, §4.5 · p. 23
5 Future perspectives
The package already addresses a broad range of optimization targets, but the authors identify several extensions that could increase its versatility. These include pulse parametrization, state-dependent and spectral constraints, and combinations with other optimization approaches.
5 Future perspectives
- Pulse parametrization could support positive fields or an upper amplitude bound, but nonlinear parametrizations require a sufficiently large inverse step size to preserve monotonic convergence.The proposed update is formulated in terms of u(t), with the physical pulse obtained after optimization.Source: §5 · p. 23
- State-dependent constraints could enable time-dependent targets, but non-convex constraints require a second-order update and add a source term that may challenge differential equation solvers.The package would need to calculate and pass that source term to an appropriate solver.Source: §5 · p. 24
- Spectral constraints can preserve monotonic convergence when their Fourier-transform kernel is positive semi-definite, but implementing the required Fredholm equation remains outstanding.The current package instead supports spectral-width limitation through post-iteration filtering and mixing filtered and unfiltered controls.Source: §5 · p. 24
- Krotov’s method requires analytically computable derivatives and searches locally, so optimized pulses depend on the initial guess; gradient-free pre-optimization and automatic differentiation are proposed as possible complements.The authors also suggest combining the package with NLopt and exploring machine-learning techniques.Source: §5 · p. 24
6 Conclusions
The paper presents an open-source Python implementation of Krotov’s method with examples for quantum optimal control. It emphasizes monotonic convergence and time-continuous controls, while noting that other methods may be preferable under strong external constraints.
6 Conclusions
- The package provides Krotov’s method with examples for quantum-information applications; its stated hallmarks are fast initial convergence, monotonicity, and aptitude for time-continuous controls.The implementation, examples, explanations, and pseudocode may also serve as a reference for implementations in other systems or languages.Source: §6 · p. 25
- The package’s interface aims to describe general quantum-control problems and lifts limitations of QuTiP’s existing routines on target types and coarse time grids.The authors propose that the same interface could later drive other optimization methods for direct comparison.Source: §6 · p. 25
- Krotov’s method is particularly suited to exploring fundamental control limits with least-constrained fields, while other methods may have an advantage under strong experimental constraints.The discussion is intended to help readers choose an appropriate method for their constraints.Source: §6 · p. 25
A The Krotov update equation
This appendix section introduces the numerical field update at the core of Krotov’s method and notes that discretization yields a numerical scheme.
A The Krotov update equation
- Each iteration numerically evaluates the field update, which is the computational core of Krotov’s method.The section also discusses how discretizing the update leads to a numerical scheme.Source: A The Krotov update equation · p. 25
- The appendix focuses on the numerical evaluation of the update rather than only its formal expression.The update is the core calculation repeated across iterations.Source: A The Krotov update equation · p. 25
- Discretization of the field update leads to a numerical scheme.The update is evaluated in each iteration.Source: A The Krotov update equation · p. 25
A.1 First order update
The first-order update is part of a coupled propagation scheme, with forward states and backward adjoint states. The passage also describes conditions and extensions relevant to monotonic convergence.
A.1 First order update
- The passage states a monotonic-convergence condition for a general functional with a convex final-time functional.It also notes that the relevant condition holds by construction for the referenced case.Source: §A.1 · p. 26
- The update equation applies independently to each control field when multiple controls are present.For nonlinear control Hamiltonians, the derivative must be evaluated at the current iteration’s control.Source: §A.1 · p. 26
- The first-order update is presented as the means of calculating the updated control fields.The update follows from the stated choice of the field functional.Source: §A.1 · p. 26
- The forward states are propagated according to their equation of motion, while the adjoint states are propagated backward under the previous iteration’s guess controls.The backward propagation uses the boundary condition specified for the adjoint states.Source: §A.1 · p. 26
- For open-system dynamics, the coupled equations replace states with density matrices, the Hamiltonian with iL, and inner products with Hilbert–Schmidt products.Backward propagation uses the adjoint operator, including for dissipative Liouvillians and non-Hermitian Hamiltonians.Source: §A.1 · p. 26
A.2 Second order update
The first-order update assumes linear dynamics, a convex terminal functional, and no state-dependent constraints. When these assumptions fail, a second-order term can retain monotonic convergence, provided its scalar function is chosen appropriately.
A.2 Second order update
- The first-order update assumes linear equations of motion, a convex terminal functional, and no state-dependent constraints.Source: §A.2 · p. 26
- A second-order term permits monotonic convergence when the first-order update’s assumptions are not met.The full construction of the second-order condition is given in Ref..Source: §A.2 · p. 27
- The scalar function σ(t) in the second-order update must be chosen to ensure monotonic convergence and can be approximated numerically.The paper points to Ref. and gives an example in Section 3.4.Source: §A.2 · p. 27
A.3 Time discretization
The continuous-time derivation guarantees monotonic convergence, but its numerical implementation uses piecewise-constant controls on a discrete time grid. The resulting sequential scheme updates each interval using past information, with step-size choices affecting convergence and stability.
A.3 Time discretization
- Monotonic convergence is mathematically guaranteed only for time-continuous controls; numerical controls are piecewise constant on a grid from 0 to T.States are defined at grid points, while controls are constant over intervals.Source: §A.3 · p. 27
- A coarse time step requires a larger inverse step size λa,l, which slows convergence; values that are too small can cause spikes and numerical instability.Source: §A.3 · p. 27
- In practice, begin with a comparatively large λa,l, then lower it as far as possible without instability; tuning generally requires trial and error.The value can be adjusted dynamically according to convergence rate.Source: §A.3 · p. 28
- The discretized scheme uses backward propagation to store states, then updates the first pulse interval from the known initial states at its midpoint.The midpoint update follows from piecewise-constant controls on an equidistant grid.Source: §A.3 · p. 28
- After each interval’s field update, the state is propagated one step forward, and the updates proceed sequentially across the grid.The updated field becomes the next iteration’s guess; optimization stops at a functional threshold or when its change approaches zero.Source: §A.3 · p. 28
- The discretized update resolves the continuous equation’s apparent dependence on states propagated under the not-yet-known updated field: each interval uses only past information.The continuous update re-emerges as the limit as dt approaches zero.Source: §A.3 · p. 28
B Pseudocode for Krotov’s method
The pseudocode implements Krotov’s time-discretized optimization, organizing inputs around objectives and propagating states through a backward pass followed by sequential control updates. It also documents stopping criteria, parallelization, and memory trade-offs.
B Pseudocode for Krotov’s method
- The package groups inputs into objectives, each containing an initial state, its Hamiltonian or Liouvillian, control operators, and possibly a target.The Hamiltonian is often shared across objectives, as are control operators when it is linear in the controls.Source: B Pseudocode for Krotov’s method · p. 29
- Time propagation dominates CPU cost under the stated assumption, and loops over independent objectives can be parallelized, though MPI may incur state-vector communication overhead.For some functionals, inter-process communication can be reduced to scalar values.Source: B Pseudocode for Krotov’s method · p. 29
- Storage is dominated by arrays for forward and backward states; when a first-order update suffices, forward arrays can collapse, and without state-dependent constraints they can be omitted.Recovering backward states by forward propagation can eliminate their storage at the cost of an additional propagation.Source: B Pseudocode for Krotov’s method · p. 29
- The algorithm takes initial controls, update shapes and step sizes, initial states, a propagator, control operators, and a terminal-state mapping as inputs.A second-order construction can additionally require σ(t); the output is optimized controls and the functional J.Source: B Pseudocode for Krotov’s method · p. 30
- The optimization loop can stop when the functional or its change crosses a threshold, when a maximum iteration count is reached, or under another chosen criterion.Source: B Pseudocode for Krotov’s method · p. 30
- The listed loops show backward propagation with storage followed by a sequential update loop; internal parameters of σ(t) are updated if necessary using Φ0 and Φ1.Source: B Pseudocode for Krotov’s method · p. 31
C Installation instructions
The package is installed in a Python environment with QuTiP as its main dependency. The instructions recommend an isolated environment and provide routes for installing the package and its example dependencies.
C Installation instructions
- The package supports Python versions ≥3.5 and has QuTiP as its main dependency.The instructions refer users to QuTiP’s installation guidance.Source: C Installation instructions · p. 32
- The instructions recommend an isolated environment and describe using conda to create one and install QuTiP.Conda’s binary scientific-package builds may help on systems where compiled extensions are difficult to install.Source: C Installation instructions · p. 32
- The released package is installed with pip, while the documentation examples and Section 2.4 require additional dependencies installable with krotov[dev].Source: C Installation instructions · p. 32
- For current installation guidance, consult the package documentation linked in Appendix D.Source: C Installation instructions · p. 32
D Package documentation
The paper presents only krotov’s central features and directs readers to its online documentation and examples for fuller guidance.
D Package documentation
- The paper covers only krotov’s most central features; complete documentation is available online.The package’s current version is available on GitHub under a BSD license.Source: D Package documentation · p. 32
- The Section 2.4 example is available as a script and as a Jupyter notebook.The online documentation also provides notebooks illustrating the Section 3 optimization tasks in more detail.Source: D Package documentation · p. 32