Skip to content

Prefill ram cache fills but is never reused #327

Open

Description

@officiallymarky

Recent builds of Hyperflare which are supposed to have patches to improve prefill host cache seems to have broken it completely.

I have completely filled vram and host cache, yet I have had zero host cache reuse.

[mal@six ~]$ curl -s http://127.0.0.1:8000/metrics | grep '^flare_host_cache_reused_tokens_total'
flare_host_cache_reused_tokens_total 0

Activity

  1. added
    area:caching
    area:selene
    bug
    priority:P2
    triage:investigate
    on Nov 18, 2026
  2. original-el8 commented on Nov 18, 2026

    @original-el8
    Collaborator

    Marked as a host-cache investigation. A zero reused-token counter alone cannot distinguish a failed lookup, an ineligible restore, or admission abandoning a hit. Please include the runtime commit, model/deployment identity, complete serving/cache settings, and metrics before and after a controlled repeated-prefix workload that first pushes the prefix out of GPU cache. Include lookup outcomes/rejections and resident versus host-reused tokens. Main contains #298 and #302, while #319 reports a distinct scheduler stall; neither establishes the cause of this report. This needs its own reproduction before those changes can be blamed or the earlier cache issue #255 closed.

  3. javieratomic commented on Nov 18, 2026

    @javieratomic
    Contributor

    A data point from a different configuration, in case it helps narrow this down: DeepSeek V4.1 Flash at tensor parallelism 3 across three GB10 hosts (one rank per host), disk-only prefix store (--prefix-cache-memory 0 --prefix-cache-disk DIR --prefix-cache-disk-limit 50G), --scheduler-policy throughput, runtime built from 6b68b9b4 (which contains #298 and #302) plus two local serving changes: #323, run with --system-headroom 4G, and a change with no pull request that reads Engram rows ahead of prefill (commit 831bf027, branch engram-prefetch of my fork). Neither changes how prefix records are looked up, stored or restored; #323 does change the system-headroom term of the host-memory budget that sizes the prefix store's intake (selene/src/offload.rs).

    1. A cold prompt of 120,000 random token IDs through /v1/completions with max_tokens 1 takes 32.7 s. flare_host_cache_lookup_outcomes_total{reason="no_match"} rises by 1; afterwards flare_host_cache_stored_total rises by 1 and flare_host_cache_bytes_out_total by 129.7 MB (123.7 MiB), and each host's prefix-cache directory holds one file of that size.
    2. The group is stopped and started again with the same prefix-cache directory. Startup prints Join host prefix stores. 1 of 1 records on every rank; the GPU cache is empty.
    3. The same prompt takes 0.12 s. flare_host_cache_lookup_outcomes_total{reason="admitted"}, flare_host_cache_lookups_total and flare_host_cache_hits_total each rise by 1, flare_host_cache_reused_tokens_total by 120,000 and flare_host_cache_bytes_in_total by 129.7 MB.

    So in this one run (one prompt, one restart) a restore from the disk tier worked on this build once the restart had emptied the GPU cache. The restored request reports cached_tokens 120000, and its token and top-20 log-probabilities are identical to the cold request's. This does not exercise the DRAM tier, or eviction with a full cache, which is what the report describes. Before the restart, repeating the prompt while it was still resident on the GPU added 120,000 to flare_cache_reused_tokens_total, did not raise flare_host_cache_lookups_total and added nothing to flare_host_cache_reused_tokens_total: a prompt wholly resident in the GPU cache is admitted without a host lookup, which is why the workload requested above has to push the prefix out of the GPU cache first.

  4. jcartu commented on Nov 20, 2026

    @jcartu
    Contributor

    @officiallymarky, could you capture just one repeat on the full-cache box? A synthetic prompt is fine; no need to post the prompt or token IDs. Note the build and cache settings, let the prefix finish storing, push it out of GPU cache with unrelated work, then replay the exact same token IDs once on the same process. The useful bit is the /metrics delta immediately around that last request: resident reused tokens, host lookup outcomes by reason, fetched/fetch-failed, bytes in and host-reused tokens. If you have the host rows-thinned/expired and GPU eviction deltas over the churn interval too, that would help. No restart needed. That should tell us which step lost this particular prefix without guessing from lifetime totals.

  5. yatesdr commented on Nov 20, 2026

    @yatesdr
    Collaborator

    Recent selene updates have likely addressed this. It is believed to be an accounting error only. @officiallymarky please rebuild on current main and check again, report back, or close this issue.

  6. officiallymarky commented on Nov 21, 2026

    @officiallymarky
    Author

    Recent selene updates have likely addressed this. It is believed to be an accounting error only. @officiallymarky please rebuild on current main and check again, report back, or close this issue.

    I pulled latest, rebuilt, then filled vram/ram cache, and still showing 0.00% hit rate for ram.

    curl -s http://127.0.0.1:8000/metrics | grep '^flare_host_cache_reused_tokens_total'
    flare_host_cache_reused_tokens_total 0

  7. mayhem4markets commented on Nov 21, 2026

    @mayhem4markets

    Seeing the same as @officiallymarky here. 0% hit rate on RAM prefix cache based on metrics API. GPU KV prefix cache has a 79.7% hit rate. Engram row cache has a 84.8% hit rate. So it's just the RAM prefix cache here. This is for a run where the server has been up for about a week with several billion tokens served.

  8. yatesdr commented on Nov 21, 2026

    @yatesdr
    Collaborator

    We ran a controlled repeat on main (25b4951): one GB10 (SM121), the Qwen3.8-27B core, --max-concurrency 1, --kv-cache-limit context (2,048 GPU KV pages of 128 tokens), and a DRAM tier.

    1. Send prompt A (22,883 tokens), then prompts with no shared prefix totalling 589,467 tokens, more than twice the GPU KV pool, then A again.
    2. With --prefix-cache-memory 40G (a 40.9 GiB tier), the replay of A restored 22,878 tokens from DRAM: flare_host_cache_hits_total +1, flare_host_cache_reused_tokens_total +22,878, flare_host_cache_restores_total{tier="dram"} +1, and cached_tokens 22,878. The request (one output token) took 0.17 s instead of 9.36 s.
    3. With --prefix-cache-memory 16G, the same steps restored nothing. The other prompts stored 21.2 GB in a 16.9 GiB tier, the tier dropped records (flare_host_cache_dropped_total{tier="dram",reason="end_of_chain"} +4), and A's lookup ended no_match.

    So on main the counter counts real restores, and a zero means no restore happened. One way to get zero is a DRAM tier that later traffic fills before a prefix is asked for again; we have not shown that this is what happens on your hosts. These would settle it, from a running server:

    • the commit or release, the model, the tensor-parallel layout, and the --prefix-cache-memory value;
    • from /metrics: flare_total_kv_pages, flare_kv_page_tokens, flare_host_cache_slots_total, flare_host_cache_memory_bytes, flare_host_cache_stored_total, flare_host_cache_dropped_total (all reasons), flare_host_cache_lookups_total and flare_host_cache_lookup_outcomes_total (all reasons).
  9. yatesdr commented on Dec 3, 2026

    @yatesdr
    Collaborator

    Two open PRs directly address upstream causes that match a high GPU KV hit rate with zero host RAM reuse:

    Once #655 and #674 merge, please retest and include the /metrics counters listed above (flare_host_cache_lookup_outcomes_total, flare_host_cache_dropped_total, flare_host_cache_stored_total, flare_checkpoint_skips_total) if you still see zero host reuse.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cachingarea:selenebugpriority:P2triage:investigate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions