Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only stream output on tp rank 0 #2124

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions python/sglang/srt/managers/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def __init__(
)
else:
self.recv_from_tokenizer = None
self.send_to_tokenizer = SimpleNamespace(send_pyobj=lambda x: None)
self.send_to_detokenizer = SimpleNamespace(send_pyobj=lambda x: None)
self.send_to_tokenizer = SimpleNamespace(send_pyobj=lambda _: None)
self.send_to_detokenizer = SimpleNamespace(send_pyobj=lambda _: None)

# Init tokenizer
self.model_config = ModelConfig(
Expand Down Expand Up @@ -1030,7 +1030,8 @@ def process_batch_result_prefill(self, batch: ScheduleBatch, result):
else:
self.tree_cache.cache_unfinished_req(req)

self.stream_output(batch.reqs)
if self.tp_rank == 0:
self.stream_output(batch.reqs)

def process_batch_result_decode(self, batch: ScheduleBatch, result):
logits_output, next_token_ids, bid = result
Expand Down Expand Up @@ -1081,7 +1082,8 @@ def process_batch_result_decode(self, batch: ScheduleBatch, result):
torch.cuda.current_stream().synchronize()
batch.next_batch_sampling_info.sampling_info_done.set()

self.stream_output(batch.reqs)
if self.tp_rank == 0:
self.stream_output(batch.reqs)

self.token_to_kv_pool.free_group_end()

Expand Down
2 changes: 1 addition & 1 deletion python/sglang/srt/model_executor/model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def init_torch_distributed(self):
if self.device == "cuda":
torch.cuda.set_device(self.gpu_id)
backend = "nccl"
# ToDO(liangan1):Just use gloo to bypass the initilization fail
# TODO(liangan1): Just use gloo to bypass the initilization fail
# Need to use xccl for xpu backend in the future
elif self.device == "xpu":
torch.xpu.set_device(self.gpu_id)
Expand Down
Loading