From a316e58a1abe6e975f3420c4265898adcd13f205 Mon Sep 17 00:00:00 2001 From: sang Date: Fri, 6 Dec 2024 19:27:06 -0800 Subject: [PATCH 1/2] done --- docs/references/contributor_guide.md | 4 ++++ python/pyproject.toml | 2 +- .../sglang/srt/managers/detokenizer_manager.py | 2 ++ python/sglang/srt/managers/scheduler.py | 16 +++++++++++----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/references/contributor_guide.md b/docs/references/contributor_guide.md index a9b25163d12..550f267ab1a 100644 --- a/docs/references/contributor_guide.md +++ b/docs/references/contributor_guide.md @@ -1,5 +1,9 @@ # Contributor Guide +# Build SGLang + +See [Install SGLang, Method 2: From Source section](../start/install.md). + ## Format Your Code Use these commands to format your code and pass CI linting tests. diff --git a/python/pyproject.toml b/python/pyproject.toml index 1ecfc4fa50a..a68a82b254c 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,7 +13,7 @@ classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: Apache Software License", ] -dependencies = ["requests", "tqdm", "numpy", "IPython"] +dependencies = ["requests", "tqdm", "numpy", "IPython", "setproctitle"] [project.optional-dependencies] runtime_common = ["aiohttp", "decord", "fastapi", diff --git a/python/sglang/srt/managers/detokenizer_manager.py b/python/sglang/srt/managers/detokenizer_manager.py index e74ba5026c1..120e990da2a 100644 --- a/python/sglang/srt/managers/detokenizer_manager.py +++ b/python/sglang/srt/managers/detokenizer_manager.py @@ -20,6 +20,7 @@ from typing import List, Union import psutil +import setproctitle import zmq from sglang.srt.hf_transformers_utils import get_tokenizer @@ -194,6 +195,7 @@ def run_detokenizer_process( server_args: ServerArgs, port_args: PortArgs, ): + setproctitle.setproctitle("sglang::detokenizer") configure_logger(server_args) parent_process = psutil.Process().parent() diff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.py index 41895e067d0..b5894d0ff2c 100644 --- a/python/sglang/srt/managers/scheduler.py +++ b/python/sglang/srt/managers/scheduler.py @@ -25,6 +25,7 @@ from typing import List, Optional import psutil +import setproctitle import torch import zmq @@ -485,12 +486,16 @@ def recv_requests(self): if self.tp_rank == 0 or self.server_args.enable_dp_attention: recv_reqs = [] - while True: - try: - recv_req = self.recv_from_tokenizer.recv_pyobj(zmq.NOBLOCK) - except zmq.ZMQError: - break + if self.last_batch is None: + recv_req = self.recv_from_tokenizer.recv_pyobj() recv_reqs.append(recv_req) + else: + while True: + try: + recv_req = self.recv_from_tokenizer.recv_pyobj(zmq.NOBLOCK) + except zmq.ZMQError: + break + recv_reqs.append(recv_req) else: recv_reqs = None @@ -1424,6 +1429,7 @@ def run_scheduler_process( dp_rank: Optional[int], pipe_writer, ): + setproctitle.setproctitle("sglang::scheduler") # set cpu affinity to this gpu process if get_bool_env_var("SGLANG_SET_CPU_AFFINITY"): set_gpu_proc_affinity(server_args.tp_size, server_args.nnodes, gpu_id) From a0deb49638a71595309df1958d91e652379f8688 Mon Sep 17 00:00:00 2001 From: Lianmin Zheng Date: Sun, 8 Dec 2024 00:59:31 -0800 Subject: [PATCH 2/2] Update python/sglang/srt/managers/scheduler.py --- python/sglang/srt/managers/scheduler.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.py index 562d02bf620..13e8dae2345 100644 --- a/python/sglang/srt/managers/scheduler.py +++ b/python/sglang/srt/managers/scheduler.py @@ -1479,9 +1479,6 @@ def run_scheduler_process( pipe_writer, ): setproctitle.setproctitle("sglang::scheduler") - # set cpu affinity to this gpu process - if get_bool_env_var("SGLANG_SET_CPU_AFFINITY"): - set_gpu_proc_affinity(server_args.tp_size, server_args.nnodes, gpu_id) # [For Router] if env var "SGLANG_DP_RANK" exist, set dp_rank to the value of the env var if dp_rank is None and "SGLANG_DP_RANK" in os.environ: