Python implementation of Krotov's method for quantum optimal control
Krotov Python Package
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.
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.
To install the latest development version of krotov from Github:
$ python -m pip install git+https://github.com/qucontrol/krotov.git@master#egg=krotov
To use Krotov’s method for quantum optimal control in a Python script or Jupyter notebook, start with:
import krotov import qutip
- 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.
- Update: Documentation now contains all information from https://arxiv.org/abs/1902.11284v4 (#54)
- Added: a PDF of the documentation is now available at https://github.com/qucontrol/krotov/tree/master/docs/pdf (#52, thanks to @TejasAvinashShetty)
- Added: Support for Python 3.7
- Changed: The 'shape' key in pulse_options was renamed to 'update_shape', to further avoid confusion between pulse shapes and update shapes.
- Changed: The .adjoint property of Objective is now a method
- Added: Ability to not use QuTiP Qobj objects, but arbitrary low-level objects instead.
- Improved: Printing an Objective now uses internal counters and a symbolic notation to identify objects shared between different objectives. (#43)
- Improved: gate_objectives now takes into account if target states are (reshuffled) basis states and does not create unnecessary new copies.
- Bugfix: Two Objective instances that contain numpy arrays as controls can now be compared with == (#44)
- Bugfix: Custom attributes (such as weight) are now preserved when copying an Objective (#44)
- Bugfix: Calling copy.deepcopy on an Objective now preserves control functions (#44)
- Improved: The Objective.mesolve and Objective.propagate methods can now receive arguments H and c_ops to override the respective attributes of the objectives. This make is easier to analyze perform a robustness analysis, where the result of an optimization should be propagated under a perturbed Hamiltonian.
- Improved: The print_table and print_debug_information info-hooks now flush their output buffers after each iteration. As a result, when writing to a file, that file can be watched with tail -f.
- Changed: Redefine tau_vals as their complex conjugate, fixing a bug in chis_ss and chis_sm (#46)
- Bugfix: Correctly calculate ∂H/∂ϵ if ϵ occurs in H multiple times (#47, thanks to @uiofgh)
- Bugfix: Correctly calculate ∂H/∂ϵ=0 if the specific ϵ currently being updated does not occur in H (#48)
- Added: Method objectives_with_controls for Result object.
- 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)
- 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.
- 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
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size krotov-0.4.1-py2.py3-none-any.whl (68.4 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View hashes|
|Filename, size krotov-0.4.1.tar.gz (4.8 MB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for krotov-0.4.1-py2.py3-none-any.whl