Arxiv:1904.00031V1 [Quant-Ph] 29 Mar 2019
Total Page:16
File Type:pdf, Size:1020Kb
NetKet: A Machine Learning Toolkit for Many-Body Quantum Systems Giuseppe Carleo,1 Kenny Choo,2 Damian Hofmann,3 James E. T. Smith,4 Tom Westerhout,5 Fabien Alet,6 Emily J. Davis,7 Stavros Efthymiou,8 Ivan Glasser,8 Sheng-Hsuan Lin,9 Marta Mauri,1, 10 Guglielmo Mazzola,11 Christian B. Mendl,12 Evert van Nieuwenburg,13 Ossian O'Reilly,14 Hugo Th´eveniaut,6 Giacomo Torlai,1 and Alexander Wietek1 1Center for Computational Quantum Physics, Flatiron Institute, 162 5th Avenue, NY 10010, New York, USA 2Department of Physics, University of Zurich, Winterthurerstrasse 190, 8057 Z¨urich,Switzerland 3Max Planck Institute for the Structure and Dynamics of Matter, Luruper Chaussee 149, 22761 Hamburg, Germany 4Department of Chemistry, University of Colorado Boulder, Boulder, Colorado 80302, USA 5Institute for Molecules and Materials, Radboud University, NL-6525 AJ Nijmegen, The Netherlands 6Laboratoire de Physique Th´eorique,IRSAMC, Universit´ede Toulouse, CNRS, UPS, 31062 Toulouse, France 7Department of Physics, Stanford University, Stanford, California 94305, USA 8Max-Planck-Institut f¨urQuantenoptik, Hans-Kopfermann-Straße 1, 85748 Garching bei M¨unchen,Germany 9Department of Physics, T42, Technische Universit¨atM¨unchen, James-Franck-Straße 1, 85748 Garching bei M¨unchen,Germany 10Dipartimento di Fisica, Universit`adegli Studi di Milano, via Celoria 16, I-20133 Milano, Italy 11Theoretische Physik, ETH Z¨urich,8093 Z¨urich,Switzerland 12Technische Universit¨atDresden, Institute of Scientific Computing, Zellescher Weg 12-14, 01069 Dresden, Germany 13Institute for Quantum Information and Matter, California Institute of Technology, Pasadena, CA 91125, USA 14Southern California Earthquake Center, University of Southern California, 3651 Trousdale Pkwy, Los Angeles, CA 90089, USA We introduce NetKet, a comprehensive open source framework for the study of many-body quan- tum systems using machine learning techniques. The framework is built around a general and flexible implementation of neural-network quantum states, which are used as a variational ansatz for quan- tum wavefunctions. NetKet provides algorithms for several key tasks in quantum many-body physics and quantum technology, namely quantum state tomography, supervised learning from wavefunc- tion data, and ground state searches for a wide range of customizable lattice models. Our aim is to provide a common platform for open research and to stimulate the collaborative development of computational methods at the interface of machine learning and many-body physics. I. MOTIVATION AND SIGNIFICANCE approaches and algorithms is expected to grow rapidly given these first successes, steepening the learning curve. Recent years have seen a tremendous activity around The goal of NetKet is to provide a set of primitives the development of physics-oriented numerical techniques and flexible tools to ease the development of cutting- based on machine learning (ML) tools [1]. In the context edge ML applications for quantum many-body physics. of many-body quantum physics, one of the main goals NetKet also wants to help bridge the gap between the lat- of these approaches is to tackle complex quantum prob- est and technically demanding developments in the field lems using compact representations of many-body states and those scholars and students who approach the sub- based on artificial neural networks. These representa- ject for the first time. Pedagogical tutorials are provided tions, dubbed neural-network quantum states (NQS) [2], to this aim. Serving as a common platform for future re- can be used for several applications. In the supervised search, the NetKet project is meant to stimulate the open and easy-to-certify development of new methods and to arXiv:1904.00031v1 [quant-ph] 29 Mar 2019 learning setting, they can be used, e.g., to learn existing quantum states for which a non-NQS representation is provide a common set of tools to reproduce published available [3]. In the unsupervised setting, they can be results. used to reconstruct complex quantum states from exper- imental measurements, a task known as quantum state A central philosophy of the NetKet framework is to tomography [4]. Finally, in the context of purely varia- provide tools that are as simple as possible to use for tional applications, NQS can be used to find approximate the end user. Given the huge popularity of the Python ground- and excited-state solutions of the Schr¨odinger programming language and of the many accompanying equation [2, 5{9], as well as to describe unitary [2, 10, 11] tools gravitating around the Python ecosystem, we have and dissipative [12{15] many-body dynamics. Despite built NetKet as a full-fledged Python library. This sim- the increasing methodological and theoretical interest in plicity of use however does not come at the expense of NQS and their applications, a set of comprehensive, easy- performance. With this efficiency requirement in mind, to-use tools for research applications is still lacking. This all critical routines and components of NetKet have been is particularly pressing as the complexity of NQS-related written in C++11. 2 II. SOFTWARE DESCRIPTION which is done with the help of the nlohmann/json library for C++ [23]. Parallelization is implemented based on We will first give a general overview of the structure of the Message Passing Interface (MPI), allowing to sub- the code in Sect. II A and then provide additional details stantially decrease running time. Specifically, the Monte on the functionality of NetKet in Sect. II B. Carlo sampling of expectation values implemented in the variational.Vmc class is parallelized, with each node drawing independent samples from the probability dis- A. Software architecture tribution which are averaged over all nodes. The core of NetKet is implemented in C++. For ease of use and in order to facilitate the integration with other B. Software functionalities frameworks, a Python interface is provided, which ex- poses all high-level functionality from the C++ core via The core feature of NetKet is the variational represen- pybind11 [16] bindings. Use of the Python interface is tation of quantum states by artificial neural networks. recommended for users building on the library for re- Given a variational state, the task is to optimize its pa- search purposes, while the C++ code should be modified rameters with regard to a specified loss function, such as for extending the NetKet library itself. the total energy for ground state searches or the (nega- NetKet is divided into several submodules. The mod- tive) overlap with a given target state. In this section, ules graph, hilbert, and operator contain the classes we will discuss the models, types of variational wavefunc- necessary for specifying the structure of the many-body tions, and learning schemes that are available in NetKet. Hilbert space, the Hamiltonian, and other observables of a quantum system. The core component of NetKet is the machine mod- 1. Model specification ule, which provides different variational representa- tions of the quantum wavefunction, particularly in the NetKet currently supports lattice models with a finite form of NQS. The variational, supervised, and Hilbert space of the form H = NN H where N de- unsupervised modules contain driver classes for energy i=1 local notes the number of lattice sites. The system is defined optimization, supervised learning, and quantum state to- on a graph G = (V; E) with a set of sites V and a set mography, respectively. These driver classes are sup- of edges (also called bonds) E between sites. The graph ported by the sampler and optimizer modules, which structure is used to help with the definition of opera- provide classes for performing Variational Monte Carlo tors on the lattice and to encode the spatial structure of (VMC) sampling and optimization steps. the model, which is necessary, e.g., to work with con- The exact module provides functions for exact diago- volutional neural networks (CNNs). NetKet provides nalization (ED) and imaginary time propagation of the the predefined Hypercube and Lattice graphs. Fur- full quantum state, in order to allow for easy benchmark- thermore, CustomGraph supports arbitrary edge-colored ing and exploration of small systems within the NetKet graphs, where each edge is associated with an integer la- framework. ED can be performed by full diagonalization bel called its color. This color can be used to describe of the Hamiltonian or, alternatively, by a Lanczos proce- different types of bonds. dure, where the user may choose between a sparse matrix representation of the Hamiltonian and a matrix-free im- Several predefined Hamiltonians are provided, such as plementation. The Lanczos solver is based on the IETL spin models (transverse field Ising, Heisenberg models) or library from the ALPS project [17, 18] which implements bosonic models (Bose-Hubbard model). For specifying a variant of the Lanczos algorithm due to Cullum and other observables and custom Hamiltonians, additional classes are available: A convenient option for common Willoughby [19, 20]. The dynamics module provides a basic Runge-Kutta ODE solver which is used for the ex- lattice models is to use the GraphOperator class, which act imaginary time propagation. allows to construct a Hamiltonian from a family of 2-local operators acting on each bond of a selected color and a The utility modules output, stats, and util contain family of 1-local operators acting on each site. It is also some additional functionality for output and statistics possible to specify general k-local operators (as well as that is used internally in other parts of NetKet. their products and sums) using the class. An overview of the most important modules and their LocalOperator dependencies is given in Figure 1. A more detailed de- scription of the module contents will be given in the next section. 2. Variational quantum states NetKet uses the Eigen 3 library [21] for linear algebra routines. In the Python interface, Eigen datatypes are The purpose of variational states is to provide a transparently converted to and from NumPy [22] arrays compact and computationally efficient representation of by pybind11.