Skip to content

Commit

Permalink
CI: skip special token for engine token ids unit test (#2648)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaochenyang20 authored Dec 29, 2024
1 parent 09e6e2a commit 1703d76
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/srt/test_engine_token_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ def test_token_ids_in_generate(self):
"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()
Expand Down

0 comments on commit 1703d76

Please sign in to comment.