From d48723b77d0ef2c220051fc53fa58beff9483b50 Mon Sep 17 00:00:00 2001 From: cklxx <1293822641@qq.com> Date: Mon, 29 Dec 2025 20:37:07 +0800 Subject: [PATCH] Clamp logprob tokens with model vocab size (#14414) --- python/sglang/srt/managers/schedule_batch.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/sglang/srt/managers/schedule_batch.py b/python/sglang/srt/managers/schedule_batch.py index 05125bd3a..e49ad99f6 100644 --- a/python/sglang/srt/managers/schedule_batch.py +++ b/python/sglang/srt/managers/schedule_batch.py @@ -1551,6 +1551,9 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin): extend_input_logprob_token_ids = torch.tensor( extend_input_logprob_token_ids ) + # Clamp placeholder or out-of-range token IDs (e.g., multimodal hashes) + # so they stay within the vocab boundary before being sent to GPU. + extend_input_logprob_token_ids.clamp_(0, self.model_config.vocab_size - 1) else: extend_input_logprob_token_ids = None