What’s New in v3.0¶
In this page we discuss the main differences between old versions of netket and version 3.0.
Hilbert space constructors do not store the lattice graph anymore. As a consequence, the constructor does not accept the graph anymore.
operator.LocalOperatornow default to real-valued matrix elements, except if you construct them with a complex-valued matrix. This is also valid for operators such as
When performing algebric operations
*, -, +on pairs of
operator.LocalOperator, the dtype of the result iscomputed using standard numpy promotion logic.
Doing an operation in-place
+=, -=, *=on a real-valued operator will now fail if the other is complex. While this might seem annoying, it’s usefull to ensure that smaller types such as float32 or complex64 are preserved if the user desires to do so.
AbstractMachinehas been removed. It’s functionality is now split among the model itself, which is defined by the user and
variational.MCStatefor pure states or
variational.MCMixedStatefor mixed states.
The model, in general is composed by two functions, or an object with two functions: an init(rng, sample_val) function, accepting a jax.random.PRNGKey object and an input, returning the parameters and the state of the model for that particular sample shape, and a
apply(params, samples, **kwargs)function, evaluating the model for the given parameters and inputs.
Some models (previously machines) such as the RBM (Restricted Bolzmann Machine) Machine, NDM (Neural Density Matrix) or MPS (Matrix Product State ansatz) are available in Pre-built models.
Machines, now called models, should be written using flax or another jax framework.
Serialization and deserialization functionality has now been moved to variational.MCState, which support the standard Flax interface through MsgPack. See Flax docs for more information
AbstractMachine.init_random_parametersfunctionality has now been absorbed into
netket.variational.VariationalState.init_parameters(), which however has a different syntax.
Samplers now require the hilbert space upon which they sample to be passed in to the constructor.
Also note that several keyword arguments of the samplers have changed, and new one are available.
It’s now possible to change Samplers dtype, which controls the type of the output. By default they use double-precision samples (np.float64). Be wary of type promotion issues with your models.
Samplers no longer take a machine as an argument.
Samplers are now immutable (frozen) dataclasses (defined through flax.struct.dataclass) that only hold the sampling parameters. As a consequence it is no longer possible to change their settings such as n_chains or n_sweeps without creating a new sampler. If you wish to update only one parameter, it is possible to construct the new sampler with the updated value by using the sampler.replace(parameter=new_value) function.
Samplers are no longer stateful objects. Instead, they can construct an immutable state object sampler.init_state, which can be passed to sampling functions such as sampler.sample, which now return also the updated state. However, unless you have particoular use-cases we advise you use the variational state MCState instead.
The SR object now is only a set of options used to compute the SR matrix. The SR matrix, now called quantum_geometric_tensor can be optained by calling MCState.quantum_geometric_tensor(sr). Depending on the settings, this can be a lazy object.
netket.Vmc has been renamed to netkt.VMC
netket.models.RBM replaces the old
RBMmachine, but has real parameters by default.
As we rely on Jax, using
dtype=complex, which are weak types, will sometimes lead to loss of precision because they might be converted to float32. Use
np.complex128instead if you want double precision when defining your models.