Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- fix(cache): evict disk cache states one at a time in LRU order by @DiadkoShmek in #2400
- fix(index): include available SHA256 hashes in wheel links by @hakarrr in #2409
- fix(server): close tokenizer config files after reading by @cloudgpuapp in #2422
- fix(cache): preserve disk cache entries on lookup and evict least-recently-used states by @remote-controlled-man in #2423
Expand Down
10 changes: 7 additions & 3 deletions llama_cpp/llama_cache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import time
from abc import ABC, abstractmethod
from typing import (
Optional,
Expand Down Expand Up @@ -146,7 +147,10 @@ def __contains__(self, key: Sequence[int]) -> bool:
def __setitem__(self, key: Sequence[int], value: "llama_cpp.llama.LlamaState"):
print("LlamaDiskCache.__setitem__: called", file=sys.stderr)
key = tuple(key)
self.cache[key] = value
print("LlamaDiskCache.__setitem__: set", file=sys.stderr)
self.cache.cull()
# Public cull() evicts ten entries at once, regardless of cull_limit.
with self.cache._transact(retry=True) as (sql, cleanup):
self.cache[key] = value
print("LlamaDiskCache.__setitem__: set", file=sys.stderr)
while self.cache_size > self.capacity_bytes and len(self.cache) > 0:
self.cache._cull(time.time(), sql, cleanup, limit=1)
print("LlamaDiskCache.__setitem__: trim", file=sys.stderr)
Loading