sgl-project/sglang · info · UserWarning

'python -m sglang.launch_server' is still supported, but 'sg

Error message

'python -m sglang.launch_server' is still supported, but 'sglang serve' is the recommended entrypoint.
  Example: sglang serve --model-path <model> [options]

What it means

Running 'python -m sglang.launch_server' still works but is no longer the recommended CLI. The modern entrypoint is the 'sglang serve' subcommand; the old module path emits this UserWarning at startup.

Source

Thrown at python/sglang/launch_server.py:63

        # Ray mode: HTTP mode with Ray backend.
        try:
            from sglang.srt.ray.http_server import launch_server
        except ImportError:
            raise ImportError(
                "Ray is required for --use-ray mode. "
                "Install it with: pip install 'sglang[ray]'"
            )

        launch_server(server_args)
    else:
        # Default mode: HTTP mode.
        from sglang.srt.entrypoints.http_server import launch_server

        launch_server(server_args)


if __name__ == "__main__":
    warnings.warn(
        "'python -m sglang.launch_server' is still supported, but "
        "'sglang serve' is the recommended entrypoint.\n"
        "  Example: sglang serve --model-path <model> [options]",
        UserWarning,
        stacklevel=1,
    )

    load_plugins()

    server_args = prepare_server_args(sys.argv[1:])

    try:
        run_server(server_args)
    finally:
        kill_process_tree(os.getpid(), include_parent=False)

View on GitHub (pinned to 0132848349)

Solutions

  1. Replace with: sglang serve --model-path <model> [options]
  2. Update Docker CMD/ENTRYPOINT and any orchestration templates accordingly
  3. If you must keep the old form temporarily, silence with PYTHONWARNINGS or warnings filter, but plan migration

Example fix

# before
python -m sglang.launch_server --model-path meta-llama/Llama-3-8B-Instruct
# after
sglang serve --model-path meta-llama/Llama-3-8B-Instruct
Defensive patterns

Strategy: validation

Validate before calling

import subprocess, sys
subprocess.run(["sglang", "serve", "--model-path", model, *extra_args])

Prevention

When it happens

Trigger: Executing python -m sglang.launch_server --model-path ... directly, or a legacy systemd/Docker launch script/deployment YAML that still invokes the module form.

Common situations: Upgrading sglang and old deployment manifests keep the module invocation; copy-pasted launch commands from older blog posts or READMEs.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/83e33f2f4d076087. Report an issue: GitHub.