Add ModelParameters.enableSwaFull() for SWA KV cache control#275
Merged
Conversation
Add a valueless boolean model launch flag mirroring the existing
enableFlashAttn() / ModelFlag.FLASH_ATTN pattern. Default off.
--swa-full keeps the full-size sliding-window-attention KV cache so the
SWA layers' KV becomes reusable across requests, restoring cross-request
prompt-prefix cache reuse (pairs with setCacheReuse) at ~2x the SWA-layer
KV RAM. Beneficial only for multi-request sessions sharing a prompt
prefix, so it is opt-in.
- ModelFlag.SWA_FULL("--swa-full")
- ModelParameters.enableSwaFull()
- ModelFlagTest: enum->string mapping row + enum count 34->35
- ModelParametersExtendedTest: enableSwaFull + not-by-default tests
- CHANGELOG entry
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SRXbL5RqW3B1XZRea3Rfc7
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
ModelParameters.enableSwaFull()method to enable the--swa-fullflag, which keeps the full-size sliding-window-attention (SWA) KV cache to enable cross-request prompt-prefix reuse (pairs with--cache-reuse).ModelFlag.SWA_FULLenum entry with corresponding CLI flag and documentation.Test plan
ModelParametersExtendedTestcoveringenableSwaFull()and default behaviorModelFlagTestto verify the CLI flag mappingModelFlagTestfrom 34 to 35Related issues / PRs
Checklist
CONTRIBUTING.mdandCODE_OF_CONDUCT.mdhttps://claude.ai/code/session_01SRXbL5RqW3B1XZRea3Rfc7