Package: krotov
Krotov Python PackagePython implementation of Krotov’s method for quantum optimal control.This implementation follows the original implementation in theQDYN Fortran library.Thekrotovpackage is built on top ofQuTiP.Development happens onGithub. You can read the full documentationonlineordownload a PDF version.If you use thekrotovpackage in your research, pleasecite it.PurposeOptimal control is a cornerstone of quantum technology: relying not
just on a passive understanding of quantum mechanics, but on theactiveutilization 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 theQuTiPlibrary as a platform for numerically describing
quantum systems.Provide a collection of examples inspired by recent publications in
theJupyter notebookformat, allowing for interactive exploration of the
method.Define a general interface for formulatinganyquantum 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.PrerequisitesThe Krotov package is available for Python versions >= 3.5. Its main dependency isQuTiP(apart from thecore packages of the Python scientific ecosystem).
Thus, you should considerQuTiP’s installation instructions.In any case, using some sort ofvirtual environmentis strongly encouraged.
Most packages in the Python scientific ecosystem are now available aswheels, making installation viapipeasy. However,QuTiP currently does
not provide wheels. Thus, on systems that do not have the necessary compilers
installed (Windows, macOS), thecondapackage manager provides a good solution.Assumingcondais installed (e.g. throughMiniconda), the following
commands set up a virtual (conda) environment into which the Krotov package can
then be installed:condacreate-nqucontrolenv"python=3.7"condaactivatequcontrolenvcondaconfig--appendchannelsconda-forgecondainstallqutipInstallationTo install the latest released version ofkrotovinto your current (conda)
environment, run this command in your terminal:python-mpipinstallkrotovThis is the preferred method to install thekrotovpackage, as it will always install the most recent stable release.You may also dopython-mpipinstallkrotov[dev,extras]to install additional development dependencies, including packages required to run the example notebooks.If you don’t havepipinstalled, thePython installation guide, respectively thePython Packaging User Guidecan guide
you through the process.To install the latest development version ofkrotovfromGithub:python-mpipinstallgit+https://github.com/qucontrol/krotov.git@master#egg=krotovUsageTo use Krotov’s method for quantum optimal control in a Python script orJupyter notebook, start with:import krotov
import qutipThen,define the necessary quantum operators and states usingQuTiP.create a list of objectives, as instances ofkrotov.Objective.callkrotov.optimize_pulsesto perform an optimization of an arbitrary
number of control fields over all the objectives.SeeUsing Krotov with QuTiPandExamplesfor details.History1.2.1 (2021-01-13)Bugfix: Crash when initializing discretized numpy-array controls (#79, thanks to@loganbvh)Bugfix: Corrected definition of co-states in Dissipative Qubit Reset example (#80, thanks toAlberto Castro)Update: Switched Testing and Documentation deployment from Travis to Github Actions (#82)1.2.0 (2020-08-17)Added:via_midpointsargument tokrotov.conversions.discretizefunctionChanged: Controls and update shapes are now discretized in a way that ensures numerical stability (#74, thanks to@zachmanson)Changed: Replacedunisegdependency withgrapheme(#76)Note: due to the changes in the time discretization of the controls and update shapes, this version will generally not reproduce optimization results from previous versions to machine precision.1.1.0 (2020-03-24)Added: Support for Python 3.8Added: Support for QuTiP 4.5.0Added: Support for parallelization withloky(#72)Added:krotov.parallelization.set_parallelizationfunctionAdded:krotov.parallelization.parallel_mapfunction (improved implementation of QuTiP’sparallel_map)Added: Ability to usethreadpoolctlto limit unwanted threadingAdded:limit_thread_pooloption tokrotov.optimize_pulsesChanged:krotov.propagators.expmnow guarantees single-threaded execution1.0.0 (2019-12-16)Update: Citation info now points toSciPost paper(#61)Added: parameterscol_formatsandcol_headersto customize the output ofkrotov.info_hooks.print_table(#65)Added: info-hooks now have access to the additional argumentspropagator,chi_constructor,mu,sigma,iter_start, anditer_stop(#66)Added: parameterkeep_original_objectivestokrotov.objectives.ensemble_objectives(#67)Added: “Related Software” in the documentationUpdate: Documentation is now hosted ongh-pagesand deployed byDoctr(#68)0.5.0 (2019-12-04)Update: Documentation now contains all information fromhttps://arxiv.org/abs/1902.11284v5Added: Allow to passargsto time-dependent control functions (#56, thanks to@timohillmann)Changed: Renamedkrotov.structural_conversionstokrotov.conversionsBugfix: Crash whenkrotov.optimize_pulsesis called withiter_stop=0(#58)Added:krotov.result.Resultis now exposed at the top level of the API, askrotov.Result(#59, thanks to@nathanshammah)Added: str-representation ofkrotov.result.Resultnow includes the total running time (#60, thanks to@nathanshammah)0.4.1 (2019-10-11)Update: Documentation now contains all information fromhttps://arxiv.org/abs/1902.11284v4(#54)Added: a PDF of the documentation is now available athttps://github.com/qucontrol/krotov/tree/master/docs/pdf(#52, thanks to@TejasAvinashShetty)0.4.0 (2019-10-08)Added: Support for Python 3.7Changed: The'shape'key inpulse_optionswas renamed to'update_shape', to further avoid confusion between pulse shapes and update shapes.Changed: The.adjointproperty ofObjectiveis now a methodAdded: Ability to not use QuTiPQobjobjects, but arbitrary low-level objects instead.Improved: Printing anObjectivenow uses internal counters and a symbolic notation to identify objects shared between different objectives. (#43)Improved:gate_objectivesnow takes into account if target states are (reshuffled) basis states and does not create unnecessary new copies.Bugfix: TwoObjectiveinstances that contain numpy arrays as controls can now be compared with==(#44)Bugfix: Custom attributes (such asweight) are now preserved when copying anObjective(#44)Bugfix: Callingcopy.deepcopyon anObjectivenow preserves control functions (#44)Improved: TheObjective.mesolveandObjective.propagatemethods can now receive argumentsHandc_opsto 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: Theprint_tableandprint_debug_informationinfo-hooks now flush their output buffers after each iteration. As a result, when writing to a file, that file can be watched withtail-f.Changed: Redefinetau_valsas their complex conjugate, fixing a bug inchis_ssandchis_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: Methodobjectives_with_controlsforResultobject.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: Parameterouttoprint_tableinfo-hookAdded: ParameterfinalizetoResult.loadAdded: Ability to dump optimization result every so many iterations (dump_resultcheck-convergence routine)Added:re-entrantoption forDensityMatrixODEPropagatorBugfix: Discretize controls to float values (#41)Bugfix: Fix overlap for non-Hermitian operators (#39)Bugfix: Interface for passingtau_valstochi_constructor(#36)Added: functionabove_valuefor convergence check (#35)0.2.0 (2019-02-14)Added: Implementation of all the standard functionalsAdded: Theinfo_hookreceives additional information, including ∫gₐ(t)dt (#32)Added: Initialization of objectives for gate optimization in Liouville spaceAdded: A new propagatorDensityMatrixODEPropagatorfor faster density matrix propagationAdded: Support for “stateful” propagators by subclassing fromkrotov.propagators.PropagatorChanged: more flexibility for parallelization (#29)Added: Support for the second-order pulse updateChanged: The options for the controls (λₐ, update-shape) are now passed through a simplifieddictinterface, instead of a customPulseOptionsclass.0.1.0 (2018-12-24)Initial release with complete implementation of first-order Krotov’s methodSupport for state-to-state and gate optimization, for both closed and open systems