From 609fe1c0d1a6c8c777926e4a48634247144929dd Mon Sep 17 00:00:00 2001 From: Kevin Flansburg Date: Sat, 18 Jul 2026 23:24:03 -0700 Subject: [PATCH] fix(gemma4): prevent attention mask offset overflow (#31672) Co-authored-by: Jimmy Shong <69131491+Jiminator@users.noreply.github.com> --- python/sglang/srt/models/gemma4_mm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/sglang/srt/models/gemma4_mm.py b/python/sglang/srt/models/gemma4_mm.py index 06eefc282..56d033ff4 100644 --- a/python/sglang/srt/models/gemma4_mm.py +++ b/python/sglang/srt/models/gemma4_mm.py @@ -335,7 +335,7 @@ class Gemma4ForConditionalGeneration(PreTrainedModel): bidirectional_attn_masks_list = [] bidirectional_attn_mask_indptr = torch.zeros( - forward_batch.batch_size + 1, dtype=torch.int32, device=input_ids.device + forward_batch.batch_size + 1, dtype=torch.int64, device=input_ids.device ) split_images = []