You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: SamplingParams with an explicit end_id fails when stop or bad strings are set #21613
Not GPU or model specific: the failure is in the LLM API before the request reaches the engine
Who can help?
No response
Information
The official example scripts
My own modified scripts
Tasks
An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
My own task or dataset (give details below)
Reproduction
fromtensorrt_llmimportLLM, SamplingParamsllm=LLM(model="Qwen/Qwen2.5-0.5B-Instruct")
params=SamplingParams(max_tokens=32, end_id=-1, stop=["\n"])
llm.generate("The capital of France is", params)
Fails with:
SamplingParams.stop (['\n']) is not processed by tokenizer, please call the setup method.
The same happens with bad=[...], and with stop=[], whenever end_id is set.
Expected behavior
Stop and bad strings are applied whether or not end_id is set explicitly.
actual behavior
The request fails with the error above.
additional notes
BaseLLM._prepare_sampling_params (tensorrt_llm/llmapi/llm.py) only calls SamplingParams._setup when end_id is None:
_setup fills in the default end_id/pad_id, but it is also the only place that tokenizes stop and bad into _stop_word_ids / _bad_word_ids. With an explicit end_id that tokenization never runs, and _get_stop_words() raises when the worker builds the request.
I have a fix ready: move the stop/bad tokenization into its own method and call it for an explicit end_id too, while the end_id/pad_id/EOS defaults keep applying only when end_id is unset.
Before submitting a new issue...
Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
Activity
[NVIDIA#21613][fix] Tokenize stop and bad strings when end_id is give…
[NVIDIA#21613][fix] Require a tokenizer for empty stop and bad string…
[#21613][fix] Tokenize stop and bad strings when end_id is given expl…