Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
64affab4
Unverified
Commit
64affab4
authored
Oct 16, 2025
by
Simo Lin
Committed by
GitHub
Oct 16, 2025
Browse files
[router] fix p and d worker filtering and bootstrap port handling (#11729)
parent
4c9bcb9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
30 deletions
+31
-30
sgl-router/src/core/worker.rs
sgl-router/src/core/worker.rs
+14
-0
sgl-router/src/core/worker_registry.rs
sgl-router/src/core/worker_registry.rs
+2
-2
sgl-router/src/routers/grpc/pipeline.rs
sgl-router/src/routers/grpc/pipeline.rs
+15
-28
No files found.
sgl-router/src/core/worker.rs
View file @
64affab4
...
...
@@ -247,6 +247,20 @@ pub enum ConnectionMode {
},
}
impl
ConnectionMode
{
/// Check if this connection mode matches another, with special handling for gRPC
/// This allows matching any gRPC connection regardless of port when comparing
/// Grpc { port: None } as a wildcard
pub
fn
matches
(
&
self
,
filter
:
&
ConnectionMode
)
->
bool
{
match
(
self
,
filter
)
{
(
ConnectionMode
::
Http
,
ConnectionMode
::
Http
)
=>
true
,
(
ConnectionMode
::
Grpc
{
..
},
ConnectionMode
::
Grpc
{
port
:
None
})
=>
true
,
(
ConnectionMode
::
Grpc
{
port
:
p1
},
ConnectionMode
::
Grpc
{
port
:
p2
})
=>
p1
==
p2
,
_
=>
false
,
}
}
}
impl
fmt
::
Display
for
ConnectionMode
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
match
self
{
...
...
sgl-router/src/core/worker_registry.rs
View file @
64affab4
...
...
@@ -308,9 +308,9 @@ impl WorkerRegistry {
}
}
// Check connection_mode if specified
// Check connection_mode if specified
(using matches for flexible gRPC matching)
if
let
Some
(
ref
conn
)
=
connection_mode
{
if
w
.connection_mode
()
!=
*
conn
{
if
!
w
.connection_mode
()
.matches
(
conn
)
{
return
false
;
}
}
...
...
sgl-router/src/routers/grpc/pipeline.rs
View file @
64affab4
...
...
@@ -340,45 +340,32 @@ impl WorkerSelectionStage {
model_id
:
Option
<&
str
>
,
text
:
Option
<&
str
>
,
)
->
Option
<
(
Arc
<
dyn
Worker
>
,
Arc
<
dyn
Worker
>
)
>
{
// Get prefill workers - use None for WorkerType filter to get all types,
// then filter manually (since Prefill is a struct variant)
let
all_workers
=
self
.worker_registry
.get_workers_filtered
(
model_id
,
None
,
// Get all types
Some
(
ConnectionMode
::
Grpc
{
port
:
None
}),
None
,
Some
(
ConnectionMode
::
Grpc
{
port
:
None
}),
// Match any gRPC worker
false
,
);
let
prefill_workers
:
Vec
<
_
>
=
all_workers
.iter
()
.filter
(|
w
|
matches!
(
w
.metadata
()
.worker_type
,
WorkerType
::
Prefill
{
..
}))
.cloned
()
.collect
();
let
available_prefill
:
Vec
<
_
>
=
prefill_workers
.iter
()
.filter
(|
w
|
w
.is_available
())
.cloned
()
.collect
();
let
(
available_prefill
,
available_decode
):
(
Vec
<
_
>
,
Vec
<
_
>
)
=
all_workers
.into_iter
()
.fold
((
Vec
::
new
(),
Vec
::
new
()),
|
mut
acc
,
w
|
{
if
w
.is_available
()
{
match
w
.metadata
()
.worker_type
{
WorkerType
::
Prefill
{
..
}
=>
acc
.0
.push
(
w
),
WorkerType
::
Decode
=>
acc
.1
.push
(
w
),
_
=>
{}
}
}
acc
});
if
available_prefill
.is_empty
()
{
warn!
(
"No available prefill workers"
);
return
None
;
}
// Get decode workers from the same all_workers list
let
decode_workers
:
Vec
<
_
>
=
all_workers
.iter
()
.filter
(|
w
|
matches!
(
w
.metadata
()
.worker_type
,
WorkerType
::
Decode
))
.cloned
()
.collect
();
let
available_decode
:
Vec
<
_
>
=
decode_workers
.iter
()
.filter
(|
w
|
w
.is_available
())
.cloned
()
.collect
();
if
available_decode
.is_empty
()
{
warn!
(
"No available decode workers"
);
return
None
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment