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
21a8fa16
Unverified
Commit
21a8fa16
authored
Nov 04, 2025
by
Yi Zhang
Committed by
GitHub
Nov 03, 2025
Browse files
tiny optimize for bench serving (#12553)
parent
7a21d8b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
python/sglang/bench_serving.py
python/sglang/bench_serving.py
+8
-1
No files found.
python/sglang/bench_serving.py
View file @
21a8fa16
...
...
@@ -25,6 +25,7 @@ import warnings
from
argparse
import
ArgumentParser
from
dataclasses
import
dataclass
,
field
from
datetime
import
datetime
from
functools
import
lru_cache
from
json
import
JSONDecodeError
from
pathlib
import
Path
from
typing
import
Any
,
AsyncGenerator
,
Dict
,
List
,
Optional
,
Tuple
,
Union
...
...
@@ -1484,9 +1485,15 @@ def sample_image_requests(
return
dataset
@
lru_cache
(
maxsize
=
1
)
def
get_available_tokens
(
tokenizer
):
"""Get all available token ids from the tokenizer vocabulary."""
return
list
(
tokenizer
.
get_vocab
().
values
())
def
gen_prompt
(
tokenizer
,
token_num
):
"""Generate a random prompt of specified token length using tokenizer vocabulary."""
all_available_tokens
=
list
(
tokenizer
.
get_vocab
().
values
()
)
all_available_tokens
=
get_available_tokens
(
tokenizer
)
selected_tokens
=
random
.
choices
(
all_available_tokens
,
k
=
token_num
)
return
tokenizer
.
decode
(
selected_tokens
)
...
...
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