Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tensorrt_llm/llmapi/rlhf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

del weights isn't the only live reference at this point: the loop above leaves tensor, func, args, list_args, and all_handles bound in the frame, so the last IPC-mapped storage survives this gc.collect()/ipc_collect() pair and is only released when the method returns. If the handle-table pressure is real, drop those too:

Suggested change
gc.collect()
del weights, tensor, list_args, all_handles
gc.collect()

torch.cuda.ipc_collect()
else:
logger.info("Finalize update weights")
Expand Down
Loading