Skip to content

Commit eb79339

Browse files
Bihan  RanaBihan  Rana
authored andcommitted
Test sglang router per service implementation
1 parent 6510956 commit eb79339

File tree

7 files changed

+134
-678
lines changed

7 files changed

+134
-678
lines changed

src/dstack/_internal/core/models/routers.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,10 @@
99

1010
class RouterType(str, Enum):
1111
SGLANG = "sglang"
12-
SGLANG_DEPRECATED = "sglang_deprecated"
13-
SGLANG_NEW = "sglang_new"
1412
VLLM = "vllm"
1513

1614

1715
class SGLangRouterConfig(CoreModel):
18-
type: Literal["sglang_deprecated"] = "sglang_deprecated"
19-
policy: str = "cache_aware"
20-
21-
22-
class SGLangNewRouterConfig(CoreModel):
2316
type: Literal["sglang"] = "sglang"
2417
policy: str = "cache_aware"
2518

@@ -30,5 +23,5 @@ class VLLMRouterConfig(CoreModel):
3023

3124

3225
AnyRouterConfig = Annotated[
33-
Union[SGLangRouterConfig, SGLangNewRouterConfig, VLLMRouterConfig], Field(discriminator="type")
26+
Union[SGLangRouterConfig, VLLMRouterConfig], Field(discriminator="type")
3427
]

src/dstack/_internal/proxy/gateway/model_routers/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,19 @@
22

33
from dstack._internal.core.models.routers import AnyRouterConfig
44
from dstack._internal.proxy.gateway.model_routers.sglang import SglangRouter
5-
from dstack._internal.proxy.gateway.model_routers.sglang_new import SglangRouterNew
65

7-
from .base import Replica, Router, RouterContext
6+
from .base import Router, RouterContext
87

98

109
def get_router(router: AnyRouterConfig, context: Optional[RouterContext] = None) -> Router:
1110
"""Factory function to create a router instance from router configuration."""
1211
if router.type == "sglang":
13-
return SglangRouterNew(router=router, context=context)
14-
if router.type == "sglang_deprecated":
1512
return SglangRouter(router=router, context=context)
16-
if router.type == "sglang_new":
17-
return SglangRouterNew(router=router, context=context)
1813
raise ValueError(f"Router type '{router.type}' is not available")
1914

2015

2116
__all__ = [
2217
"Router",
2318
"RouterContext",
24-
"Replica",
2519
"get_router",
2620
]

src/dstack/_internal/proxy/gateway/model_routers/base.py

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ class Config:
1919
log_level: Literal["debug", "info", "warning", "error"] = "info"
2020

2121

22-
class Replica(BaseModel):
23-
"""Represents a single replica (worker) endpoint managed by the router.
24-
25-
The model field identifies which model this replica serves.
26-
In SGLang, model = model_id (e.g., "meta-llama/Meta-Llama-3.1-8B-Instruct").
27-
"""
28-
29-
url: str # HTTP URL where the replica is accessible (e.g., "http://127.0.0.1:10001")
30-
model: str # (e.g., "meta-llama/Meta-Llama-3.1-8B-Instruct")
31-
32-
3322
class Router(ABC):
3423
"""Abstract base class for router implementations (e.g., SGLang, vLLM).
3524
@@ -79,67 +68,35 @@ def is_running(self) -> bool:
7968
...
8069

8170
@abstractmethod
82-
def register_replicas(
83-
self, domain: str, num_replicas: int, model_id: Optional[str] = None
84-
) -> List[Replica]:
85-
"""Register replicas to a domain (allocate ports/URLs for workers).
86-
87-
Args:
88-
domain: The domain name for this service.
89-
num_replicas: The number of replicas to allocate for this domain.
90-
model_id: Optional model identifier (e.g., "meta-llama/Meta-Llama-3.1-8B-Instruct").
91-
Required only for routers that support IGW (Inference Gateway) mode for multi-model serving.
92-
93-
Returns:
94-
List of Replica objects with allocated URLs and model_id set (if provided).
95-
96-
Raises:
97-
Exception: If allocation fails.
98-
"""
99-
...
100-
101-
@abstractmethod
102-
def unregister_replicas(self, domain: str) -> None:
103-
"""Unregister replicas for a domain (remove model and unassign all its replicas).
104-
105-
Args:
106-
domain: The domain name for this service.
107-
108-
Raises:
109-
Exception: If removal fails or domain is not found.
110-
"""
111-
...
112-
113-
@abstractmethod
114-
def add_replicas(self, replicas: List[Replica]) -> None:
71+
def add_replicas(self, replica_urls: List[str]) -> None:
11572
"""Register replicas with the router (actual API calls to add workers).
11673
11774
Args:
118-
replicas: The list of replicas to add to router.
75+
replica_urls: The list of replica URLs to add to router.
11976
12077
Raises:
12178
Exception: If adding replicas fails.
12279
"""
12380
...
12481

12582
@abstractmethod
126-
def remove_replicas(self, replicas: List[Replica]) -> None:
83+
def remove_replicas(self, replica_urls: List[str]) -> None:
12784
"""Unregister replicas from the router (actual API calls to remove workers).
12885
12986
Args:
130-
replicas: The list of replicas to remove from router.
87+
replica_urls: The list of replica URLs to remove from router.
13188
13289
Raises:
13390
Exception: If removing replicas fails.
13491
"""
13592
...
13693

13794
@abstractmethod
138-
def update_replicas(self, replicas: List[Replica]) -> None:
95+
def update_replicas(self, replica_urls: List[str]) -> None:
13996
"""Update replicas for service, replacing the current set.
14097
14198
Args:
142-
replicas: The new list of replicas for this service.
99+
replica_urls: The new list of replica URLs for this service.
143100
144101
Raises:
145102
Exception: If updating replicas fails.

0 commit comments

Comments
 (0)