Skip to content

Fix KV cache handling for Gemma4 26B - #1235

Draft
nsivalin wants to merge 2 commits into
quic:mainfrom
nsivalin:fix/gemma4-26b-kv-fix
Draft

Fix KV cache handling for Gemma4 26B#1235
nsivalin wants to merge 2 commits into
quic:mainfrom
nsivalin:fix/gemma4-26b-kv-fix

Conversation

@nsivalin

@nsivalin nsivalin commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
  • Fixes sliding-window KV cache corruption in QEffGemma4DynamicLayer.update() where physical-slot validity was computed from the wrapped/physical position instead of the logical position, causing attention to read stale/garbage KV data (leading to infinite repetition and non-deterministic output) once a request's sequence length crossed the sliding_window boundary.

  • The fix is scoped to google/gemma-4-26B-A4B-it only (via config.num_experts as the differentiator, leaving the original code path unchanged for all other Gemma4 variants (31B/E2B/E4B).

@nsivalin
nsivalin marked this pull request as ready for review August 5, 2026 03:55
@ochougul

ochougul commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Please keep this PR in draft unless a maintainer approves it. Then you can make it ready for review.

@ochougul
ochougul marked this pull request as draft August 5, 2026 04:38
@quic-hemagnih

Copy link
Copy Markdown
Contributor

Can you fix the LINT issues

@quic-rishinr
quic-rishinr force-pushed the fix/gemma4-26b-kv-fix branch from 814192a to 1bbcf0f Compare August 7, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants