rllib/evaluation/worker_set.py
def sync_weights(
        self,
        policies: Optional[List[PolicyID]] = None,
        from_worker: Optional[RolloutWorker] = None,
        global_vars: Optional[Dict[str, TensorType]] = None,
    ) -> None:
        """Syncs model weights from the local worker to all remote workers.

        Args:
            policies: Optional list of PolicyIDs to sync weights for.
                If None (default), sync weights to/from all policies.
            from_worker: Optional RolloutWorker instance to sync from.
                If None (default), sync from this WorkerSet's local worker.
        """
        if self.local_worker() is None and from_worker is None:
            raise TypeError(
                "No `local_worker` in WorkerSet, must provide `from_worker` "
                "arg in `sync_weights()`!"
            )

        # Only sync if we have remote workers or `from_worker` is provided.
        if self.remote_workers() or from_worker is not None:
            weights = (from_worker or self.local_worker()).get_weights(policies)
            # Put weights only once into object store and use same object
            # ref to synch to all workers.
            weights_ref = ray.put(weights)
            # Sync to all remote workers in this WorkerSet.
            for to_worker in self.remote_workers():
                to_worker.set_weights.remote(weights_ref, global_vars=global_vars)

            # If `from_worker` is provided, also sync to this WorkerSet's
            # local worker.
            if from_worker is not None and self.local_worker() is not None:
                self.local_worker().set_weights(weights, global_vars=global_vars)
            # If `global_vars` is provided and local worker exists  -> Update its
            # global_vars.
            elif self.local_worker() is not None and global_vars is not None:
                self.local_worker().set_global_vars(global_vars)
Syncs model weights from the local worker to all remote workers.

        Args:
            policies: Optional list of PolicyIDs to sync weights for.
                If None (default), sync weights to/from all policies.
            from_worker: Optional RolloutWorker instance to sync from.
                If None (default), sync from this WorkerSet's local worker.
        
Syncs model weights from the local worker to all remote workers.
Syncs model weights from the local worker to all remote workers .
def sync_weights(
        self,
        policies: Optional[List[PolicyID]] = None,
        from_worker: Optional[RolloutWorker] = None,
        global_vars: Optional[Dict[str, TensorType]] = None,
    ) -> None:
        if self.local_worker() is None and from_worker is None:
            raise TypeError(
                "No `local_worker` in WorkerSet, must provide `from_worker` "
                "arg in `sync_weights()`!"
            )
        if self.remote_workers() or from_worker is not None:
            weights = (from_worker or self.local_worker()).get_weights(policies)
            weights_ref = ray.put(weights)
            for to_worker in self.remote_workers():
                to_worker.set_weights.remote(weights_ref, global_vars=global_vars)
            if from_worker is not None and self.local_worker() is not None:
                self.local_worker().set_weights(weights, global_vars=global_vars)
            elif self.local_worker() is not None and global_vars is not None:
                self.local_worker().set_global_vars(global_vars)
def sync_weights ( self , policies : Optional [ List [ PolicyID ] ] = None , from_worker : Optional [ RolloutWorker ] = None , global_vars : Optional [ Dict [ str , TensorType ] ] = None , ) -> None : if self . local_worker ( ) is None and from_worker is None : raise TypeError ( "No `local_worker` in WorkerSet, must provide `from_worker` " "arg in `sync_weights()`!" ) if self . remote_workers ( ) or from_worker is not None : weights = ( from_worker or self . local_worker ( ) ) . get_weights ( policies ) weights_ref = ray . put ( weights ) for to_worker in self . remote_workers ( ) : to_worker . set_weights . remote ( weights_ref , global_vars = global_vars ) if from_worker is not None and self . local_worker ( ) is not None : self . local_worker ( ) . set_weights ( weights , global_vars = global_vars ) elif self . local_worker ( ) is not None and global_vars is not None : self . local_worker ( ) . set_global_vars ( global_vars )
Syncs model weights from the local worker to all remote workers.
Syncs model weights from the local worker to all remote workers .
"""Syncs model weights from the local worker to all remote workers.

        Args:
            policies: Optional list of PolicyIDs to sync weights for.
                If None (default), sync weights to/from all policies.
            from_worker: Optional RolloutWorker instance to sync from.
                If None (default), sync from this WorkerSet's local worker.
        """ # Only sync if we have remote workers or `from_worker` is provided. # Put weights only once into object store and use same object # ref to synch to all workers. # Sync to all remote workers in this WorkerSet. # If `from_worker` is provided, also sync to this WorkerSet's # local worker. # If `global_vars` is provided and local worker exists  -> Update its # global_vars.
self
policies
Optional[List[PolicyID]]
Optional list of PolicyIDs to sync weights for.
If None (default), sync weights to/from all policies.
Optional list of PolicyIDs to sync weights for . If None ( default ) sync weights to / from all policies .
from_worker
Optional[RolloutWorker]
Optional RolloutWorker instance to sync from.
If None (default), sync from this WorkerSet's local worker.
Optional RolloutWorker instance to sync from . If None ( default ) sync from this WorkerSet ' s local worker .
global_vars
Optional[Dict[str, TensorType]]