From 7655db6c1ea873870d0728a0a8209dba80f6fc89 Mon Sep 17 00:00:00 2001 From: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> Date: Thu, 16 Jul 2026 02:49:09 -0700 Subject: [PATCH] [nvbugs/6463831][fix] use is_comm_session predicate to survive symbol rebind The session-reuse test infrastructure (tests/test_common/session_reuse.py) monkey-patches the module-level MpiPoolSession symbol in tensorrt_llm.executor.proxy with a factory function to enable pool reuse across LLM instances. That breaks isinstance(self.mpi_session, MpiPoolSession) in _start_executor_workers with: TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union Switch to the polymorphic MpiSession.is_comm_session() predicate. It is a method call on the instance, so it does not depend on the module-level MpiPoolSession symbol staying bound to the class, and it composes with the _ReusableSession wrapper's __getattr__ delegation. Negating it selects the same set of local-pool sessions (MpiPoolSession and subclasses) as the original isinstance check. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> --- tensorrt_llm/executor/proxy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorrt_llm/executor/proxy.py b/tensorrt_llm/executor/proxy.py index 11451bad5b67..46c380ed74fe 100644 --- a/tensorrt_llm/executor/proxy.py +++ b/tensorrt_llm/executor/proxy.py @@ -573,7 +573,10 @@ 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: + # Use the polymorphic predicate: the module-level ``MpiPoolSession`` + # symbol may be rebound to a factory at runtime by test infrastructure + # (tests/test_common/session_reuse.py), breaking ``isinstance``. + 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)