[Serve][LLM] SGLangServer multi-replica support
Author: eicherseijiCreated Apr 9, 2026Updated Sep 29, 2026
Labelsbuggood-first-issuetriageservellmstabilityhelp-wanted
What happened + What you expected to happen
Three blockers
- Multi replica actor name collision: https://github.com/sgl-project/sglang/blob/60acdc31f2073c1be4997c6a1e3b6fa90cd41b81/python/sglang/srt/ray/engine.py#L152
ray.exceptions.ActorAlreadyExistsError: The name sglang_scheduler_rank0node=10.0.197.129_pp0_tp0 (namespace=None) is already taken.- Not switching EngineClass when Ray is enabled: https://github.com/ray-project/ray/blob/f4502b93dfacf047491079eddddf34ad43bace1b/python/ray/llm/examples/sglang/modules/sglang_engine.py#L69
Causes OOM because mp backend does not set CUDA visible devices:
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 512.00 MiB. GPU 0 has a total capacity of 22.03 GiB of which 408.94 MiB is free. Process 63764 has 17.97 GiB memory in use.- Port collision: https://github.com/sgl-project/sglang/blob/60acdc31f2073c1be4997c6a1e3b6fa90cd41b81/python/sglang/srt/ray/engine.py#L129
torch.distributed.DistNetworkError: The server socket has failed to listen on any local network address. port: 30233, useIpv6: false, code: -98, name: EADDRINUSE, message: address already in useVersions / Dependencies
Docker image: rayproject/ray-llm:nightly-py311-cu128
pip3 uninstall -y vllm
pip3 install "sglang[all,ray]==0.5.10rc0"
# Reinstall opentelemetry-proto to regenerate _pb2.py files compatible with
# the protobuf version that sglang pulls in (protobuf 4.x+ removed old-style
# descriptor creation, causing Ray dashboard to crash on startup).
pip3 install --upgrade opentelemetry-proto opentelemetry-sdk opentelemetry-exporter-prometheusReproduction script
import sys
import httpx
import pytest
from openai import OpenAI
from ray import serve
from ray._common.test_utils import wait_for_condition
from ray.llm.examples.sglang.modules.sglang_engine import SGLangServer
from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME
from ray.serve.llm import LLMConfig, build_openai_app
from ray.serve.schema import ApplicationStatus
MODEL_ID = "Qwen/Qwen2.5-0.5B-Instruct"
RAY_MODEL_ID = "qwen-0.5b-sglang"
llm_config = LLMConfig(
model_loading_config={
"model_id": RAY_MODEL_ID,
"model_source": MODEL_ID,
},
deployment_config={
"autoscaling_config": {
"min_replicas": 2,
"max_replicas": 2,
}
},
server_cls=SGLangServer,
engine_kwargs={
"model_path": MODEL_ID,
"tp_size": 1,
"mem_fraction_static": 0.8,
"use_ray": True
},
)
app = build_openai_app({"llm_configs": [llm_config]})
serve.run(app, blocking=False)Issue Severity
None
Source: ray-project/ray