[bugfix] add pd router policy validation (#7904)

This commit is contained in:
Simo Lin
2025-07-09 21:52:06 -07:00
committed by GitHub
parent dd445a41f5
commit 4ed57807c2
2 changed files with 37 additions and 10 deletions

View File

@@ -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"

View File

@@ -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