Skip to content

Commit 1ff19a8

Browse files
authored
fix: potential out-of-bound (#420)
Signed-off-by: Tianer Zhou <[email protected]>
1 parent a213363 commit 1ff19a8

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

lib/llm/src/kv_router/scheduler.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ pub fn select_worker(
245245
let kv_load_ratio = w.data.kv_active_blocks as f64 / w.data.kv_total_blocks as f64;
246246
let load_deviation = kv_load_ratio - workers.load_avg;
247247

248-
// [FIXME] multiple endpoints of the same worker cause out of bound error
249-
let worker_id = workers.worker_ids[i];
248+
let worker_id = w.worker_id();
250249
let overlap_score = request.overlap.scores.get(&worker_id).map_or(0, |x| *x);
251250
let overlap_score = overlap_score as usize * kv_block_size;
252251

lib/llm/src/kv_router/scoring.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
//! Scoring functions for the KV router.
1717
1818
use serde::{Deserialize, Serialize};
19-
use std::collections::HashSet;
2019

2120
use crate::kv_router::scheduler::Endpoint;
2221

2322
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
2423
pub struct ProcessedEndpoints {
2524
pub endpoints: Vec<Endpoint>,
26-
pub worker_ids: Vec<i64>,
2725
pub load_avg: f64,
2826
pub load_std: f64,
2927
}
@@ -43,12 +41,8 @@ impl ProcessedEndpoints {
4341
/ load_values.len() as f64;
4442
let load_std = variance.sqrt();
4543

46-
let worker_ids: HashSet<i64> = endpoints.iter().map(|x| x.worker_id()).collect();
47-
let worker_ids: Vec<i64> = worker_ids.into_iter().collect();
48-
4944
ProcessedEndpoints {
5045
endpoints,
51-
worker_ids,
5246
load_avg,
5347
load_std,
5448
}

0 commit comments

Comments
 (0)