File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
3940INSTANTIATE_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
Original file line number Diff line number Diff line change 1818 cudagraph_mark_step_begin ,
1919 DEFAULT_EXPLORATION_TYPE ,
2020 INSTANTIATE_TIMEOUT ,
21+ WEIGHT_SYNC_TIMEOUT ,
2122)
2223
2324from torchrl .collectors ._multi_async import MultiAsyncCollector , MultiaSyncDataCollector
5051 # Constants
5152 "_TIMEOUT" ,
5253 "INSTANTIATE_TIMEOUT" ,
54+ "WEIGHT_SYNC_TIMEOUT" ,
5355 "_MIN_TIMEOUT" ,
5456 "_MAX_IDLE_COUNT" ,
5557 "DEFAULT_EXPLORATION_TYPE" ,
Original file line number Diff line number Diff line change 1111from torch import multiprocessing as mp , nn
1212
1313from torchrl ._utils import logger as torchrl_logger
14+ from torchrl .collectors ._constants import WEIGHT_SYNC_TIMEOUT
1415
1516from torchrl .weight_update .utils import _resolve_model
1617from 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
You can’t perform that action at this time.
0 commit comments