refactor: update cache insertion method to use cache_type parameter#274
Merged
refactor: update cache insertion method to use cache_type parameter#274
Conversation
- Changed the parameter name from 'checkpoint' to 'cache_type' in MLXLMHandler and related tests for clarity. - Introduced a new PromptTrie class for efficient token sequence management in prompt caching. - Enhanced CacheEntry to include cache_type for better cache management.
for more information, see https://pre-commit.ci
- Simplified the cache insertion method in PromptTrie by using list comprehension for better readability. - Added `ordering` property and `count_by_type` method to `LRUPromptCache` for improved cache type management. - Updated references to `_ordering` to use the new property for consistency and clarity. - Modified model path in the main execution block for updated model usage.
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.
refactor: align LRUPromptCache with upstream mlx-lm implementation
Summary
PromptTrieandPromptTrieResultas standalone classes, matching the upstreammlx_lm.models.cachestructurecheckpoint: boolwithcache_type: str("assistant","user","system") for priority-based eviction orderingpop_prefixesfor cleaner prefix removal when inserting trimmable caches_n_bytes_by_type) and addstats_by_type()method