Skip to content

Fix SWA local layer silent exit by implementing ring buffer#2762

Draft
enlenama wants to merge 1 commit into
google-ai-edge:mainfrom
enlenama:main
Draft

Fix SWA local layer silent exit by implementing ring buffer#2762
enlenama wants to merge 1 commit into
google-ai-edge:mainfrom
enlenama:main

Conversation

@enlenama

@enlenama enlenama commented Jul 8, 2026

Copy link
Copy Markdown

For Sliding Window Attention models, local layers have smaller KV cache (e.g. 1K) than global layers (e.g. 16K). Previously, when decode position exceeded cache capacity, HWKVCacheUpdate returned OutOfRangeError which propagated through the task loop causing silent exit.

Fix: wrap position modulo cache_seq (ring buffer) instead of returning error. Handle prefill wrap-around with split memcpy for cases where the write spans the cache boundary.

For Sliding Window Attention models, local layers have smaller KV cache
(e.g. 1K) than global layers (e.g. 16K). Previously, when decode position
exceeded cache capacity, HWKVCacheUpdate returned OutOfRangeError which
propagated through the task loop causing silent exit.

Fix: wrap position modulo cache_seq (ring buffer) instead of returning
error. Handle prefill wrap-around with split memcpy for cases where the
write spans the cache boundary.
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.

1 participant