Skip to main content

Python implementation of Krotov's method for quantum optimal control

Project description

Krotov Python Package

Source code on Github Krotov on the Python Package Index Join the chat at https://gitter.im/qucontrol_krotov/Lobby Travis Continuous Integration AppVeyor Continuous Integration Coveralls BSD License Documentation Status arXiv

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

This implementation follows the original implementation in the QDYN Fortran library. The method is described in detail in D. M. Reich, M. Ndong, and C. P. Koch, J. Chem. Phys. 136, 104103 (2012) (arXiv:1008.5126).

The krotov package is built on top of QuTiP.

Development happens on Github. You can read the full documentation at ReadTheDocs.

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

Purpose

Optimal control is a cornerstones 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 to behave in some desired way. This is essential for the realization of quantum computers, and related technologies such as quantum sensing. See e.g. Glaser et al. Eur. Phys. J. D 69, 279 (2015) for an overview of methods, applications, and current research directions. Quantum technology and thus quantum control are the focus of several large-scale national and super-national research endeavors, such as the U.S. $1 billion National Quantum Initiative Act and the €1 billion European Quantum Flagship program.

Krotov’s method is one of the two leading gradient-based optimization algorithms used in numerical quantum optimal control. It simulates the dynamics of a quantum system under a set of initial controls, and evaluates the result with respect to an optimization functional to be minimized. It then iteratively modifies the controls to guarantee a monotonically decreasing value in the optimization functional. To date, there has not been an open source implementation of the method. This package provides that missing implementation.

The choice of Python as an implementation language is due to Python’s easy to learn syntax, expressiveness, and immense popularity in the scientific community. Moreover, the QuTiP library exists to provide the foundations of numerically describing quantum systems, and already includes basic versions of some of the other popular algorithms in quantum control, the gradient-based GRAPE and the gradient-free CRAB. The availability of the Jupyter notebook framework provides an ideal platform for showing the use of the method.

The Krotov package targets both students wishing to enter the field of quantum control, and researchers in the field. By providing a comprehensive set of examples, we enable users of our package to explore the formulation of typical control problems, and to understand how Krotov’s method can solve them. These examples are inspired by recent publications, and thus show the use of the method at the cutting edge of research. Optimal control is also increasingly important in the design of experiments, and we hope that the availability of an easy to use implementation of Krotov’s will facilitate this further.

The use of Python implies that for large-scale control problems, performance may become a significant issue. In this case, it may be necessary to implement Krotov’s method in a more efficient (compiled) language. While the method as such is relatively straightforward, there are some subtleties involved. Our implementation puts an emphasis on clarity, and the documentation provides detailed explanations of all necessary concepts. Thus, the Krotov package can serve as a reference implementation, leveraging Python’s reputation as “executable pseudocode”, and as a foundation against which to test other implementations.

Prerequisites

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.6
$ conda activate qucontrolenv
$ conda config --append channels conda-forge
$ conda install qutip

Installation

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

$ 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

$ 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:

$ pip install git+https://github.com/qucontrol/krotov.git@master#egg=krotov

Usage

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

import krotov

Then,

  • define the necessary quantum operators and states using QuTiP.

  • create a list of objectives, as instances of krotov.Objective

  • 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.

History

0.3.0 (2019-03-01)

  • Added: Preprint citation information (krotov.__arxiv__, krotov.__citation__, krotov.__bibtex__)

  • Added: Ability to continue from a previous optimization (#26)

  • Added: Parameter out to print_table info-hook

  • Added: Parameter finalize to Result.load

  • Added: Ability to dump optimization result every so many iterations (dump_result check-convergence routine)

  • Added: re-entrant option for DensityMatrixODEPropagator

  • Bugfix: Discretize controls to float values (#41)

  • Bugfix: Fix overlap for non-Hermitian operators (#39)

  • Bugfix: Interface for passing tau_vals to chi_constructor (#36)

  • Added: function above_value for convergence check (#35)

0.2.0 (2019-02-14)

  • Added: Implementation of all the standard functionals

  • Added: The info_hook receives additional information, including ∫gₐ(t)dt (#32)

  • Added: Initialization of objectives for gate optimization in Liouville space

  • Added: A new propagator DensityMatrixODEPropagator for faster density matrix propagation

  • Added: Support for “stateful” propagators by subclassing from krotov.propagators.Propagator

  • Changed: more flexibility for parallelization (#29)

  • Added: Support for the second-order pulse update

  • Changed: The options for the controls (λₐ, update-shape) are now passed through a simplified dict interface, instead of a custom PulseOptions class.

0.1.0 (2018-12-24)

  • Initial release with complete implementation of first-order Krotov’s method

  • Support for state-to-state and gate optimization, for both closed and open systems

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

krotov-0.3.0.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

krotov-0.3.0-py2.py3-none-any.whl (63.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file krotov-0.3.0.tar.gz.

File metadata

  • Download URL: krotov-0.3.0.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for krotov-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4ebca474b510d0d82b407e8914bf6a8828267968555a0338dbdd7575e2bb9bd4
MD5 15ecb5d8ac66d29d9c2c27284ad5cd08
BLAKE2b-256 f6cd5ebb87bd5b709d20b50ccfe5c1205e9143ad78bd92c2795ac70944c153b7

See more details on using hashes here.

File details

Details for the file krotov-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: krotov-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 63.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for krotov-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6ffa19d61903edac42b2c965b0485b3b65ab0cd7e3328f42f7a1fb1108875275
MD5 4d21351b0b595b31329e10d5ef38d514
BLAKE2b-256 aa5365a461abd3182a5c09d1ef7d1478b93540745d14434b6abe1c7231a7b703

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page