diff --git a/tensorrt_llm/llmapi/rlhf_utils.py b/tensorrt_llm/llmapi/rlhf_utils.py index 47135c765678..958529827025 100644 --- a/tensorrt_llm/llmapi/rlhf_utils.py +++ b/tensorrt_llm/llmapi/rlhf_utils.py @@ -124,6 +124,11 @@ def update_weights(self, ipc_handles: Optional[dict] = None): self.engine.model_engine.model, weights, allow_partial_loading=True ) del weights + # ipc_collect only reclaims mappings whose Python refs are + # already gone; force GC so cudaIpcOpenMemHandle storages are + # released before the sweep, or the IPC handle table saturates + # across repeated RPCs. + gc.collect() torch.cuda.ipc_collect() else: logger.info("Finalize update weights")