Skip to content

server: implement disk cache - #32303

Open
ngxson wants to merge 8 commits into
masterfrom
xsn/server_disk_cache_2
Open

ngxson wants to merge 8 commits into
masterfrom
xsn/server_disk_cache_2

Conversation

@ngxson

@ngxson ngxson commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Stacked on top #32154

Supersede #28092

Implement disk cache with running hash

TODO:

Requirements

@github-actions github-actions Bot added documentation Improvements or additions to documentation testing Everything test related server labels Nov 15, 2026
@ngxson
ngxson force-pushed the xsn/server_disk_cache_2 branch from a9af0e1 to 0a68f9b Compare November 15, 2026 08:44
@ngxson
ngxson changed the base branch from xsn/server_slot_sched to master November 15, 2026 08:44
@ngxson
ngxson marked this pull request as ready for review November 15, 2026 08:51
@ngxson
ngxson requested review from a team as code owners November 15, 2026 08:51
@Green-Sky

Copy link
Copy Markdown
Collaborator

requires cache-ram

Can this made to work without ram caching?

@mercant1982

Copy link
Copy Markdown

I tested 4348c46d with an existing Qwen2.5-7B-Instruct Q4_0 model on the CPU backend. The native restart test reaches a disk-cache hit and correctly reuses all 200 prefix tokens, but fails its byte-counter assertion: the file is 11,472,912 bytes and /metrics reports 1.14729e+07 (11,472,900).

The existing Prometheus serializer uses the stream's default six significant digits. Setting its precision to std::numeric_limits<double>::max_digits10 fixes the assertion without changing cache storage or matching. I reproduced the failure twice on the unmodified PR and tested the accompanying one-line patch.

With that patch, all six tested native cases pass: restart, partial prefix match, no match, RAM-first reuse, RAM eviction to disk, and truncated-file rejection. Five test bodies are unchanged; for the eviction case I increased the fixture's RAM limit from 1 MiB to 64 MiB so it holds one Qwen KV state (about 55 MiB), rather than the tiny test model's state. No assertions were relaxed. I did not run the LoRA case.

This is a metrics precision issue, not evidence of corrupt cache data. CPU-only execution, real local HTTP requests, no model download. The upstream fake-timing test setting is retained, so these are correctness checks rather than performance measurements. AI assistance was used to prepare the validation and patch.

Evidence and reproduction: https://gist.github.com/mercant1982/4d666a9a6f8a04fe75f769015957630c

@ngxson

ngxson commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

requires cache-ram

Can this made to work without ram caching?

not sure where do you quote this from

hmm no, basically anything need to be copied to ram first then to disk. but we can improve it in the future

@Davidyz

Davidyz commented Nov 16, 2026

Copy link
Copy Markdown

hmm no, basically anything need to be copied to ram first then to disk. but we can improve it in the future

I hope it's ok to ask here: what's the smallest -cram needed to make disk cache work? Would it need to be big enough to fit at least one prompt entry (with its checkpoints)? Or rather, what's the smallest -cram I need to have in order to make disk cache work properly?

@ngxson

ngxson commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

I believe we will eventually figure out how to handle this plus -cram more efficient, just one prompt away

but it's not the priority of this PR: I'm keeping changes here as minimal as possible

@Green-Sky

Copy link
Copy Markdown
Collaborator

just one prompt away

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

documentation Improvements or additions to documentation server testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants