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
18 changes: 7 additions & 11 deletions python/sglang/srt/layers/moe/kt_ep_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,7 @@ def _create_cpu_buffers(self):
else:
self.shm_unique_id = None
if dist.is_initialized():
unique_id_list = [self.shm_unique_id]
dist.broadcast_object_list(
unique_id_list, src=0, group=get_tp_group().cpu_group
)
self.shm_unique_id = unique_id_list[0]
self.shm_unique_id = get_tp_group().broadcast_object(self.shm_unique_id)

for name in self.weight_names:
gpu_tensor = getattr(self.gpu_layer, name)
Expand Down Expand Up @@ -499,14 +495,14 @@ def _create_cpu_buffers(self):
self.cpu_buffers[name] = cpu_buffer

if dist.is_initialized():
dist.barrier(group=get_tp_group().device_group)
get_tp_group().barrier()

self.all_rank_buffer_ptrs = self._collect_all_rank_buffer_pointers()

# Unlink shared memory after all ranks have collected pointers.
# The memory remains accessible as long as we hold references via mmap.
if dist.is_initialized():
dist.barrier(group=get_tp_group().device_group)
get_tp_group().barrier()
for shm in self.shm_handles.values():
shm.unlink()

Expand Down Expand Up @@ -706,7 +702,7 @@ def submit_write_expert(expert_id):

# Barrier to ensure all ranks see the written data
if dist.is_initialized():
dist.barrier(group=get_tp_group().device_group)
get_tp_group().barrier()

with torch.cuda.stream(copy_stream):
slot = e % 2 # Double buffering
Expand Down Expand Up @@ -874,7 +870,7 @@ def submit_write_expert(expert_id, slot):

# Barrier to ensure all ranks see the written data
if dist.is_initialized():
dist.barrier(group=get_tp_group().device_group)
get_tp_group().barrier()

with torch.cuda.stream(copy_stream):
for _, cpu_buf, gpu_t in weight_infos:
Expand Down Expand Up @@ -1046,7 +1042,7 @@ def submit_write_expert(expert_id, slot):

# Barrier to ensure all ranks see the written data
if dist.is_initialized():
dist.barrier(group=get_tp_group().device_group)
get_tp_group().barrier()

with torch.cuda.stream(copy_stream):
for _, cpu_buf, gpu_t in weight_infos:
Expand Down Expand Up @@ -1198,7 +1194,7 @@ def submit_write_expert(expert_id, slot):

# Barrier to ensure all ranks see the written data
if dist.is_initialized():
dist.barrier(group=get_tp_group().device_group)
get_tp_group().barrier()

with torch.cuda.stream(copy_stream):
for _, cpu_buf, gpu_t in weight_infos:
Expand Down
Loading