kv-cache: resolve TURBO_LAYER_ADAPTIVE mode per cache construction - #354
Merged
TheTom merged 1 commit intoSep 6, 2026
Conversation
adaptive_mode was a function-local static, so it was computed once from whichever cache was constructed first in the process and then reused verbatim for every later construction regardless of that cache's own type_v - a real problem for iswa/MTP setups that build more than one kv_cache with different type_v in the same process, and for anything that sweeps --cache-type-v (e.g. llama-bench). Hoisted the mode resolution out of the per-layer loop into a per-construction local computed once per llama_kv_cache::llama_kv_cache call, before the loop starts, so every layer in a given cache sees the same mode and every new cache re-resolves it against its own type_v. Split out of PR TheTom#326 per review at TheTom#326 (comment) Assisted-by: Claude Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
TheTom
merged commit Sep 6, 2026
d7afd02
into
TheTom:feature/turboquant-kv-cache
9 of 24 checks passed
Owner
|
Merged. Per-construction resolution is the right shape; the second cache in an iswa or MTP process now gets its own mode instead of inheriting whichever was built first. The only visible change is that the auto-enable log line can print once per cache, which is fine. |
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
Split out of #326 per review comment: #326 (comment)
adaptive_modeinllama_kv_cache::llama_kv_cachewas a function-localstatic, so it was resolved once from whichever cache was constructed first in the process and then reused verbatim for every later construction, regardless of that cache's owntype_v. This is a real bug for iswa/MTP setups that build more than onellama_kv_cachewith differenttype_vin the same process, and for anything that sweeps--cache-type-v(e.g.llama-bench).kv_adaptive_mode), computed once perllama_kv_cache::llama_kv_cachecall before the layer loop starts.type_v(the fix).Test plan
llamatarget)🤖 Generated with Claude Code