From a1086155aedab05ef517a82be416d708fc8a380b Mon Sep 17 00:00:00 2001 From: trtllm-agent Date: Thu, 16 Jul 2026 03:10:30 -0700 Subject: [PATCH] [nvbugs/6463828][fix] use is_comm_session() instead of isinstance(MpiPoolSession) The proxy's post-init worker-PID registration branch guarded on isinstance(self.mpi_session, MpiPoolSession). Two legitimate patterns in the codebase break that check: 1. tests/test_common/session_reuse.py monkey-patches tensorrt_llm.executor.proxy.MpiPoolSession to a factory *function* for session reuse; isinstance(x, ) raises TypeError. 2. Session-reuse hands out a _ReusableSession wrapper that delegates via __getattr__ to a real MpiPoolSession; it is not a subclass. Replace the concrete-type check with the polymorphic MpiSession helper is_comm_session(), which correctly returns False for pool-based sessions (register PIDs) and True for comm-based sessions (skip). Wrappers that delegate to a real MpiPoolSession forward is_comm_session() through __getattr__, so the reuse path works transparently. Signed-off-by: trtllm-agent --- tensorrt_llm/executor/proxy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorrt_llm/executor/proxy.py b/tensorrt_llm/executor/proxy.py index 11451bad5b67..2454162a69ef 100644 --- a/tensorrt_llm/executor/proxy.py +++ b/tensorrt_llm/executor/proxy.py @@ -573,7 +573,9 @@ def mpi_done_callback(future: concurrent.futures.Future): raise RuntimeError( "Executor worker returned error") from ready_signal - if isinstance(self.mpi_session, MpiPoolSession) and len(status) == 3: + # Comm-based sessions bind to externally-owned processes we cannot + # monitor; only register PIDs for pool sessions that spawned them. + if not self.mpi_session.is_comm_session() and len(status) == 3: worker_process_identities: List[WorkerProcessIdentity] = status[2] self._worker_process_monitor.register(worker_process_identities)