Skip to content

Fix multi-token attention mask in RotatingKVCache - #1978

Open
robertcprice wants to merge 1 commit into
ml-explore:mainfrom
robertcprice:rotating-cache-keep-mask
Open

robertcprice wants to merge 1 commit into
ml-explore:mainfrom
robertcprice:rotating-cache-keep-mask

Conversation

@robertcprice

@robertcprice robertcprice commented Oct 15, 2026 •

Copy link
Copy Markdown

The RotatingKVCache attention mask was incorrectly masking out the keep sink tokens during chunked prefill. By setting the sliding window width to max_size - keep, we ensure that the query attends to exactly max_size tokens: the keep prefix tokens plus the most recent max_size - keep tokens. I've verified the fix with unit tests, confirming that the logit alignment between step-by-step decoding and chunked prefill is now consistent.

I used an AI coding assistant to help isolate the mask overlap bug and write the corresponding unit tests, while I reviewed and verified all logic and results.

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