Simplify server startup output (#20885)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
a02cff7f2b
commit
0949b138af
+1
-6
@@ -224,16 +224,11 @@ work_dirs/
|
|||||||
*.exe
|
*.exe
|
||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
compile_commands.json
|
|
||||||
|
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
# VSCode
|
# VSCode
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
1
|
|
||||||
|
|
||||||
# Autoenv
|
# Autoenv
|
||||||
.env.leave
|
.env.leave
|
||||||
|
|
||||||
@@ -243,6 +238,7 @@ Cargo.lock
|
|||||||
# Generated vision test fixtures (regenerate with: python scripts/generate_vision_golden.py)
|
# Generated vision test fixtures (regenerate with: python scripts/generate_vision_golden.py)
|
||||||
sgl-model-gateway/tests/fixtures/golden/
|
sgl-model-gateway/tests/fixtures/golden/
|
||||||
|
|
||||||
|
# Other repos
|
||||||
lmms-eval
|
lmms-eval
|
||||||
|
|
||||||
**/.serena/
|
**/.serena/
|
||||||
@@ -262,7 +258,6 @@ inputs/
|
|||||||
# setuptools-scm generated version file
|
# setuptools-scm generated version file
|
||||||
python/sglang/_version.py
|
python/sglang/_version.py
|
||||||
|
|
||||||
|
|
||||||
# MUSA section
|
# MUSA section
|
||||||
# Generated source files by torchada
|
# Generated source files by torchada
|
||||||
sgl-kernel/csrc_musa/
|
sgl-kernel/csrc_musa/
|
||||||
|
|||||||
@@ -14,13 +14,11 @@ def main():
|
|||||||
|
|
||||||
# complex sub commands
|
# complex sub commands
|
||||||
subparsers = parser.add_subparsers(dest="subcommand", required=True)
|
subparsers = parser.add_subparsers(dest="subcommand", required=True)
|
||||||
|
|
||||||
subparsers.add_parser(
|
subparsers.add_parser(
|
||||||
"serve",
|
"serve",
|
||||||
help="Launch the SGLang server.",
|
help="Launch an SGLang server.",
|
||||||
add_help=False,
|
add_help=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
subparsers.add_parser(
|
subparsers.add_parser(
|
||||||
"generate",
|
"generate",
|
||||||
help="Run inference on a multimodal model.",
|
help="Run inference on a multimodal model.",
|
||||||
|
|||||||
+20
-15
@@ -52,17 +52,13 @@ def serve(args, extra_argv):
|
|||||||
# we can't show the exact help. Instead, we show a general help message and then
|
# we can't show the exact help. Instead, we show a general help message and then
|
||||||
# the help for both possible server types.
|
# the help for both possible server types.
|
||||||
print(
|
print(
|
||||||
"Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\n"
|
"Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\n\n"
|
||||||
)
|
"This command can launch either a standard language model server or a diffusion model server.\n"
|
||||||
print(
|
"The server type is determined by the --model-path.\n"
|
||||||
"This command can launch either a standard language model server or a diffusion model server."
|
|
||||||
)
|
|
||||||
print("The server type is determined by the model path.\n")
|
|
||||||
print(
|
|
||||||
"Optional override: --model-type {auto,llm,diffusion} "
|
"Optional override: --model-type {auto,llm,diffusion} "
|
||||||
"(default: auto, fallback to LLM on detection failure).\n"
|
"(default: auto, fallback to LLM on detection failure)."
|
||||||
)
|
)
|
||||||
print("For specific arguments, please provide a model_path.")
|
|
||||||
print("\n--- Help for Standard Language Model Server ---")
|
print("\n--- Help for Standard Language Model Server ---")
|
||||||
from sglang.srt.server_args import prepare_server_args
|
from sglang.srt.server_args import prepare_server_args
|
||||||
|
|
||||||
@@ -72,13 +68,22 @@ def serve(args, extra_argv):
|
|||||||
pass # argparse --help calls sys.exit
|
pass # argparse --help calls sys.exit
|
||||||
|
|
||||||
print("\n--- Help for Diffusion Model Server ---")
|
print("\n--- Help for Diffusion Model Server ---")
|
||||||
from sglang.multimodal_gen.runtime.entrypoints.cli.serve import (
|
try:
|
||||||
add_multimodal_gen_serve_args,
|
from sglang.multimodal_gen.runtime.entrypoints.cli.serve import (
|
||||||
)
|
add_multimodal_gen_serve_args,
|
||||||
|
)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="SGLang Diffusion Model Serving")
|
parser = argparse.ArgumentParser(
|
||||||
add_multimodal_gen_serve_args(parser)
|
prog="sglang serve",
|
||||||
parser.print_help()
|
description="SGLang Diffusion Model Serving",
|
||||||
|
)
|
||||||
|
add_multimodal_gen_serve_args(parser)
|
||||||
|
parser.print_help()
|
||||||
|
except ImportError:
|
||||||
|
print(
|
||||||
|
"Diffusion model support is not available. "
|
||||||
|
'Install with: pip install "sglang[diffusion]"'
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
model_type, dispatch_argv = _extract_model_type_override(extra_argv)
|
model_type, dispatch_argv = _extract_model_type_override(extra_argv)
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ def get_model_path(extra_argv):
|
|||||||
raise Exception(
|
raise Exception(
|
||||||
"Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\n\n"
|
"Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\n\n"
|
||||||
"This command can launch either a standard language model server or a diffusion model server.\n"
|
"This command can launch either a standard language model server or a diffusion model server.\n"
|
||||||
"The server type is determined by the model path.\n"
|
"The server type is determined by the --model-path.\n"
|
||||||
"For specific arguments, please provide a model_path."
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import warnings
|
||||||
|
|
||||||
from sglang.srt.server_args import prepare_server_args
|
from sglang.srt.server_args import prepare_server_args
|
||||||
from sglang.srt.utils import kill_process_tree
|
from sglang.srt.utils import kill_process_tree
|
||||||
@@ -14,6 +15,7 @@ suppress_noisy_warnings()
|
|||||||
def run_server(server_args):
|
def run_server(server_args):
|
||||||
"""Run the server based on server_args.grpc_mode and server_args.encoder_only."""
|
"""Run the server based on server_args.grpc_mode and server_args.encoder_only."""
|
||||||
if server_args.encoder_only:
|
if server_args.encoder_only:
|
||||||
|
# For encoder disaggregation
|
||||||
if server_args.grpc_mode:
|
if server_args.grpc_mode:
|
||||||
from sglang.srt.disaggregation.encode_grpc_server import (
|
from sglang.srt.disaggregation.encode_grpc_server import (
|
||||||
serve_grpc_encoder,
|
serve_grpc_encoder,
|
||||||
@@ -46,8 +48,6 @@ def run_server(server_args):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import warnings
|
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"'python -m sglang.launch_server' is still supported, but "
|
"'python -m sglang.launch_server' is still supported, but "
|
||||||
"'sglang serve' is the recommended entrypoint.\n"
|
"'sglang serve' is the recommended entrypoint.\n"
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def cuda_platform_plugin() -> str | None:
|
|||||||
if cuda_is_jetson():
|
if cuda_is_jetson():
|
||||||
is_cuda = True
|
is_cuda = True
|
||||||
if is_cuda:
|
if is_cuda:
|
||||||
logger.info("CUDA is available")
|
logger.debug("CUDA is available")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
"sglang.multimodal_gen.runtime.platforms.cuda.CudaPlatform" if is_cuda else None
|
"sglang.multimodal_gen.runtime.platforms.cuda.CudaPlatform" if is_cuda else None
|
||||||
@@ -67,9 +67,9 @@ def mps_platform_plugin() -> str | None:
|
|||||||
|
|
||||||
if torch.backends.mps.is_available():
|
if torch.backends.mps.is_available():
|
||||||
is_mps = True
|
is_mps = True
|
||||||
logger.info("MPS (Metal Performance Shaders) is available")
|
logger.debug("MPS (Metal Performance Shaders) is available")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info("MPS detection failed: %s", e)
|
logger.debug("MPS detection failed: %s", e)
|
||||||
|
|
||||||
return "sglang.multimodal_gen.runtime.platforms.mps.MpsPlatform" if is_mps else None
|
return "sglang.multimodal_gen.runtime.platforms.mps.MpsPlatform" if is_mps else None
|
||||||
|
|
||||||
@@ -90,11 +90,11 @@ def rocm_platform_plugin() -> str | None:
|
|||||||
try:
|
try:
|
||||||
if len(amdsmi.amdsmi_get_processor_handles()) > 0:
|
if len(amdsmi.amdsmi_get_processor_handles()) > 0:
|
||||||
is_rocm = True
|
is_rocm = True
|
||||||
logger.info("ROCm platform is available")
|
logger.debug("ROCm platform is available")
|
||||||
finally:
|
finally:
|
||||||
amdsmi.amdsmi_shut_down()
|
amdsmi.amdsmi_shut_down()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info("ROCm platform is unavailable: %s", e)
|
logger.debug("ROCm platform is unavailable: %s", e)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
"sglang.multimodal_gen.runtime.platforms.rocm.RocmPlatform" if is_rocm else None
|
"sglang.multimodal_gen.runtime.platforms.rocm.RocmPlatform" if is_rocm else None
|
||||||
@@ -109,9 +109,9 @@ def npu_platform_plugin() -> str | None:
|
|||||||
|
|
||||||
if torch.npu.is_available():
|
if torch.npu.is_available():
|
||||||
is_npu = True
|
is_npu = True
|
||||||
logger.info("NPU is available")
|
logger.debug("NPU is available")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info("NPU detection failed: %s", e)
|
logger.debug("NPU detection failed: %s", e)
|
||||||
return (
|
return (
|
||||||
"sglang.multimodal_gen.runtime.platforms.npu.NPUPlatformBase"
|
"sglang.multimodal_gen.runtime.platforms.npu.NPUPlatformBase"
|
||||||
if is_npu
|
if is_npu
|
||||||
@@ -131,7 +131,7 @@ def musa_platform_plugin() -> str | None:
|
|||||||
finally:
|
finally:
|
||||||
pymtml.mtmlLibraryShutDown()
|
pymtml.mtmlLibraryShutDown()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info("MUSA platform is unavailable: %s", e)
|
logger.debug("MUSA platform is unavailable: %s", e)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
"sglang.multimodal_gen.runtime.platforms.musa.MusaPlatform" if is_musa else None
|
"sglang.multimodal_gen.runtime.platforms.musa.MusaPlatform" if is_musa else None
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from sglang.srt.compilation.compiler_interface import EagerAdapter, InductorAdap
|
|||||||
from sglang.srt.compilation.cuda_piecewise_backend import CUDAPiecewiseBackend
|
from sglang.srt.compilation.cuda_piecewise_backend import CUDAPiecewiseBackend
|
||||||
from sglang.srt.compilation.npu_piecewise_backend import NPUPiecewiseBackend
|
from sglang.srt.compilation.npu_piecewise_backend import NPUPiecewiseBackend
|
||||||
from sglang.srt.compilation.pass_manager import PostGradPassManager
|
from sglang.srt.compilation.pass_manager import PostGradPassManager
|
||||||
from sglang.srt.utils.common import is_npu, rank0_log
|
from sglang.srt.utils.common import is_npu
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -375,7 +375,6 @@ class SGLangBackend:
|
|||||||
config: CompilationConfig,
|
config: CompilationConfig,
|
||||||
graph_pool: Any,
|
graph_pool: Any,
|
||||||
):
|
):
|
||||||
rank0_log(f"Initializing SGLangBackend")
|
|
||||||
assert graph_pool is not None
|
assert graph_pool is not None
|
||||||
self.graph_pool = graph_pool
|
self.graph_pool = graph_pool
|
||||||
|
|
||||||
@@ -394,7 +393,6 @@ class SGLangBackend:
|
|||||||
self.inductor_config["post_grad_custom_post_pass"] = self.post_grad_pass_manager
|
self.inductor_config["post_grad_custom_post_pass"] = self.post_grad_pass_manager
|
||||||
|
|
||||||
def __call__(self, graph: fx.GraphModule, example_inputs) -> Callable:
|
def __call__(self, graph: fx.GraphModule, example_inputs) -> Callable:
|
||||||
rank0_log(f"SGLangBackend __call__")
|
|
||||||
base_cache_dir = os.path.expanduser(
|
base_cache_dir = os.path.expanduser(
|
||||||
os.getenv("SGLANG_CACHE_DIR", "~/.cache/sglang/")
|
os.getenv("SGLANG_CACHE_DIR", "~/.cache/sglang/")
|
||||||
)
|
)
|
||||||
@@ -466,7 +464,5 @@ class SGLangBackend:
|
|||||||
with open(graph_path, "w") as f:
|
with open(graph_path, "w") as f:
|
||||||
f.write(src)
|
f.write(src)
|
||||||
|
|
||||||
rank0_log(f"Computation graph saved to {graph_path}")
|
|
||||||
|
|
||||||
self._called = True
|
self._called = True
|
||||||
return self.split_gm
|
return self.split_gm
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import torch
|
|||||||
|
|
||||||
from sglang.srt.compilation.compilation_config import CompilationConfig
|
from sglang.srt.compilation.compilation_config import CompilationConfig
|
||||||
from sglang.srt.compilation.piecewise_context_manager import is_in_piecewise_cuda_graph
|
from sglang.srt.compilation.piecewise_context_manager import is_in_piecewise_cuda_graph
|
||||||
from sglang.srt.utils.common import rank0_log
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -118,7 +117,6 @@ def install_torch_compiled(
|
|||||||
fullgraph: bool = True,
|
fullgraph: bool = True,
|
||||||
graph_pool: Any = None,
|
graph_pool: Any = None,
|
||||||
):
|
):
|
||||||
rank0_log(f"install_torch_compiled")
|
|
||||||
unbound_fwd = module.__class__.forward
|
unbound_fwd = module.__class__.forward
|
||||||
if not callable(unbound_fwd):
|
if not callable(unbound_fwd):
|
||||||
raise TypeError("module.__class__.forward must be callable")
|
raise TypeError("module.__class__.forward must be callable")
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ def initialize_mamba_selective_state_update_backend(server_args: ServerArgs) ->
|
|||||||
f"--mamba-backend value."
|
f"--mamba-backend value."
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(
|
logger.debug(
|
||||||
"Mamba selective_state_update backend initialized: %s",
|
"Mamba selective_state_update backend initialized: %s",
|
||||||
_mamba_ssu_backend.name,
|
_mamba_ssu_backend.name,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ from dataclasses import dataclass
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Any, Deque, Dict, List, Optional, Tuple, Union
|
from typing import Any, Deque, Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
|
from sglang.srt.utils.common import suppress_noisy_warnings
|
||||||
|
|
||||||
|
suppress_noisy_warnings()
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
import setproctitle
|
import setproctitle
|
||||||
import torch
|
import torch
|
||||||
|
|||||||
@@ -258,9 +258,6 @@ class SchedulerMetricsMixin:
|
|||||||
if self.disaggregation_mode == DisaggregationMode.PREFILL:
|
if self.disaggregation_mode == DisaggregationMode.PREFILL:
|
||||||
msg += f"#prealloc-req: {len(self.disagg_prefill_bootstrap_queue.queue)}, "
|
msg += f"#prealloc-req: {len(self.disagg_prefill_bootstrap_queue.queue)}, "
|
||||||
msg += f"#inflight-req: {len(self.disagg_prefill_inflight_queue)}, "
|
msg += f"#inflight-req: {len(self.disagg_prefill_inflight_queue)}, "
|
||||||
msg += f"input throughput (token/s): {self.last_input_throughput:.2f}, "
|
|
||||||
else:
|
|
||||||
msg += f"input throughput (token/s): {self.last_input_throughput:.2f}, "
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.server_args.language_only
|
self.server_args.language_only
|
||||||
@@ -275,7 +272,8 @@ class SchedulerMetricsMixin:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
msg += f"{graph_backend[self.device]}: {can_run_cuda_graph}"
|
msg += f"{graph_backend[self.device]}: {can_run_cuda_graph}, "
|
||||||
|
msg += f"input throughput (token/s): {self.last_input_throughput:.2f}"
|
||||||
|
|
||||||
if self.is_stats_logging_rank:
|
if self.is_stats_logging_rank:
|
||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
|
|||||||
@@ -6282,7 +6282,7 @@ def prepare_server_args(argv: List[str]) -> ServerArgs:
|
|||||||
Returns:
|
Returns:
|
||||||
The server arguments.
|
The server arguments.
|
||||||
"""
|
"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser(prog="sglang serve")
|
||||||
ServerArgs.add_cli_args(parser)
|
ServerArgs.add_cli_args(parser)
|
||||||
|
|
||||||
# Check for config file and merge arguments if present
|
# Check for config file and merge arguments if present
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ builtins.FP8_E4M3_MIN = FP8_E4M3_MIN
|
|||||||
# this makes it impossible to see the animation in the progress bar
|
# this makes it impossible to see the animation in the progress bar
|
||||||
# but will avoid messing up with ray or multiprocessing, which wraps
|
# but will avoid messing up with ray or multiprocessing, which wraps
|
||||||
# each line of output with some prefix.
|
# each line of output with some prefix.
|
||||||
BAR_FORMAT = "{desc}: {percentage:3.0f}% Completed | {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]\n" # noqa: E501
|
BAR_FORMAT = "{desc}: {percentage:3.0f}% Completed | {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]"
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
|
|||||||
Reference in New Issue
Block a user