Skip to content

Commit e8fb516

Browse files
committed
Update
[ghstack-poisoned]
1 parent 4029297 commit e8fb516

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

torchrl/collectors/_constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def cudagraph_mark_step_begin():
2828
"INSTANTIATE_TIMEOUT",
2929
"_MIN_TIMEOUT",
3030
"_MAX_IDLE_COUNT",
31+
"WEIGHT_SYNC_TIMEOUT",
3132
"DEFAULT_EXPLORATION_TYPE",
3233
"_is_osx",
3334
"_Interruptor",
@@ -38,6 +39,9 @@ def cudagraph_mark_step_begin():
3839
_TIMEOUT = 1.0
3940
INSTANTIATE_TIMEOUT = 20
4041
_MIN_TIMEOUT = 1e-3 # should be several orders of magnitude inferior wrt time spent collecting a trajectory
42+
# Timeout for weight synchronization during collector init.
43+
# Increase this when using many collectors across different CUDA devices.
44+
WEIGHT_SYNC_TIMEOUT = float(os.environ.get("TORCHRL_WEIGHT_SYNC_TIMEOUT", 120.0))
4145
# MAX_IDLE_COUNT is the maximum number of times a Dataloader worker can timeout with his queue.
4246
_MAX_IDLE_COUNT = int(os.environ.get("MAX_IDLE_COUNT", torch.iinfo(torch.int64).max))
4347

torchrl/collectors/collectors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
cudagraph_mark_step_begin,
1919
DEFAULT_EXPLORATION_TYPE,
2020
INSTANTIATE_TIMEOUT,
21+
WEIGHT_SYNC_TIMEOUT,
2122
)
2223

2324
from torchrl.collectors._multi_async import MultiAsyncCollector, MultiaSyncDataCollector
@@ -50,6 +51,7 @@
5051
# Constants
5152
"_TIMEOUT",
5253
"INSTANTIATE_TIMEOUT",
54+
"WEIGHT_SYNC_TIMEOUT",
5355
"_MIN_TIMEOUT",
5456
"_MAX_IDLE_COUNT",
5557
"DEFAULT_EXPLORATION_TYPE",

torchrl/weight_update/_shared.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from torch import multiprocessing as mp, nn
1212

1313
from torchrl._utils import logger as torchrl_logger
14+
from torchrl.collectors._constants import WEIGHT_SYNC_TIMEOUT
1415

1516
from torchrl.weight_update.utils import _resolve_model
1617
from torchrl.weight_update.weight_sync_schemes import (
@@ -97,7 +98,7 @@ def setup_connection_and_weights_on_receiver(
9798
weights: Any = None,
9899
model: Any = None,
99100
strategy: Any = None,
100-
timeout: float = 10.0,
101+
timeout: float = WEIGHT_SYNC_TIMEOUT,
101102
) -> TensorDictBase:
102103
"""Receive shared memory buffer reference from sender via their per-worker queues.
103104

0 commit comments

Comments
 (0)