[Model] Add block-local attention and YaRN for local layers to Gemma3 (#39823)

Signed-off-by: Philip Monk <169196560+philip-essential@users.noreply.github.com>
This commit is contained in:
philip-essential
2026-04-21 23:34:50 -07:00
committed by GitHub
parent 4254aeb56f
commit 123674879e
7 changed files with 540 additions and 8 deletions
@@ -336,6 +336,12 @@ class Attention(nn.Module, AttentionLayerBase):
)
cache_config.enable_prefix_caching = False
if extra_impl_args.get("chunk_lookback", -1) > -1:
assert self.attn_backend.get_name() == "TRITON_ATTN", (
f"Chunked attention with lookback requires the Triton backend, "
f"but got {self.attn_backend.get_name()}."
)
impl_cls = self.attn_backend.get_impl_cls()
self.impl = impl_cls( # type: ignore[assignment] # impl_cls always returns an AttentionImpl subclass
num_heads,