Skip to content

fix(mistral): honor sliding-window attention - #912

Open
taking-lying-flat wants to merge 1 commit into
FlashML-org:mainfrom
taking-lying-flat:fix/mistral-sliding-window
Open

taking-lying-flat wants to merge 1 commit into
FlashML-org:mainfrom
taking-lying-flat:fix/mistral-sliding-window

Conversation

@taking-lying-flat

@taking-lying-flat taking-lying-flat commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Mistral-7B-v0.1 declares sliding_window=4096, but the Mistral config parser drops it and the attention forward call passes no window specification. Both prefill and decode therefore use full causal attention. At query position 4096, token 0 is still visible even though it should already be outside the window.

Preserve a positive window as an SWA group covering all Mistral layers, and pass it through AttentionSpec to the existing attention kernels.

Declaring that group also selects HybridSWAKVCache, which currently requires both full-attention and SWA layers. Allow a pure-SWA model by retaining an empty full-attention slab for the existing page geometry and rebuild logic; it allocates no full-attention KV data. Without this adjustment, fixing the configuration would make cache construction fail.

For pure-SWA pools with fixed window capacity (naive or an explicit SWA capacity), the remaining per-page cost is only the slot mapping. Automatic sizing would otherwise spend the remaining memory on mappings without increasing KV capacity. Cap that logical page count at max_running_req * ceil(max_seq_len / page_size), while honoring explicit page counts. This cap is limited to automatic sizing in those fixed-capacity, pure-SWA cases.

@taking-lying-flat
taking-lying-flat marked this pull request as ready for review November 16, 2026 01:51
KarrAcaRn pushed a commit to KarrAcaRn/FreeToken-ByAI that referenced this pull request Nov 21, 2026
KarrAcaRn pushed a commit to KarrAcaRn/FreeToken-ByAI that referenced this pull request Nov 21, 2026

This branch has not been deployed

No deployments
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