Releases: netket/netket
NetKet 3.12 (💫 13 May 2024)
New Features
- Discrete Hilbert spaces now use a special {class}
nk.utils.StaticRange
object to store the local values that label the local degree of freedom. This special object is jax friendly and can be converted to arrays, and allows for easy conversion from the local degrees of freedom to integers that can be used to index into arrays, and back. While those objects are not really used internally yet, in the future they will be used to simplify the implementations of operators and other objects #1732. - Some utilities to time execution of training loop are now provided, that can be used to coarsely see what part of the algorithm is dominating the training cost. To use it, pass
driver.run(..., timeit=True)
to all drivers when running them. - Added several new tensor network ansatze to the
nk.models.tensor_networks
namespace. Those also replace previous tensor network implementations, that were de-facto broken #1745. - Add jax implementation of Bose Hubbard Operator, named {class}
netket.operator.BoseHubbardJax
and split numba implementation in a separate class #1773. - NetKet now automatically sets the visible GPUs when running under MPI with GPUs, by enumerating local GPUs and setting
jax_default_device
according to some local rank. This behaviour should allow users to not have to specifyCUDA_VISIBLE_DEVICES
and local mpi ranks on their scripts. This behaviour is only activated when running using MPI, and not used when using experimental sharding mode. To disable this functionality, setNETKET_MPI_AUTODETECT_LOCAL_GPU=0
#1757. - {class}
netket.experimental.models.Slater2nd
now implements also the generalized hartree fock, as well as the restricted and unrestricted HF of before #1765. - A new variational state computing the sum of multiple slater determinants has been added, named {class}
nk.experimental.models.MultiSlater2nd
. This state has the same options of {class}~netket.experimental.models.Slater2nd
#1765. - Support for
jax>=0.4.27
#1801.
Breaking Changes
- The
out
keyword of Discrete Hilbert indexing methods (all_states
,numbers_to_states
andstates_to_numbers
) deprecated in the last release has been removed completely #1722. - The Homogeneous Hilbert spaces now must store the list of valid local values for the states with a {class}
nk.utils.StaticRange
objects instead of list of floats. The constructors have been updated accordingly. {class}~nk.utils.StaticRange
is a range-like object that is jax-compatible and from now on should be used to index into local hilbert spaces #1732. - The
numbers_to_states
andstates_to_numbers
methods of {class}netket.hilbert.DiscreteHilbert
must now be jax jittable. Custom Hilbert spaces using non-jittable functions have to be adapted by including a {func}jax.pure_callback
in thenumbers_to_states
/states_to_numbers
member functions #1748. - {attr}
~netket.vqs.MCState.chunk_size
must be set to an integer and will error immediately otherwise. This might break some code, but in general should give more informative error messages overall #1798.
Deprecations
- The method {func}
netket.nn.states_to_numbers
is now deprecated. Please use {meth}~DiscreteHilbert.numbers_to_states
directly.
Improvements
- Rewrite the code for generating random states of
netket.hilbert.Fock
andnetket.hilbert.Spin
in Jax and jit theinit
andreset
functions ofnetket.sampler.MetropolisSampler
for better performance and improved compatibility with sharding #1721. - Rewrite
netket.hilbert.index
used byHomogeneousHilbert
(includingSpin
andFock
) so that larger spaces with a sum constraint can be indexed. This can be useful fornetket.sampler.Exactsampler
,netket.vqs.FullSumState
as well as for ED calculations #1720. - Duplicating a
netket.vqs.MCState
now leads to perfectly deterministic, identical samples between two different copies of the sameMCState
even if the sampler is changed. Previously, duplicating anMCState
and changing the sampler on two copies of the same state would lead to some completely random seed being used and therefore different samples to be generated. This change is needed to eventually achieve proper checkpointing of our calculations #1778. - The methods converting Jax Operators to another kind (such as LocalOperators to PauliOperators) will return the Jax version of those operators if available #1781.
- Parallel Tempering samplers {class}
netket.experimental.sampler.MetropolisPt
now accept a distribution (lin
orlog
) for the distribution of the temperatures, or a custom array #1786.
Finalized Deprecations
- Removed module function
netket.sampler.sample_next
that was deprecated in NetKet 3.3 (December 2021) #17XX.
Internal changes
- Initialize the MetropolisSamplerState in a way that avoids recompilation when using sharding #1776.
- Wrap several functions in the samplers and operators with a
shard_map
to avoid unnecessary collective communication when doing batched indexing of sharded arrays #1777. - Callbacks are now Pytree and can be flattened/unflatted and serialized with flax #1666.
Bug Fixes
- Fixed the gradient of variational states w.r.t. complex parameters which was missing a factor of 2. The learning rate needs to be halved to reproduce simulations made with previous versions of NetKet #1785.
- Fixed the bug #1791. where MetropolisHamiltonian with jax operators was leaking tracers and crashing #1792.
- The bug in Parallel Tempering samplers was found and they have now been fixed. In short, usages until now were most likely returning garbage samples, but not anymore! #1769.
Merged PRs
- Remove out argument from HilbertIndex and DiscreteHilbert by @inailuig in #1722
- Fix typos by @jwnys in #1729
- Rewrite random fock and spin in jax by @inailuig in #1721
- Fix HashableArray being a pytree by @PhilipVinc in #1731
- Fix #1735: repr and integer t0 in RKSolverState by @PhilipVinc in #1736
- Move Hilbert spaces to Lazy range objects by @PhilipVinc in #1732
- Add utilities for lexicographic search / sort of matrices by @inailuig in #1739
- Remove some code duplication in tensorhilbert by @PhilipVinc in #1741
- Remove unused sample_fun from MCState by @inailuig in #1746
- Rewrite Hilbert Index by @inailuig in #1720
- Fix #1742, Fix conjugation of fermionic operators to be only conjugation, not conjugate-transposition by @PhilipVinc in #1743
- Make .to_qobj() work on jax operators by @PhilipVinc in #1749
- Reset struct.Pytree property_cached by @inailuig in #1750
- Update optax requirement from <0.2,>=0.1.3 to >=0.1.3,<0.3 by @dependabot in #1751
- Consistency fixes for constraints in hilbert by @PhilipVinc in #1755
- use automatic tqdm selection by @PhilipVinc in #1756
- update support to qutip 5 by @PhilipVinc in #1762
- Some docs improvements by @PhilipVinc in #1761
- Add utilities to profile netket optimisation loop by @PhilipVinc in #1760
- Add MPS/MPDO models with open and periodic boundary conditions by @LionSR in #1745
- Autoset
CUDA_VISIBLE_GPUS
when running with MPI by @PhilipVinc in #1757 - Update to solve jax deprecations by @PhilipVinc in #1766
- Update sphinx requirement from <7.3,>=7.0 to >=7.0,<7.4 by @dependabot in #1772
- Update myst-nb requirement from ~=1.0.0 to >=1.0,<1.2 by @dependabot in #1768
- Fix typo in variational state loading documentation by @Adrien-Kahn in #1775
- Bose Hubbard as a DiscreteJaxOperator by @Z-Denis in #1773
- Allow overriding the function a MCState is sampled from by @inailuig in #1770
- Declare correct sharding in MetropolisSamplerState.init by @PhilipVinc in #1776
- Make variational state samples reproducible in more situations by @PhilipVinc in #1778
- update macos CI by @i...
NetKet 3.11.4
Updates for deprecations in jax 0.4.25
Full Changelog: v3.11.3...v3.11.4
NetKet 3.11.3
Bugfix release addressing the following issues:
- Fixes a bug where the conjugate of a fermionic operator was the conjugate-transpose, and the hermitian transpose
.H
was the identity. This could break code relying on complex-valued fermionic operators #1743. - Fixed a bug when converting jax operators to qutip format #1749.
- Fixed an internal bug of
netket.utils.struct.Pytree
, where the cached properties's cache was not cleared whenreplace
was used to copy and modify the Pytree #1750. - Update upper bound on optax to
optax<0.3
, following the release ofoptax
0.2 #1751. - Support QuTiP 5, released in march 2024 #1762.
Full Changelog: v3.11.2...v3.11.3
NetKet 3.11.2
Bugfix release to solve the following issues:
- Fix error thrown in repr method of error thrown in TDVP integrators.
- Fix repr error of {class}
nk.sampler.rules.MultipleRules
#1729. - Solve an issue with RK Integrators that could not be initialised with integer
t0
initial time ifdt
was a float, as well as a wrongrepr
method leading to uncomprehensible stacktraces #1736. - Fix HashableArray being a pytree: make it just an hashable object #1731.
Full Changelog: v3.11.1...v3.11.2
v3.11.1 (Bugfix release)
NetKet 3.11 (~💘 16 february 2024)
This release supports Python 3.12 through the latest release of Numba, introduces several new jax-compatible operators and adds a new experimental way to distribute calculations among multiple GPUs without using MPI.
We have a few breaking changes as well: deprecations that were issued more than 18 months ago have now been finalized, most notable the dtype
argument to several models and layers, some keywords to GCNN and setting the number of chains of exact samplers.
New Features
- Recurrent neural networks and layers have been added to
nkx.models
andnkx.nn
#1305. - Added experimental support for running NetKet on multiple jax devices (as an alternative to MPI). It is enabled by setting the environment variable/configuration flag
NETKET_EXPERIMENTAL_SHARDING=1
. Parallelization is achieved by distributing the Markov chains / samples equally across all available devices utilizingjax.Array
sharding. On GPU multi-node setups are supported via jax.distribued, whereas on CPU it is limited to a single process but several threads can be used by settingXLA_FLAGS='--xla_force_host_platform_device_count=XX'
#1511. - {class}
netket.experimental.operator.FermionOperator2nd
is a new Jax-compatible implementation of fermionic operators. It can also be constructed starting from a standard fermionic operator by callingoperator.to_jax_operator()
, or used in combination withpyscf
converters#1675,#1684. - {class}
netket.operator.LocalOperatorJax
is a new Jax-compatible implementation of local operators. It can also be constructed starting from a standard operator by callingoperator.to_jax_operator()
#1654. - The logger interface has been formalised and documented in the abstract base class {class}
netket.logging.AbstractLog
#1665. - The {class}
~netket.experimental.sampler.ParticleExchange
sampler and corresponding rule {class}~netket.experimental.sampler.rules.ParticleExchangeRule
has been added, which special cases {class}~netket.sampler.ExchangeSampler
to fermionic spaces in order to avoid proposing moves where the two site exchanged have the same population #1683.
Breaking Changes
- The {class}
netket.models.Jastrow
wave-function now only has {math}N (N-1)
variational parameters, instead of the {math}N^2
redundant ones it had before. Saving and loading format has now changed and won't be compatible with previous versions#1664. - Finalize deprecations of some old methods in
nk.sampler
namespace (see original commit 1f77ad8267e16fe8b2b2641d1d48a0e7ae94832e) - Finalize deprecations of 2D input to DenseSymm layers, which now turn into error and
extra_bias
option of Equivariant Networks/GCNNs (see original commit c61ea542e9d0f3e899d87a7471dea96d4f6b152d) - Finalize deprecations of very old input/properties to Lattices 0f6f520da9cb6afcd2361dd6fd029e7ad6a2693e)
- Finalie the deprecation for
dtype=
attribute of several modules innk.nn
andnk.models
, which has been printing an error since April 2022. You should update usages ofdtype=
toparam_dtype=
#1724
Deprecations
MetropolisSampler.n_sweeps
has been renamed to {attr}~netket.sampler.MetropolisSampler.MetropolisSampler.sweep_size
for clarity. Usingn_sweeps
when constructing the sampler now throws a deprecation warning;sweep_size
should be used instead going forward #1657.- Samplers and metropolis rules defined as {func}
netket.utils.struct.dataclass
are deprecated because the base class is now a {class}netket.utils.struct.Pytree
. The only change needed is to remove the dataclass decorator and define a standard init method #1653. - The
out
keyword of Discrete Hilbert indexing methods (all_states
,numbers_to_states
andstates_to_numbers
) is deprecated and will be removed in the next release. Plan ahead and remove usages to avoid breaking your code 3 months from now #1725!
Internal changes
- A new class {class}
netket.utils.struct.Pytree
, can be used to create Pytrees for which inheritance autoamtically works and for which it is possible to define__init__
. Several structures such as samplers and rules have been transitioned to this new interface instead of old style@struct.dataclass
#1653. - The {class}
~netket.experimental.operator.FermionOperator2nd
and related classes now store the constant diagonal shift as another term instead of a completely special cased scalar value. The same operators now also respect thecutoff
keyword argument more strictly #1686. - Dtypes of the matrix elements of operators are now handled more correctly, and fewer warnings are raised when running NetKet in X32 mode. Moreover, operators like Ising now default to floating point dtype even if the coefficients are integers #1697.
Bug Fixes
- Support multiplication of Discrete Operators by Sparse arrays #1661.
Full list of PRs merged:
What's Changed
- [experimental] Add initial support for jax multi-device and multi-process environments (part 1) by @inailuig in #1645
- Fix #1646 by @PhilipVinc in #1647
- Actually use chunk size in vs.local_estimators by @PhilipVinc in #1650
- throw error in Ising when using non Spin Hilbert space by @PhilipVinc in #1648
- Add RNN by @wdphy16 in #1305
- PauliStrings: hash stable for mask by @PhilipVinc in #1651
- Pv/news by @PhilipVinc in #1652
- Update state.py by @llviteritti in #1658
- [experimental] Add initial support for jax multi-device and multi-process environments (part 2) by @inailuig in #1511
- Fix some doc generation issues in sampler by @PhilipVinc in #1660
- Use
np.testing
for better error messages by @wdphy16 in #1663 - Support matmul between
DiscreteOperator
and sparse array by @wdphy16 in #1661 - Use
autoflush_cost
when flushing parameters inJsonLog
by @wdphy16 in #1662 - Modified Jastrow model using tril_indices by @llviteritti in #1664
- Formalise logger interface, minor fixes by @PhilipVinc in #1665
- enable changing the mode of PauliStrings by @PhilipVinc in #1669
- Make Samplers and rules 'standard' classes, less magical by @PhilipVinc in #1653
- Refactor FermionOperator tests by @PhilipVinc in #1677
- Rename 'MetropolisSampler.n_sweeps' to 'sweep_size' #1657 by @iamoeg in #1680
- FermionOperatorJax by @PhilipVinc in #1675
- Fix 1675 by @inailuig in #1684
- Run distributed tests on CI by @inailuig in #1679
- port local operator to jax by @inailuig in #1654
- Remove constant in fermion operator and include an explicit cutoff by @jwnys in #1686
- Add metropolis exchange rule for fermions by @jwnys in #1683
- makeluigihappy by @PhilipVinc in #1689
- Fix passing
diag_scale
throughQGTAuto
by @wdphy16 in #1692 - Substitute
variables
withparameters
in automatic QGT selector by @alleSini99 in #1693 - Override
to_local_operator
to returnLocalOperatorJax
instead ofLocalOperator
by @alleSini99 in #1694 - Finalize deprecations from > 2 years ago by @PhilipVinc in #1698
- Update flax requirement from <0.8,>=0.7.1 to >=0.7.1,<0.9 by @dependabot in #1700
- Formalize operator dtypes by @wdphy16 in #1697
- Support multiple "batch" dimensions in GCNN layers by @attila-i-szabo in #1699
- Fix tests like
x in ys
wherex
is an array by @wdphy16 in #1701 - remove VMC/TDVP .info method, variational_common.info by @PhilipVinc in #1703
- [PaulistringsJax] Implement cutoff by @inailuig in #1702
- Fix #1705: raise error if
vs.sample(chain_length=X, n_samples=X)
by @PhilipVinc in https://github.com/ne...
NetKet 3.10.2 (bug fixes)
What's Changed
- Fix #1646 by @PhilipVinc in #1647
- Actually use chunk size in vs.local_estimators by @PhilipVinc in #1650
- throw error in Ising when using non Spin Hilbert space by @PhilipVinc in #1648
Full Changelog: v3.10.1...v3.10.2
NetKet 3.10.1
What's Changed
- Fix #1643 : support complex parameters in SRt by @PhilipVinc in #1644
Full Changelog: v3.10...v3.10.1
NetKet 3.10
The highlights of this version are a new experimental driver to optimise networks with millions of parameters using SR, and introduces new utility functions to convert a pyscf molecule to a netket Hamiltonian.
Read below for a more detailed changelog
New Features
- Added new {class}
netket.experimental.driver.VMC_SRt
driver, which leads in identical parameter updates as the standard Stochastic Reconfiguration with diagonal shift regularization. Therefore, it is essentially equivalent to using the standard {class}netket.driver.VMC
with the {class}netket.optimizer.SR
preconditioner. The advantage of this method is that it requires the inversion of a matrix with side number of samples instead of number of parameters, making this formulation particularly useful in typical deep learning scenarios #1623. - Added a new function {func}
netket.experimental.operator.from_pyscf_molecule
to construct the electronic hamiltonian of a given molecule specified through pyscf. This is accompanied by {func}netket.experimental.operator.pyscf.TV_from_pyscf_molecule
to compute the T and V tensors of a pyscf molecule #1602. - Added the operator computing the Rényi2 entanglement entropy on Hilbert spaces with discrete dofs #1591.
- It is now possible to disable netket's double precision default activation and force all calculations to be performed using single precision by setting the environment variable/configuration flag
NETKET_ENABLE_X64=0
, which also setsJAX_ENABLE_X64=0
. When running with this flag, the number of warnings printed by jax is considerably reduced as well #1544. - Added new shortcuts to build the identity operator as {func}
netket.operator.spin.identity
and {func}netket.operator.boson.identity
#1601. - Added new {class}
netket.hilbert.Particle
constructor that only takes as input the number of dimensions of the system #1577. - Added new {class}
netket.experimental.models.Slater2nd
model implementing a Slater ansatz #1622. - Added new {func}
netket.jax.logdet_cmplx
function to compute the complex log-determinant of a batch of matrices #1622.
Breaking changes
- {class}
netket.experimental.hilbert.SpinOrbitalFermions
attributes have been changed: {attr}~netket.experimental.hilbert.SpinOrbitalFermions.n_fermions
now always returns an integer with the total number of fermions in the system (if specified). A new attribute {attr}~netket.experimental.hilbert.SpinOrbitalFermions.n_fermions_per_spin
has been introduced that returns the same tuple of fermion number per spin subsector as before. A few fields are now marked as read-only as modifications where ignored #1622. - The {class}
netket.nn.blocks.SymmExpSum
layer is now normalised by the number of elements in the symmetry group in order to maintain a reasonable normalisation #1624. - The labelling of spin sectors in {func}
netket.experimental.operator.fermion.create
and similar operators has now changed from the eigenvalue of the spin operator ({math}\pm 1/2
and so on) to the eigenvalue of the Pauli matrices ({math}\pm 1
and so on) #1637. - The connected elements and expectation values of all non-simmetric fermionic operators is now changed in order to be correct #1640.
Improvements
- Considerably reduced the memory consumption of {class}
~netket.operator.LocalOperator
, especially in the case of large local hilbert spaces. Also leveraged sparsity in the terms to speed up compilation (_setup
) in the same cases #1558. - {class}
netket.nn.blocks.SymmExpSum
now works with inputs of arbitrary dimensions, while previously it errored for all inputs that were not 2D #1616 - Stop using
FrozenDict
fromflax
and instead return standard dictionaries for the variational parameters from the variational state. This makes it much easier to edit parameters #1547. - Vastly improved, finally readable documentation of all Flax modules and neural network architectures #1641.
Bug Fixes
- Fixed minor bug where {class}
netket.operator.LocalOperator
could not be built withnp.matrix
object obtained by converting scipy sparse matrices to dense #1597. - Raise correct error instead of unintelligible one when multiplying {class}
netket.experimental.operator.FermionOperator2nd
with other operators #1599. - Do not rescale the output of {func}
netket.jax.jacobian
by the square root of number of samples. Previously, when specifyingcenter=True
we were incorrectly rescaling the output #1614. - Fix bug in {class}
netket.operator.PauliStrings
that caused the dtype to get out of sync with the dtype of the internal arrays, causing errors when manipulating them symbolically #1619. - Fix bug that prevented the use of {class}
netket.operator.DiscreteJaxOperator
as observables with all drivers #1625. - Fermionic operator
get_conn
method was returning values as if the operator was transposed, and has now been fixed. This will break the expectation value of non-simmetric fermionic operators, but hopefully nobody was looking into them #1640.
NetKet 3.9.2 (bug fix)
What's Changed
- Use dynamic ncol in tqdm by @PhilipVinc in #1542
- Ensure localoperator keeps single precision with */-+ by @PhilipVinc in #1545
- fix #1550 by @PhilipVinc in #1551
Full Changelog: v3.9.1...v3.9.2