ray.rllib.evaluation.worker_set.WorkerSet.sync_weights#

WorkerSet.sync_weights(policies: Optional[List[str]] = None, from_worker_or_trainer: Optional[Union[ray.rllib.evaluation.rollout_worker.RolloutWorker, ray.rllib.core.learner.learner_group.LearnerGroup]] = None, to_worker_indices: Optional[List[int]] = None, global_vars: Optional[Dict[str, Union[numpy.array, jnp.ndarray, tf.Tensor, torch.Tensor]]] = None, timeout_seconds: Optional[int] = 0) None[source]#

Syncs model weights from the given weight source to all remote workers.

Weight source can be either a (local) rollout worker or a learner_group. It should just implement a get_weights method.

Parameters
  • policies – Optional list of PolicyIDs to sync weights for. If None (default), sync weights to/from all policies.

  • from_worker_or_trainer – Optional (local) RolloutWorker instance or LearnerGroup instance to sync from. If None (default), sync from this WorkerSet’s local worker.

  • to_worker_indices – Optional list of worker indices to sync the weights to. If None (default), sync to all remote workers.

  • global_vars – An optional global vars dict to set this worker to. If None, do not update the global_vars.

  • timeout_seconds – Timeout in seconds to wait for the sync weights calls to complete. Default is 0 (sync-and-forget, do not wait for any sync calls to finish). This significantly improves algorithm performance.