From 158d7e1c05cffb24fdf01bbe8f3f2fde29888a99 Mon Sep 17 00:00:00 2001 From: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> Date: Thu, 16 Jul 2026 05:16:40 -0700 Subject: [PATCH] [nvbugs/6461799][fix] Resolve MpiPoolSession from source module for isinstance check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test-side session-reuse plugin (tests/test_common/session_reuse.py) monkey-patches the module-level MpiPoolSession attribute in tensorrt_llm.executor.proxy with a factory function to intercept pool construction. This is fine for the constructor call site, but breaks the isinstance(self.mpi_session, MpiPoolSession) guard added by e05790a1ca (nvbugs/6435642) — isinstance() rejects a function as its second argument with TypeError. Import MpiPoolSession from tensorrt_llm.llmapi.mpi_session at the use site so the class reference is resolved from the source module and is immune to attribute-level patching on the proxy module. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> --- tensorrt_llm/executor/proxy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorrt_llm/executor/proxy.py b/tensorrt_llm/executor/proxy.py index 11451bad5b67..27c8007de617 100644 --- a/tensorrt_llm/executor/proxy.py +++ b/tensorrt_llm/executor/proxy.py @@ -573,6 +573,9 @@ def mpi_done_callback(future: concurrent.futures.Future): raise RuntimeError( "Executor worker returned error") from ready_signal + # Import from the source module: test infrastructure (session_reuse.py) + # monkey-patches this module's MpiPoolSession attribute to a factory. + from ..llmapi.mpi_session import MpiPoolSession if isinstance(self.mpi_session, MpiPoolSession) and len(status) == 3: worker_process_identities: List[WorkerProcessIdentity] = status[2] self._worker_process_monitor.register(worker_process_identities)