Skip to content

Commit 027be09

Browse files
committed
[None][test] Restrict SIGKILL disposal to broken pools only
Healthy retires (lifetime cap, stale env snapshot, duplicate cache slot) go back to a graceful background shutdown: those workers are idle and exit cleanly, and abnormal termination of MPI-spawned children can upset the MPI runtime in the parent test process. The SIGKILL path is kept only for pools that failed the health probe, where workers may be wedged in a collective and a graceful shutdown would block forever. Signed-off-by: qgai <qgai@nvidia.com>
1 parent f09acfe commit 027be09

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

tests/test_common/session_reuse.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,23 @@ def max_uses(self) -> int:
259259
return int(os.environ.get("TRTLLM_TEST_REUSE_MAX_USES", "16"))
260260

261261
@staticmethod
262-
def _retire(real):
262+
def _retire(real, broken: bool = False):
263263
"""Dispose of a pool in the background without blocking the test.
264264
265-
Pools are usually retired because they are broken (failed health
266-
probe, stale env, lifetime cap). A graceful ``shutdown()`` on a pool
267-
whose workers are wedged in a collective blocks forever and leaks the
268-
workers' GPU memory into subsequent tests. ``shutdown_abort`` is NOT
269-
an option either: it calls ``MPI_COMM_WORLD.Abort``, which kills the
270-
parent test process along with the workers. Instead SIGKILL the
271-
worker PIDs recorded at spawn (retired pools are discarded, so
272-
nothing needs a graceful stop; the driver reclaims GPU memory on
273-
process death) and then reap the client side.
265+
Healthy retires (lifetime cap, stale env snapshot, duplicate cache
266+
slot) use a graceful ``shutdown()``: the workers are idle and exit
267+
cleanly, and killing MPI-spawned children abnormally can upset the
268+
MPI runtime in the parent process.
269+
270+
``broken=True`` (failed health probe) means the workers may be wedged
271+
in a collective: a graceful shutdown would block forever and leak
272+
their GPU memory into subsequent tests, and ``shutdown_abort`` calls
273+
``MPI_COMM_WORLD.Abort``, which kills the parent test process too.
274+
Instead SIGKILL the worker PIDs recorded at spawn (a discarded pool
275+
needs no graceful stop; the driver reclaims GPU memory on process
276+
death) and then reap the client side.
274277
"""
275-
pids = getattr(real, "_reuse_worker_pids", ())
278+
pids = getattr(real, "_reuse_worker_pids", ()) if broken else ()
276279

277280
def _dispose():
278281
import signal
@@ -371,7 +374,7 @@ def acquire(self, real_cls, n_workers):
371374
f"[session-reuse] cached pool failed reset, rebuilding: {e}",
372375
flush=True,
373376
)
374-
self._retire(real)
377+
self._retire(real, broken=True)
375378
return _ReusableSession(self._spawn_fresh(real_cls, n_workers), self)
376379

377380
def _spawn_fresh(self, real_cls, n_workers):

0 commit comments

Comments
 (0)