Skip to content
Python implementation of Krotov's method for quantum optimal control
Python Makefile
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Initial commit Nov 6, 2018
binder Bump version to 0.5.0 (update HISTORY and Docs) Dec 4, 2019
docs Bump version to 0.5.0 (update HISTORY and Docs) Dec 4, 2019
scripts Set krotov version for Binder when making release Dec 4, 2019
src Bump version to 0.5.0 (update HISTORY and Docs) Dec 4, 2019
tests Handle `iter_stop=0` correctly Nov 21, 2019
.editorconfig Initial commit Nov 6, 2018
.gitignore Bootstrap tox.ini from tox-pyenv.ini Sep 15, 2019
.pre-commit-config.yaml Use local linters for pre-commit hooks Sep 11, 2019
.pylintrc Add linter configuration Apr 21, 2019
.travis.yml Use travis_wait when creating py38dev tox dir Nov 10, 2019
AUTHORS.rst Update History and Credits Nov 9, 2019
CONTRIBUTING.rst Update documentation to correspond to arxiv v5 Dec 4, 2019
HISTORY.rst Bump version to 0.5.0 (update HISTORY and Docs) Dec 4, 2019
LICENSE Initial commit Nov 6, 2018 Do isort-check when testing locally Apr 23, 2019
Makefile Set up Sphinx to LaTeX conversion Oct 9, 2019
README.rst Bump version to 0.5.0 (update HISTORY and Docs) Dec 4, 2019
readthedocs.yml Initial commit Nov 6, 2018
setup.cfg Use clean-script Sep 15, 2019 Revise documentation according to preprint Oct 11, 2019
tox-conda.ini Pass HOME to tox environment Nov 10, 2019


Krotov Python Package

Source code on Github Krotov on the Python Package Index Join the chat at Travis Continuous Integration AppVeyor Continuous Integration Codecov BSD License Documentation Status Launch Binder arXiv

Python implementation of Krotov's method for quantum optimal control.

This implementation follows the original implementation in the QDYN Fortran library.

The krotov package is built on top of QuTiP.

Development happens on Github. You can read the full documentation at online or download a PDF version.

If you use the krotov package in your research, please cite it.


Optimal control is a cornerstone of quantum technology: relying not just on a passive understanding of quantum mechanics, but on the active utilization of the quantum properties of matter. Quantum optimal control asks how to manipulate the dynamics of a quantum system in some desired way. This is essential for the realization of quantum computers and related technologies such as quantum sensing.

Krotov's method and GRAPE are the two leading gradient-based optimization algorithms used in numerical quantum optimal control. Krotov's method distinguishes itself by guaranteeing monotonic convergence for near-continuous control fields. This makes is particularly useful for exploring the limits of controllability in a physical system. While GRAPE is found in various software packages, there has not been an open source implementation of Krotov's method to date. Our package provides that missing implementation.

The Krotov package targets both students wishing to enter the field of quantum control and researchers in the field. It was designed towards the following goals:

  • Leverage the QuTiP library as a platform for numerically describing quantum systems.
  • Provide a collection of examples inspired by recent publications in the Jupyter notebook format, allowing for interactive exploration of the method.
  • Define a general interface for formulating any quantum control problem, which may extend to other optimization methods in the future.
  • Serve as a reference implementation of Krotov's method, and as a foundation against which to test other implementations.
  • Enable the more widespread use of Krotov's method, for example in the design of experiments.


The Krotov package is available for Python versions >= 3.5. Its main dependency is QuTiP (apart from the core packages of the Python scientific ecosystem). Thus, you should consider QuTiP's installation instructions.

In any case, using some sort of virtual environment is strongly encouraged. Most packages in the Python scientific ecosystem are now available as wheels, making installation via pip easy. However, QuTiP currently does not provide wheels. Thus, on systems that do not have the necessary compilers installed (Windows, macOS), the conda package manager provides a good solution.

Assuming conda is installed (e.g. through Miniconda), the following commands set up a virtual (conda) environment into which the Krotov package can then be installed:

$ conda create -n qucontrolenv python=3.7
$ conda activate qucontrolenv
$ conda config --append channels conda-forge
$ conda install qutip


To install the latest released version of krotov into your current (conda) environment, run this command in your terminal:

$ python -m pip install krotov

This is the preferred method to install the krotov package, as it will always install the most recent stable release.

You may also do

$ python -m pip install krotov[dev,extras]

to install additional development dependencies, including packages required to run the example notebooks.

If you don't have pip installed, the Python installation guide, respectively the Python Packaging User Guide can guide you through the process.

To install the latest development version of krotov from Github:

$ python -m pip install git+


To use Krotov's method for quantum optimal control in a Python script or Jupyter notebook, start with:

import krotov
import qutip


  1. define the necessary quantum operators and states using QuTiP.
  2. create a list of objectives, as instances of krotov.Objective.
  3. call krotov.optimize_pulses to perform an optimization of an arbitrary number of control fields over all the objectives.

See Using Krotov with QuTiP and Examples for details.

You can’t perform that action at this time.