Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ def update_weights(self) -> None:
for hf_named_tensors in self._hf_weight_iterator.get_hf_weight_chunks(megatron_local_weights):
refs, long_lived_tensors = self._send_hf_params(hf_named_tensors)
ray.get(refs)
del long_lived_tensors
# Free GPU tensors so the caching allocator can reuse the blocks,
# then release CUDA IPC cache entries whose consumers (sglang engines)
# have already closed their IPC handles.
del long_lived_tensors, hf_named_tensors
torch.cuda.ipc_collect()

dist.barrier(group=get_gloo_group())
# After the barrier all engines have returned, so every rank's last-chunk
# IPC handles are now released by the consumers. Clean them up.
torch.cuda.ipc_collect()

# int4/fp4 post_process
if rank == 0:
Expand Down Expand Up @@ -212,7 +219,6 @@ def _send_to_colocated_engine(
if ipc_gather_group is None:
return [], None

# TODO improve
long_live_tensors = []

if getattr(FlattenedTensorBucket, "supports_multi_dtypes", False):
Expand Down