[Bugfix][Gemma4] Keep image bidirectional attention within the sliding window (#47217)
Signed-off-by: Luciano Martins <lucianommartins@users.noreply.github.com> Co-authored-by: Luciano Martins <lucianommartins@users.noreply.github.com>
This commit is contained in:
co-authored by
Luciano Martins
parent
41de1380c2
commit
979f5511d7
@@ -499,6 +499,13 @@ class Gemma4Attention(nn.Module):
|
||||
logits_soft_cap=attn_logits_soft_cap,
|
||||
per_layer_sliding_window=sliding_window,
|
||||
kv_sharing_target_layer_name=kv_sharing_target_layer_name,
|
||||
# Gemma4 vision bidi: on sliding layers the bidirectional image
|
||||
# block must stay within the sliding window, matching HF's
|
||||
# (causal OR blockwise) AND sliding_window. Without this the image
|
||||
# span (~1100 soft tokens at max_soft_tokens=1120) exceeds the 1024
|
||||
# window; the runner keeps the full range and the kernel bounds it
|
||||
# per-query here.
|
||||
mm_prefix_clamp_sliding_window=self.is_sliding,
|
||||
prefix=f"{prefix}.attn",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user