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
4ed57807
Unverified
Commit
4ed57807
authored
Jul 09, 2025
by
Simo Lin
Committed by
GitHub
Jul 09, 2025
Browse files
[bugfix] add pd router policy validation (#7904)
parent
dd445a41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
10 deletions
+37
-10
sgl-router/src/config/types.rs
sgl-router/src/config/types.rs
+6
-10
sgl-router/src/config/validation.rs
sgl-router/src/config/validation.rs
+31
-0
No files found.
sgl-router/src/config/types.rs
View file @
4ed57807
...
...
@@ -231,16 +231,12 @@ impl RouterConfig {
PolicyConfig
::
PowerOfTwo
{
..
}
=>
{
crate
::
pd_types
::
PDSelectionPolicy
::
PowerOfTwo
}
PolicyConfig
::
CacheAware
{
cache_threshold
,
balance_abs_threshold
,
balance_rel_threshold
,
..
}
=>
crate
::
pd_types
::
PDSelectionPolicy
::
CacheAware
{
cache_threshold
:
*
cache_threshold
,
balance_abs_threshold
:
*
balance_abs_threshold
,
balance_rel_threshold
:
*
balance_rel_threshold
,
},
PolicyConfig
::
CacheAware
{
..
}
=>
{
return
Err
(
ConfigError
::
IncompatibleConfig
{
reason
:
"CacheAware policy is not supported in PD disaggregated mode"
.to_string
(),
});
}
PolicyConfig
::
RoundRobin
=>
{
return
Err
(
ConfigError
::
IncompatibleConfig
{
reason
:
"RoundRobin policy is not supported in PD disaggregated mode"
...
...
sgl-router/src/config/validation.rs
View file @
4ed57807
...
...
@@ -270,6 +270,12 @@ impl ConfigValidator {
.to_string
(),
});
}
(
RoutingMode
::
PrefillDecode
{
..
},
PolicyConfig
::
CacheAware
{
..
})
=>
{
return
Err
(
ConfigError
::
IncompatibleConfig
{
reason
:
"CacheAware policy is not supported in PD disaggregated mode"
.to_string
(),
});
}
_
=>
{}
}
...
...
@@ -471,6 +477,31 @@ mod tests {
.contains
(
"RoundRobin policy is not supported in PD disaggregated mode"
));
}
#[test]
fn
test_validate_cache_aware_with_pd_mode
()
{
// CacheAware with PD mode should fail
let
config
=
RouterConfig
::
new
(
RoutingMode
::
PrefillDecode
{
prefill_urls
:
vec!
[(
"http://prefill:8000"
.to_string
(),
None
)],
decode_urls
:
vec!
[
"http://decode:8000"
.to_string
()],
},
PolicyConfig
::
CacheAware
{
cache_threshold
:
0.5
,
balance_abs_threshold
:
32
,
balance_rel_threshold
:
1.1
,
eviction_interval_secs
:
60
,
max_tree_size
:
1000
,
},
);
let
result
=
ConfigValidator
::
validate
(
&
config
);
assert
!
(
result
.is_err
());
assert
!
(
result
.unwrap_err
()
.to_string
()
.contains
(
"CacheAware policy is not supported in PD disaggregated mode"
));
}
#[test]
fn
test_validate_power_of_two_with_regular_mode
()
{
// PowerOfTwo with Regular mode should fail
...
...
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