Skip to main content

Classes

DistributedRunner

A class to launch and manage distributed workers.

Constructor Parameters

Class Variables

Methods

close_zmq_socket

Closes the ZeroMQ socket.Returns: NoneType

ensure_alive

Ensures that the distributed worker processes are alive. If the processes are not alive, it raises an error.Returns: NoneType

gather_errors

Gathers errors from the distributed worker processes. This method should be called to collect any errors that occurred during execution.Returns: list[Exception]

get_zmq_socket

Returns a ZeroMQ socket of the specified type.Returns: A ZeroMQ socket.

invoke

Invokes the distributed worker with the given payload.Returns: Any

is_alive

Check if the distributed worker processes are alive.Returns: bool

keepalive

Sends the keepalive payload to the worker.Returns: NoneType

maybe_cancel_keepalive

Cancels the keepalive timer if it is set.Returns: NoneType

maybe_reset_keepalive

Resets the keepalive timer if it is set.Returns: NoneType

maybe_start_keepalive

Starts the keepalive timer if it is set.Returns: NoneType

run

The main function to run the distributed worker. This function is called by each worker process spawned by torch.multiprocessing.spawn. This method must be synchronous.Returns: NoneType

start

Starts the distributed worker processes.Returns: NoneType

stop

Stops the distributed worker processes.Returns: NoneType

stream

Streams the result from the distributed worker.Returns: AsyncIterator[Any]

terminate

Terminates the distributed worker processes. This method should be called to clean up the worker processes.Returns: NoneType

DistributedWorker

A base class for distributed workers.

Constructor Parameters

Class Variables

Properties

Methods

add_streaming_error

Add an error to the queue.Returns: NoneType

add_streaming_result

Add a streaming result to the queue.Returns: NoneType

initialize

Initialize the worker.Returns: NoneType

rank_print

Print a message with the rank of the current worker.Returns: NoneType

run_in_worker

Run a function in the worker.Returns: Future[Any]

setup

Override this method to set up the worker. This method is called once per worker.Returns: NoneType

shutdown

Shutdown the event loop.Returns: NoneType

submit

Submit a coroutine to the event loop.Returns: Future[Any]

teardown

Override this method to tear down the worker. This method is called once per worker.Returns: NoneType