Skip to content

fix(cache): honor configured disk cache capacity - #2400

Open
DiadkoShmek wants to merge 2 commits into
abetlen:mainfrom
DiadkoShmek:lezo3-disk-cache-capacity
Open

DiadkoShmek wants to merge 2 commits into
abetlen:mainfrom
DiadkoShmek:lezo3-disk-cache-capacity

Conversation

@DiadkoShmek

Copy link
Copy Markdown

LlamaDiskCache accepts capacity_bytes but opens its diskcache backend without a size_limit.
The backend can therefore evict a state below the requested capacity because it still uses its default 1 GiB limit or a smaller persisted limit.
Pass the requested capacity to diskcache when opening it and disable backend batch culling so the existing manual trim keeps recent states that fit.

Fixes #1402.

The regression uses a real SQLite-backed cache with a small persisted budget, reopens it with a larger requested budget, and checks that a serialized LlamaState which fits the new budget survives.
Adjacent tests verify that oversized states are still evicted and a full cache retains the newest fitting states.

Validation: the new regression fails before the fix; 9 cache/speculative/chat-format/grammar tests and 2 official native version/tokenization tests pass after it; make lint passes.
Built the pinned CPU backend on Linux x86_64 / Python 3.13 with four build jobs.
No model was downloaded; the full model-backed suite was not run locally.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implementation of LlamaDiskCache lacks capacity setting.

1 participant