You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): paged backend declines every partial prefix adoption, and APC+paged loses even multiturn reuse #225
Found during a cross-version server memory-footprint measurement (v0.1.4 vs main, 2026-06-12) using scripts/bench_memory_footprint.py (commit 18c88c1). Method: one fresh mlxcel serve process per (config, scenario), fixed HTTP workloads at temperature 0, sampling the process phys-footprint via /usr/bin/footprint at 2.5 s (RSS does not see MLX Metal buffers at all). Model: llama-3.2-1b-4bit on M1 Ultra, --max-batch-size 8. Scenarios: idle, shared_prefix_burst (8 concurrent requests sharing a ~3.7k-token system prompt), seqshare (same prefix, 8 sequential requests), multiturn (one conversation, 8 turns), churn (32 distinct prompts). Run-to-run noise: idle/multiturn within 0.5 percent, burst/seqshare/churn peaks within 10 to 25 percent.
Problem
try_adopt_cached_prefix (src/server/batch/scheduler.rs, paged branch around line 1290) declines paged adoption whenever matched_len < paged_seq_len, with partial adoption marked as deferred. Measured consequences over HTTP:
Divergent sibling requests sharing a long system prompt never adopt on the default backend (decode_storage auto resolves to paged when batching): burst and seqshare report cached=0 for every request.
With --apc-enabled, APC clamps matched_len to a block boundary, so matched_len < entry_len holds for virtually every lookup. Result: paged plus APC adopts nothing at all, including strict multiturn continuation that works without APC (measured: multiturn cached tokens 11067 without APC, 0 with APC).
Fix sketch
Implement partial adoption for paged detached sets: floor matched_len to the pool block boundary, adopt the covered block chain (reusing the existing refcount/pin machinery), release the tail blocks, set the logical length and per-layer offsets, and let the prefill loop re-prefill the divergent tail. Release pins on every decline path. Mind the known trim_tokens front/back asymmetry.
Acceptance criteria
APC + paged shows cached>0 for burst, seqshare, and multiturn over HTTP.
Outputs byte-identical to a cold prefill (extend the real-model paged_prefix_share_parity style test to a partial match).
seqshare footprint for APC+paged at or below APC+dense on the bench harness.
Related
Filed together from the same measurement: #224, #226, #227, #228.
Activity
perf: presize paged pool per prefill span and eval grown slabs eagerly (
fix: account real paged pool bytes in the prompt-cache ledger and sta…
feat: non-consuming clone-and-pin paged adoption (#232)
perf: presize paged pool per prefill span and eval grown slabs eagerly (
fix: account real paged pool bytes in the prompt-cache ledger and sta…
feat: non-consuming clone-and-pin paged adoption (lablup#232)