Welcome to the documentation for Netket 3.0.
Please read the release notes to see what has changed since the last release.
Installation and requirements¶
Netket v3.0 requires python>= 3.8 and optionally a recent MPI install. To install, run one of the two following commands
pip install netket
If you want to run NetKet on a GPU, you must install a GPU-compatible
jaxlib. For that, we advise you to
look at the instructions on jax repository, however at the time
of writing, this means you should run the following command:
pip install --upgrade "jax[cuda111]" -f https://storage.googleapis.com/jax-releases/jax_releases.html
Where the jaxlib version must correspond to the version of the existing CUDA installation you want to use. Refer to jax documentation to learn more about matching cuda versions with python wheels.
To query the installed netket version you can run the following command in your shell
python -e "import netket; print(netket.version)"
If you want to use MPI, you will need to have a working MPI compiler. You can install the dependencies necessary to run with MPI with the following command:
pip install netket[mpi]
Subsequently, NetKet will exploit MPI-level parallelism for the Monte-Carlo sampling. See this block to understand how NetKet behaves under MPI.
Netket is a numerical framework written in Python to simulate many-body quantum systems using variational methods. In general, netket allows the user to parametrize quantum states using arbitrary functions, be it simple mean-field ansatze, Jastrow, MPS ansatze or convolutional neural networks. Those states can be sampled efficiently in order to estimate observables or other quantities. Stochastic optimisation of the energy or a time-evolution are implemnented on top of those samplers.
Netket tries to follow the functional programming paradigm, and is built around jax. While it is possible to run the examples without knowledge of jax, we strongly reccomend getting familiar with it if you wish to extend netket.
This documentation is divided into several modules, each explaining in-depth how a sub-module of netket works. You can select a module from the list on the left, or you can read the following example which contains links to all relevant parts of the documentation.
Netket v3 API is centered around flax, a jax library to simplify the definition and
usage of Neural-Networks.
If you want to define more complex custom models, you should read Flax documentation on how to define a Linen module.
However, you can also use
jax.stax or haiku.
Flax supports complex numbers but does not make it overly easy to work with them. As such, netket exports a module, netket.nn which re-exports the functionality in flax.nn, but with the additional support of complex numbers. Also netket.optim is a re-export of flax.optim with few added functionalities.
Lastly, in netket.jax there are a few functions, notably jax.grad and jax.vjp adapted to work with arbitrary real or complex functions, and/or with MPI.
Legacy API support (API before 2021)¶
With the 3.0 official release in the beginning of 2021, we have drastically changed the API of Netket, which are no longer compatible with the old version.
Netket will ship a copy of the old API and functionalities under the legacy submodule. To keep using your old scripts you should change your import at the top from import netket as nk to import netket.legacy as nk.
While you can keep using the legacy module, we will remove it sometime soon with version 3.1, so we strongly advise to update your scripts to the new version. To aid you in updating your code, a lot of deprecation warning will be issued when you use the legacy api suggesting you how to update your code.
While it might be annoying, the new API allows us to have less code to maintain and grants more freedom to the user when defining models, so it will be a huge improvement.
Some documentation of the legacy module can be found in this section Legacy Random Generation, but please be advised that it is no longer-supported and documentation will probably be of poor quality.
For more information on new features and API changes, please consult Whats New.
If you were using the previous version of NetKet, we strongly advise you to read Whats New as it lists several changes that might otherwise pass unnoticed.