@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / c3b5189137
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 14:45 UTC

[Bugfix] catch AssertionError in MistralTokenizer as ValueError (#16344)

Signed-off-by: Guillaume Calmettes <gcalmettes@scaleway.com>

Guillaume Calmettes committed Apr 9, 2025 at 19:33 UTC c3b51891371e659c92936697c622df1162fb6eff
1 file changed +12 -5
vllm/entrypoints/chat_utils.py
+12 -5
@@ -1193,8 +1193,15 @@ def apply_mistral_chat_template(
1193 **kwargs,
1194 )
1195
1196 - return tokenizer.apply_chat_template(
1197 - messages=messages,
1198 - tools=tools,
1199 - **kwargs,
1200 - )
1196 + try:
1197 + return tokenizer.apply_chat_template(
1198 + messages=messages,
1199 + tools=tools,
1200 + **kwargs,
1201 + )
1202 + # mistral-common uses assert statements to stop processing of input
1203 + # if input does not comply with the expected format.
1204 + # We convert those assertion errors to ValueErrors so they can be
1205 + # are properly caught in the preprocessing_input step
1206 + except AssertionError as e:
1207 + raise ValueError from e