MPTransport¶
- class torchrl.weight_update.MPTransport(pipe_connection, timeout: float = 10.0)[source]¶
Multiprocessing transport using pipes.
- Parameters:
pipe_connection (mp.Pipe) – The pipe connection to use for communication.
timeout (float) – The timeout for waiting for acknowledgment. Default is 10 seconds.
- receive_weights(timeout: float = 1.0) tuple[str, Any] | None[source]¶
Receive weights from the pipe (used in worker process).
This method only handles weight update messages. Other messages (like “close”, “continue”, etc.) are ignored and should be handled by the main worker loop.
- Returns:
Tuple of (model_id, weights) if weights were received, None if no data available or if a non-weight message was received.
- send_weights(model_id: str, weights: Any) None[source]¶
Send weights through the pipe.
Sends weights and waits for acknowledgment to ensure delivery.