Skip to content

Add a seed for integrator step function to reproduce results #286

@thomasloux

Description

@thomasloux

Currently, one can make an integrator init function reproducible by providing a seed: it will used for initial momenta of the system. Yet, for stochastic integrator like Langevin, it would also be useful to provide a seed.
This would also be useful to check that NPT and NVT Langevin keep the same behaviour overtime, by harcoding the some property values at the end of a simulation in tests.

Technically, it would just require to add an optional argument for a torch.Generator. It would be defined before the start of the simulation and provided in step_function each time.

Potentially, we could discuss the possibility to also be able to reproduce single system simulated in a batch context.
Example:

  • I simulate 2 systems
  • For some reason, I want to reproduce any of the two systems
  • If I want to reproduce exactly the same trajectory, I need to simulate again both systems.

This would imply changing:

  • Generation of initial momenta: currently if I simulate a batch of 2 exact systems with Nosé Hoover, I get 2 different trajectories because the initial momenta is different. In this case, it makes sense, but it would not be practical to get the initial momenta of the second system, even knowing the seed.
  • Generation of noise in step function: currently only needed for Langevin.

For the second step, it not as clear to know how to modify it in clear way for a user. The naive way to do that would be to have a generator per system, which is cumbersome if you explicitly need to provide the list of generator each time you run the step function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions