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
zhaoyu6
sglang
Commits
ffd03a9b
Unverified
Commit
ffd03a9b
authored
Oct 04, 2025
by
Simo Lin
Committed by
GitHub
Oct 04, 2025
Browse files
[router] fix get load response parsing (#11213)
parent
666da3d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
+26
-5
sgl-router/py_test/fixtures/mock_worker.py
sgl-router/py_test/fixtures/mock_worker.py
+11
-1
sgl-router/src/core/worker_manager.rs
sgl-router/src/core/worker_manager.rs
+15
-4
No files found.
sgl-router/py_test/fixtures/mock_worker.py
View file @
ffd03a9b
...
...
@@ -141,7 +141,17 @@ def create_app(args: argparse.Namespace) -> FastAPI:
@
app
.
get
(
"/get_load"
)
async
def
get_load
(
request
:
Request
):
check_api_key
(
request
)
return
JSONResponse
({
"load"
:
_inflight
})
# Return format matching real workers: array of load info per DP rank
return
JSONResponse
(
[
{
"dp_rank"
:
0
,
"num_reqs"
:
_inflight
,
"num_waiting_reqs"
:
0
,
"num_tokens"
:
_inflight
,
}
]
)
def
make_json_response
(
obj
:
dict
,
status_code
:
int
=
200
)
->
JSONResponse
:
resp
=
JSONResponse
(
obj
,
status_code
=
status_code
)
...
...
sgl-router/src/core/worker_manager.rs
View file @
ffd03a9b
...
...
@@ -1252,11 +1252,22 @@ impl WorkerManager {
Ok
(
response
)
if
response
.status
()
.is_success
()
=>
{
match
response
.json
::
<
Value
>
()
.await
{
Ok
(
json
)
=>
{
if
let
Some
(
load
)
=
json
.get
(
"load"
)
.and_then
(|
v
|
v
.as_i64
())
{
debug!
(
"Worker {} load: {}"
,
url
,
load
);
Some
(
load
as
isize
)
// The /get_load endpoint returns an array of load info objects (one per DP rank)
// Each object has: {dp_rank, num_reqs, num_waiting_reqs, num_tokens}
if
let
Some
(
array
)
=
json
.as_array
()
{
let
total_tokens
:
i64
=
array
.iter
()
.filter_map
(|
entry
|
{
entry
.get
(
"num_tokens"
)
.and_then
(|
v
|
v
.as_i64
())
})
.sum
();
debug!
(
"Worker {} load (total tokens): {}"
,
url
,
total_tokens
);
Some
(
total_tokens
as
isize
)
}
else
{
warn!
(
"Invalid load response from {}: {:?}"
,
url
,
json
);
warn!
(
"Invalid load response from {}: expected array, got {:?}"
,
url
,
json
);
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