Skip to content

Simplify batching logic and improve python driver for vmc

Vicentini Filippo requested to merge max_batch into v2.1

Created by: gcarleo

  1. This PR addresses #300 (closed) changing batch_size to n_chains and allowing samplers to further accept an (actual) batch_size argument that however does not change the number of chains, but only how the calls are distributed. This fixes #300 (closed) while giving more freedom in the choice of the batch size, independently on the number of chains.

  2. Python 2 machine are also removed from tests, as per #297 (closed).

  3. OpenMP is also deactivated by default, since in my experience it gives more trouble than benefits (especially on Mac), and it is actually faster in most cases to just use the purely serial version without the calls to OpenMP.

  4. The Python driver for vmc (netket.Vmc) has been put on par with the C++ driver. The previous version was slower, because the GenerateSamples written in C++ was (amazingly) slow. The reasons are not entirely clear to me, but most likely it was because of some implicit copies done by pybind11. The amazing thing is that the pure python version of GenerateSamples provided in this PR is (basically) as fast as the pure C++ version, thus there is no need to carry along the C++ version.

  5. A first step towards simplifying batched calls to LocalValues has been done. This is still not optimal, in the sense that batching in principle can happen on irregular sizes (as noticed by @twesterhout). However, the version in this PR is much more maintainable and there is no measurable slowing down with respect to the previous version. In the future, we will address the issue of providing batched versions of LogValDiff and similar.

  6. There is now a legacy class (netket.variational.Vmc) that is complaint with the legacy version and just calls internally the new netket.Vmc driver. This legacy class also has a method run identical to the old interface, producing json outputs compatibile with the legacy json output files.

  7. The C++ VMC driver and many other unnecessary classes have been completely removed, addressing part of issue #299 (closed).

Merge request reports