ray.rllib.evaluation.worker_set.WorkerSet#

class ray.rllib.evaluation.worker_set.WorkerSet(*, env_creator: Callable[[EnvContext], Any | gymnasium.Env | None] | None = None, validate_env: Callable[[Any | gymnasium.Env], None] | None = None, default_policy_class: Type[Policy] | None = None, config: AlgorithmConfig | None = None, num_workers: int = 0, local_worker: bool = True, logdir: str | None = None, _setup: bool = True)[source]#

Set of EnvRunners with n @ray.remote workers and zero or one local worker.

Where: n >= 0.

Methods

__init__

Initializes a WorkerSet instance.

add_policy

Adds a policy to this WorkerSet's workers or a specific list of workers.

add_workers

Creates and adds a number of remote workers to this worker set.

fetch_ready_async_reqs

Get esults from outstanding asynchronous requests that are ready.

foreach_env

Calls func with all workers' sub-environments as args.

foreach_env_with_context

Calls func with all workers' sub-environments and env_ctx as args.

foreach_policy

Calls func with each worker's (policy, PolicyID) tuple.

foreach_policy_to_train

Apply func to all workers' Policies iff in policies_to_train.

foreach_worker

Calls the given function with each EnvRunner as its argument.

foreach_worker_async

Calls the given function asynchronously with each worker as the argument.

foreach_worker_with_id

Calls the given function with each EnvRunner and its ID as its arguments.

healthy_worker_ids

Returns the list of remote worker IDs.

is_policy_to_train

Whether given PolicyID (optionally inside some batch) is trainable.

local_worker

Returns the local rollout worker.

num_healthy_remote_workers

Returns the number of healthy remote workers.

num_healthy_workers

Returns the number of all healthy workers, including the local worker.

num_in_flight_async_reqs

Returns the number of in-flight async requests.

num_remote_worker_restarts

Total number of times managed remote workers have been restarted.

num_remote_workers

Returns the number of remote rollout workers.

probe_unhealthy_workers

Checks for unhealthy workers and tries restoring their states.

reset

Hard overrides the remote workers in this set with the given one.

stop

Calls stop on all rollout workers (including the local one).

sync_env_runner_states

Synchronizes the connectors of this WorkerSet's EnvRunners.

sync_weights

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