Skip to content

Commit bb6d8c2

Browse files
authored
[Bugfix] Catch and log invalid token ids in detokenizer #2 (vllm-project#26445)
Signed-off-by: Nick Hill <nhill@redhat.com>
1 parent ebf6ef1 commit bb6d8c2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vllm/v1/engine/detokenizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ def decode_next(self, next_token_id: int) -> str:
227227
def _protected_step(self, next_token_id: int) -> Optional[str]:
228228
try:
229229
token = self.stream.step(self.tokenizer, next_token_id)
230-
except OverflowError:
230+
except (OverflowError, TypeError):
231231
# Handle rare observed overflow, still to be diagnosed.
232232
# See https://github.com/vllm-project/vllm/issues/21951.
233-
logger.exception("Encountered invalid token id: %d", next_token_id)
233+
logger.exception("Encountered invalid token id: %r", next_token_id)
234234
token = None
235235
except Exception as e:
236236
if not str(e).startswith(INVALID_PREFIX_ERR_MSG):

0 commit comments

Comments
 (0)