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
26ebb849
Unverified
Commit
26ebb849
authored
May 18, 2025
by
fzyzcjy
Committed by
GitHub
May 17, 2025
Browse files
Tiny refactor bench_serving to extract RequestFuncOutput.init_new (#6108)
parent
02973cd9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
python/sglang/bench_serving.py
python/sglang/bench_serving.py
+10
-8
No files found.
python/sglang/bench_serving.py
View file @
26ebb849
...
@@ -73,6 +73,12 @@ class RequestFuncOutput:
...
@@ -73,6 +73,12 @@ class RequestFuncOutput:
error
:
str
=
""
error
:
str
=
""
output_len
:
int
=
0
output_len
:
int
=
0
@
staticmethod
def
init_new
(
request_func_input
:
RequestFuncInput
):
output
=
RequestFuncOutput
()
output
.
prompt_len
=
request_func_input
.
prompt_len
return
output
def
remove_prefix
(
text
:
str
,
prefix
:
str
)
->
str
:
def
remove_prefix
(
text
:
str
,
prefix
:
str
)
->
str
:
return
text
[
len
(
prefix
)
:]
if
text
.
startswith
(
prefix
)
else
text
return
text
[
len
(
prefix
)
:]
if
text
.
startswith
(
prefix
)
else
text
...
@@ -114,8 +120,7 @@ async def async_request_trt_llm(
...
@@ -114,8 +120,7 @@ async def async_request_trt_llm(
if
args
.
disable_ignore_eos
:
if
args
.
disable_ignore_eos
:
del
payload
[
"min_length"
]
del
payload
[
"min_length"
]
del
payload
[
"end_id"
]
del
payload
[
"end_id"
]
output
=
RequestFuncOutput
()
output
=
RequestFuncOutput
.
init_new
(
request_func_input
)
output
.
prompt_len
=
request_func_input
.
prompt_len
ttft
=
0.0
ttft
=
0.0
st
=
time
.
perf_counter
()
st
=
time
.
perf_counter
()
...
@@ -186,8 +191,7 @@ async def async_request_openai_completions(
...
@@ -186,8 +191,7 @@ async def async_request_openai_completions(
}
}
headers
=
get_auth_headers
()
headers
=
get_auth_headers
()
output
=
RequestFuncOutput
()
output
=
RequestFuncOutput
.
init_new
(
request_func_input
)
output
.
prompt_len
=
request_func_input
.
prompt_len
generated_text
=
""
generated_text
=
""
output_len
=
request_func_input
.
output_len
output_len
=
request_func_input
.
output_len
...
@@ -269,8 +273,7 @@ async def async_request_truss(
...
@@ -269,8 +273,7 @@ async def async_request_truss(
}
}
headers
=
get_auth_headers
()
headers
=
get_auth_headers
()
output
=
RequestFuncOutput
()
output
=
RequestFuncOutput
.
init_new
(
request_func_input
)
output
.
prompt_len
=
request_func_input
.
prompt_len
generated_text
=
""
generated_text
=
""
ttft
=
0.0
ttft
=
0.0
...
@@ -355,8 +358,7 @@ async def async_request_sglang_generate(
...
@@ -355,8 +358,7 @@ async def async_request_sglang_generate(
headers
=
get_auth_headers
()
headers
=
get_auth_headers
()
output
=
RequestFuncOutput
()
output
=
RequestFuncOutput
.
init_new
(
request_func_input
)
output
.
prompt_len
=
request_func_input
.
prompt_len
generated_text
=
""
generated_text
=
""
output_len
=
request_func_input
.
output_len
output_len
=
request_func_input
.
output_len
...
...
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