Refactor: review improvements for KV cache quantization#72
Closed
janhilgard wants to merge 1 commit intowaybarrios:mainfrom
Closed
Refactor: review improvements for KV cache quantization#72janhilgard wants to merge 1 commit intowaybarrios:mainfrom
janhilgard wants to merge 1 commit intowaybarrios:mainfrom
Conversation
Collaborator
Author
|
Hey @waybarrios — ideally I'd push these changes directly into #62, but I don't have write access and |
Owner
|
@janhilgard Sorry for the late. Being pretty busy. but now you have access!! :) |
Collaborator
Author
|
Thank you very much @waybarrios! Really appreciate it 🙏 |
- Add `_maybe_dequantize()` method to replace 5 repeated dequantize patterns in fetch() - Use explicit `isinstance(QuantizedKVCache)` instead of duck-typing in estimate_kv_cache_memory() - Use normal QuantizedKVCache constructor instead of __new__() bypass in _trim_cache_offset() - Extract `_add_kv_cache_quantization_args()` to deduplicate 4 CLI args in serve/bench parsers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f805997 to
36164d1
Compare
Collaborator
Author
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
_maybe_dequantize()helper method to eliminate 5 repeated conditional dequantize blocks infetch()(DRY)hasattr/isinstance(keys, (list, tuple))check with explicitisinstance(layer_cache, QuantizedKVCache)inestimate_kv_cache_memory()— more robust and self-documenting__new__()bypass with normalQuantizedKVCache(group_size=..., bits=...)constructor in_trim_cache_offset()— forward-compatible if__init__adds new attributes_add_kv_cache_quantization_args()helper to deduplicate identical CLI argument definitions betweenserveandbenchparsersTest plan
test_kv_cache_quantization.pytests passruff checkclean on changed files (pre-existing N806 on_QKVCacheunrelated)🤖 Generated with Claude Code