Skip to content

Batched versions of RbmSpin and MetropolisLocal

Vicentini Filippo requested to merge github/fork/twesterhout/master into v2.1

Created by: twesterhout

Breaking changes

  • variational

    • compute_samples returns a MCResult type instead of _VmcResult (netket::vmc::Result in C++). netket::vmc::Result didn't expose any methods or data members to Python and was just completely useless for end users. MCResult exposes all the data obtained during sampling.
    • compute_samples argument names changed: nsamples is now n_samples and ndiscard is replaced by n_discard (as requested here).
    • Number of samples returned from compute_samples may differ from the argument value for samplers with batch sizes greater than 1.
    • expectation and variance functions are removed. A combination of calls to local_values and statistics can be used instead.
    • Interface of gradient function has changed.
    • Interface of local_values function has changed.
    • local_value function is removed. local_values can be used instead.
    • Added statistics function for calculating means, variances, errors, correlation times, etc. of Monte Carlo data.
  • machine

    • order of arguments in init_random_parameters has changed. Moreover, it is no longer necessary to provide a seed. Random number generator will be initialised from /dev/random (or /dev/urandom).
    • Machines now have a state_dict function which returns internal state as a dictionary (similar to torch.nn.Module.state_dict in PyTorch). Currently, only RbmSpinV2 supports it. All other machines throw errors saying that the requested functionality is not implemented.
    • log_val and der_log can now receive either 1D or 2D tensors corresponding to a single visible configuration or a batch of visible configurations.
  • sampler

    • machine_func now works with arrays instead of scalars.
    • acceptance is no longer part of Sampler, but most of the samplers still implement it.
    • visible property is now a 2D tensor and behaves slightly differently.
    • Removed hilbert property. Use .machine.hilbert instead.
  • probably more

Code changes

  • Machines are free to use their own custom type for lookup tables. It is passed around using netket::any (a C++11 port of std::any).
  • AbstractMachine::LogVal is renamed to LogValSingle. LogVal now works with batches of visible configurations. AbstractMachine contains default implementation for LogVal in terms of LogValSingle.
  • AbstractMachine::DerLog is renamed to DerLogSingle. DerLog now works with batches of visible configurations. AbstractMachine contains default implementation for DerLog in terms of DerLogSingle.
  • RbmSpinV2 -- a safer and more efficient version of RbmSpin.
  • Stochastic reconfiguration is now exposed to Python as SR.
  • Samplers now have a BatchSize method.
  • Samplers now have CurrentState function which returns both the current visible configuration and the corresponding logarithm of the wavefunction.
  • etc.

New dependencies

  • Sleef vectorized maths library. Currently used only for implementing faster activation function for RBMs. It also has a DFT component which might be useful if at some point we decide to estimate correlation time using lag-t correlations.
  • linb-any implementation of C++17 std::any for C++11-compatible compilers.

Merge request reports