File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545
4646_inited = False
4747
48+ _INDUCTOR_QUIESCE_POOL_ENV = "TORCHINDUCTOR_QUIESCE_ASYNC_COMPILE_POOL"
4849_UNIFIED_CACHE_ROOT_ENV = "TRTLLM_CACHE_DIR"
4950_TRTLLM_DG_CACHE_ENV = "TRTLLM_DG_CACHE_DIR"
5051_TRTLLM_DG_DUMP_CUBIN_ENV = "TRTLLM_DG_JIT_DUMP_CUBIN"
@@ -94,6 +95,14 @@ def _set_numexpr_thread_default() -> None:
9495 os .environ .setdefault ("NUMEXPR_NUM_THREADS" , "1" )
9596
9697
98+ def _keep_inductor_compile_pool_alive () -> None :
99+ # Inductor shuts down its async-compile worker pool after a short idle
100+ # period. A compile submitted while that shutdown is in flight can wait
101+ # forever, and a rank stuck there stalls every collective of its group
102+ # (e.g. a torch.compile'd helper recompiling inside a TP forward).
103+ os .environ .setdefault (_INDUCTOR_QUIESCE_POOL_ENV , "0" )
104+
105+
97106def _add_trt_llm_dll_directory ():
98107 on_windows = platform .system () == "Windows"
99108 if on_windows :
@@ -162,6 +171,7 @@ def _setup_vendored_triton_kernels():
162171def _prepare_environment () -> None :
163172 """Phase 1: environment and library preparation, before the Torch import."""
164173 _set_numexpr_thread_default ()
174+ _keep_inductor_compile_pool_alive ()
165175 _setup_unified_cache ()
166176 _add_trt_llm_dll_directory ()
167177 _preload_python_lib ()
Original file line number Diff line number Diff line change @@ -129,6 +129,33 @@ def test_prepare_environment_configures_cache_first(monkeypatch: pytest.MonkeyPa
129129 assert calls == ["cache" , "dll" , "python" , "triton" ]
130130
131131
132+ def test_prepare_environment_keeps_inductor_compile_pool_alive (
133+ monkeypatch : pytest .MonkeyPatch ,
134+ ) -> None :
135+ monkeypatch .delenv (_bootstrap ._INDUCTOR_QUIESCE_POOL_ENV , raising = False )
136+ for name in (
137+ "_setup_unified_cache" ,
138+ "_add_trt_llm_dll_directory" ,
139+ "_preload_python_lib" ,
140+ "_setup_vendored_triton_kernels" ,
141+ ):
142+ monkeypatch .setattr (_bootstrap , name , lambda : None )
143+
144+ _bootstrap ._prepare_environment ()
145+
146+ assert os .environ [_bootstrap ._INDUCTOR_QUIESCE_POOL_ENV ] == "0"
147+
148+
149+ def test_explicit_inductor_compile_pool_quiesce_setting_takes_precedence (
150+ monkeypatch : pytest .MonkeyPatch ,
151+ ) -> None :
152+ monkeypatch .setenv (_bootstrap ._INDUCTOR_QUIESCE_POOL_ENV , "1" )
153+
154+ _bootstrap ._keep_inductor_compile_pool_alive ()
155+
156+ assert os .environ [_bootstrap ._INDUCTOR_QUIESCE_POOL_ENV ] == "1"
157+
158+
132159def test_mpi_pool_environment_forwards_unified_cache_variables (
133160 monkeypatch : pytest .MonkeyPatch ,
134161) -> None :
You can’t perform that action at this time.
0 commit comments