Skip to content

Commit 92dd9b6

Browse files
ocss884lifuhuang
authored andcommitted
fix: fix broadcast_pyobj breaking VerlEngine (sgl-project#5997)
1 parent 50f0123 commit 92dd9b6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

python/sglang/srt/entrypoints/verl_engine.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(
3737
monkey_patch_torch_reductions()
3838
self._device_mesh_cpu = device_mesh_cpu
3939
self._tp_rank = device_mesh_cpu.get_local_rank()
40+
self._rank = device_mesh_cpu.get_rank()
4041
self._tp_size = device_mesh_cpu.size()
4142
tp_size_per_node = self._tp_size // nnodes
4243
node_rank = self._tp_rank // tp_size_per_node
@@ -114,7 +115,7 @@ def generate(
114115
# Most naive implementation, can extract tensor and send via gloo if too slow
115116
[output] = broadcast_pyobj(
116117
data=[output],
117-
rank=self._tp_rank,
118+
rank=self._rank,
118119
dist_group=self._device_mesh_cpu.get_group(),
119120
src=self._device_mesh_cpu.mesh[0].item(),
120121
force_cpu_device=False,
@@ -157,7 +158,7 @@ def update_weights_from_tensor(
157158
)
158159

159160
if self._tp_rank == 0:
160-
self._engine.tokenizer_manager.flush_cache()
161+
self._engine.flush_cache()
161162

162163
def release_memory_occupation(self):
163164
if self._tp_rank == 0:

python/sglang/srt/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,10 @@ def broadcast_pyobj(
897897
src: int = 0,
898898
force_cpu_device: bool = True,
899899
):
900-
"""Broadcast inputs from rank=0 to all other ranks with torch.dist backend."""
900+
"""Broadcast inputs from src rank to all other ranks with torch.dist backend.
901+
The `rank` here refer to the source rank on global process group (regardless
902+
of dist_group argument).
903+
"""
901904
device = torch.device(
902905
"cuda" if torch.cuda.is_available() and not force_cpu_device else "cpu"
903906
)

0 commit comments

Comments
 (0)