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
OpenDAS
dynamo
Commits
2dc18dbc
Commit
2dc18dbc
authored
Mar 31, 2025
by
Tianer Zhou
Committed by
GitHub
Mar 31, 2025
Browse files
fix: potential out-of-bound (#420)
Signed-off-by:
Tianer Zhou
<
ezhoureal@gmail.com
>
parent
fcdcb12f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
8 deletions
+1
-8
lib/llm/src/kv_router/scheduler.rs
lib/llm/src/kv_router/scheduler.rs
+1
-2
lib/llm/src/kv_router/scoring.rs
lib/llm/src/kv_router/scoring.rs
+0
-6
No files found.
lib/llm/src/kv_router/scheduler.rs
View file @
2dc18dbc
...
@@ -245,8 +245,7 @@ pub fn select_worker(
...
@@ -245,8 +245,7 @@ pub fn select_worker(
let
kv_load_ratio
=
w
.data.kv_active_blocks
as
f64
/
w
.data.kv_total_blocks
as
f64
;
let
kv_load_ratio
=
w
.data.kv_active_blocks
as
f64
/
w
.data.kv_total_blocks
as
f64
;
let
load_deviation
=
kv_load_ratio
-
workers
.load_avg
;
let
load_deviation
=
kv_load_ratio
-
workers
.load_avg
;
// [FIXME] multiple endpoints of the same worker cause out of bound error
let
worker_id
=
w
.worker_id
();
let
worker_id
=
workers
.worker_ids
[
i
];
let
overlap_score
=
request
.overlap.scores
.get
(
&
worker_id
)
.map_or
(
0
,
|
x
|
*
x
);
let
overlap_score
=
request
.overlap.scores
.get
(
&
worker_id
)
.map_or
(
0
,
|
x
|
*
x
);
let
overlap_score
=
overlap_score
as
usize
*
kv_block_size
;
let
overlap_score
=
overlap_score
as
usize
*
kv_block_size
;
...
...
lib/llm/src/kv_router/scoring.rs
View file @
2dc18dbc
...
@@ -16,14 +16,12 @@
...
@@ -16,14 +16,12 @@
//! Scoring functions for the KV router.
//! Scoring functions for the KV router.
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
std
::
collections
::
HashSet
;
use
crate
::
kv_router
::
scheduler
::
Endpoint
;
use
crate
::
kv_router
::
scheduler
::
Endpoint
;
#[derive(Debug,
Default,
Serialize,
Deserialize,
Clone)]
#[derive(Debug,
Default,
Serialize,
Deserialize,
Clone)]
pub
struct
ProcessedEndpoints
{
pub
struct
ProcessedEndpoints
{
pub
endpoints
:
Vec
<
Endpoint
>
,
pub
endpoints
:
Vec
<
Endpoint
>
,
pub
worker_ids
:
Vec
<
i64
>
,
pub
load_avg
:
f64
,
pub
load_avg
:
f64
,
pub
load_std
:
f64
,
pub
load_std
:
f64
,
}
}
...
@@ -43,12 +41,8 @@ impl ProcessedEndpoints {
...
@@ -43,12 +41,8 @@ impl ProcessedEndpoints {
/
load_values
.len
()
as
f64
;
/
load_values
.len
()
as
f64
;
let
load_std
=
variance
.sqrt
();
let
load_std
=
variance
.sqrt
();
let
worker_ids
:
HashSet
<
i64
>
=
endpoints
.iter
()
.map
(|
x
|
x
.worker_id
())
.collect
();
let
worker_ids
:
Vec
<
i64
>
=
worker_ids
.into_iter
()
.collect
();
ProcessedEndpoints
{
ProcessedEndpoints
{
endpoints
,
endpoints
,
worker_ids
,
load_avg
,
load_avg
,
load_std
,
load_std
,
}
}
...
...
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