parallelizer

Functions for operating MALA in parallel.

barrier()[source]

General interface for a barrier.

finalize()[source]

Properly shut down lingering Kokkos/GPU instances.

get_comm()[source]

Return the MPI communicator, if MPI is being used.

Returns:

comm – An MPI communicator.

Return type:

MPI.COMM_WORLD

get_local_rank()[source]

Get the local rank of the process.

This is the rank WITHIN a node. Useful when multiple GPUs are used on one node. Always returns 0 in the serial case.

Originally obtained from: https://github.com/hiwonjoon/ICML2019-TREX/blob/master/mujoco/learner/baselines/baselines/common/mpi_util.py

License: MIT License

Copyright (c) 2019 Daniel Brown and Wonjoon Goo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Returns:

local_rank – The local rank of the current thread.

Return type:

int

get_rank()[source]

Get the rank of the current thread.

Always returns 0 in the serial case.

Returns:

rank – The rank of the current thread.

Return type:

int

get_size()[source]

Get the number of ranks.

Returns:

size – The number of ranks.

Return type:

int

parallel_warn(warning, min_verbosity=0, category=<class 'UserWarning'>)[source]

Interface for warnings in parallel runs. Can be used like warnings.warn.

Linked to the verbosity option in parameters. By default, all messages are treated as high level messages and will be printed.

Parameters:
  • warning (str) – Warning to be printed.

  • min_verbosity (int) – Minimum number of verbosity for this output to still be printed.

  • category (class) – Category of the warning to be thrown.

printout(*values, sep=' ', min_verbosity=0)[source]

Interface to built-in “print” for parallel runs. Can be used like print.

Linked to the verbosity option in parameters. By default, all messages are treated as high level messages and will be printed.

Parameters:
  • values (object) – Values to be printed.

  • sep (string) – Separator between printed values.

  • min_verbosity (int) – Minimum number of verbosity for this output to still be printed.

set_current_verbosity(new_value)[source]

Set the verbosity used for the printout statements.

Should only be called by the parameters file, not by the user directly!

Parameters:

new_value (int) – New verbosity.

set_ddp_status(new_value)[source]

Set the ddp status.

By setting the ddp status via this function it can be ensured that printing works in parallel. The Parameters class does that for the user.

Parameters:

new_value (bool) – Value the ddp status has.

set_lammps_instance(new_instance)[source]

Set a new LAMMPS instance to be targeted during the finalize call.

This currently has to be done in order for Kokkos to not through an error when operating in GPU descriptor calculation mode.

Parameters:

new_instance (lammps.LAMMPS) – A LAMMPS instance currently in memory to be properly finalized at the end of the script.

set_mpi_status(new_value)[source]

Set the MPI status.

By setting the MPI status via this function it can be ensured that printing works in parallel. The Parameters class does that for the user.

Parameters:

new_value (bool) – Value the MPI status has.