[Bugfix] gemma[2,3] interleaved attention when sliding window is disabled (#17180)

Signed-off-by: Chen Zhang <zhangch99@outlook.com>
This commit is contained in:
Chen Zhang
2025-04-25 19:53:51 -07:00
committed by GitHub
parent c53e0730cb
commit 8de2901fea
3 changed files with 15 additions and 11 deletions
+3 -1
View File
@@ -146,7 +146,9 @@ class Gemma3Attention(nn.Module):
# TODO(woosuk): Add reference to the original HF implementation.
layer_idx = extract_layer_index(prefix)
self.is_sliding = bool((layer_idx + 1) % config.sliding_window_pattern)
self.is_sliding = (getattr(
config, "interleaved_sliding_window", None) is not None and bool(
(layer_idx + 1) % config.sliding_window_pattern))
# Initialize the rotary embedding.
if self.is_sliding:
# Local attention. Override the values in config.json.