fix: correct off-by-one in vocab boundary check for token validation (#22367)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: fzyzcjy <ch271828n@outlook.com>
This commit is contained in:
Ricardo-M-L
2026-06-09 15:24:39 -07:00
committed by GitHub
co-authored by Claude Opus 4.6 fzyzcjy
parent fde4004429
commit 7f730edfdc
2 changed files with 83 additions and 1 deletions
+1 -1
View File
@@ -1330,7 +1330,7 @@ class Req(ReqDllmMixin):
def _check_vocab_boundary_finish(self, new_accepted_tokens: List[int] = None):
for i, token_id in enumerate(new_accepted_tokens):
if token_id > self.vocab_size or token_id < 0:
if token_id >= self.vocab_size or token_id < 0:
offset = len(self.output_ids) - len(new_accepted_tokens) + i
if self.sampling_params.stop_token_ids:
self.output_ids[offset] = next(