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
1703d766
Unverified
Commit
1703d766
authored
Dec 29, 2024
by
Chayenne
Committed by
GitHub
Dec 29, 2024
Browse files
CI: skip special token for engine token ids unit test (#2648)
parent
09e6e2aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
test/srt/test_engine_token_ids.py
test/srt/test_engine_token_ids.py
+11
-8
No files found.
test/srt/test_engine_token_ids.py
View file @
1703d766
...
...
@@ -19,20 +19,23 @@ class TestEngineTokenIds(unittest.TestCase):
"The capital of France is"
,
"The future of AI is"
,
]
sampling_params
=
{
"temperature"
:
0
,
"top_p"
:
0.95
}
outputs
=
llm
.
generate
(
prompts
,
sampling_params
)
for
prompt
,
output
in
zip
(
prompts
,
outputs
):
# SGLang's input_ids has a start token, so we remove it for comparison.
deocode_input
=
tokenizer
.
decode
(
output
[
"input_ids"
][
1
:])
assert
(
deocode_input
in
prompt
deocode_input
=
tokenizer
.
decode
(
output
[
"input_ids"
],
skip_special_tokens
=
True
)
assert
(
deocode_input
in
prompt
)
or
(
prompt
in
deocode_input
),
f
"Decode input:
{
deocode_input
}
mismatch for:
{
prompt
}
"
# SGLang's output_ids does not have a start token.
deocode_output
=
tokenizer
.
decode
(
output
[
"output_ids"
])
assert
(
deocode_output
in
output
[
"text"
]
deocode_output
=
tokenizer
.
decode
(
output
[
"output_ids"
],
skip_special_tokens
=
True
)
assert
(
deocode_output
in
output
[
"text"
])
or
(
output
[
"text"
]
in
deocode_output
),
f
"Decode output:
{
deocode_output
}
mismatch for:
{
output
[
'text'
]
}
"
llm
.
shutdown
()
...
...
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