Repository navigation
Description
Summary. On a 64 GB M5 Pro at stock settings (0.3.5.1, tensorfold serve Vontra/Qwen3.8-27B-MLX-4bit --name bench, DFlash2 pulled), the fitted window is 140,288 tokens. But nothing above roughly 100–125K tokens can be kept for the next turn. The request is served, but storing its checkpoint fails: the store evicts every older checkpoint trying to make room, then refuses the new one anyway (see suggestion 3), so the store ends up empty. The next turn re-prefills everything: 7–11 minutes on this machine. The README says omitted --context targets the window "allowing room to retain a prompt for the next turn". That holds without the drafter and fails with it.
Machine, runtime and fixture are as in #70 (the M5 Pro 64 GB report).
A growing conversation
One conversation, +6,144 fixture tokens per turn, real replies kept, greedy, thinking off. Checkpoint state is from each request's serve.log done line.
| Turn | Prompt tokens | Cached | TTFT | Checkpoint store after the turn |
|---|---|---|---|---|
| 14 | 89,613 | 83,261 | 33.6 s | 2 ckpts, 6.06 GiB |
| 15 | 95,875 | 89,405 | 36.0 s | 1 ckpt, 6.10 GiB, evictions 13→15 |
| 16 | 102,152 | 95,868 | 36.6 s | 0 ckpts, 0.00 GiB, evictions 16 |
| 17 | 108,431 | 2,048 (system block only) | 434 s | 0, 0.00 GiB |
| 18–22 | 114,682 → 139,783 | 2,048 | 466 → 644 s | 0, 0.00 GiB |
| 23 | 146,035 | HTTP 400, "maximum context length is 140,288…" |
With DFlash2 resident, the largest conversation checkpoint this configuration keeps is about 6.1–6.3 GiB, roughly 96–100K tokens.
Single requests (cold, then the same prompt plus one turn)
| 98,337 tokens | 131,106 tokens | 139,922 tokens | 152,210 tokens | |
|---|---|---|---|---|
| + DFlash2 (default) | kept 6.24 GiB; resumed 0.69 s | not kept (0.00 GiB, evictions 5→6); resumed 574 s | not kept; resumed 644 s | over the window |
--drafter none |
kept 9.44 GiB; resumed 0.59 s |
Controls
--prompt-cache-gib 12doesn't help. The fitted context stays 140,288. The 131,106-token request still left the store at 0 checkpoints and 0.00 GiB (evictions 0→3), and it resumed in 575 s. So--prompt-cache-gibisn't the limit. The--drafter nonerun above kept a 9.44 GiB checkpoint under the default 8 GiB--prompt-cache-gib.- A raised budget doesn't help either. With a local patch to 0.78 (see M5 Air 32 GB, Qwen3.8-27B + DFlash2: 0.3.5 refuses at the 70% budget; runs fine at 0.85 (25 GB peak, C=8 58 tok/s) — please allow raising the limit #50), the window grows to 176,128, and a 175,763-token request still isn't kept (resumed in 905 s).
- oQ2 + DFlash2 at stock fits 172,032, and a 171,667-token request isn't kept either.
So the window seems to be sized so one request fits, while keeping that request's checkpoint needs roughly 65 KB per token on top. Measured: 6.24 GiB for 98K tokens, 9.44 GiB for 152K. That extra doesn't fit alongside the drafter.
Suggestions (any one would do)
- When DFlash2 is resident, size the default context so a request and its checkpoint fit. Here that's about 100K rather than 140K.
- Or report a second number at startup, "prompts resume up to N tokens", next to the window. Clients such as Claude Code or Pi could compact before N instead of before the window.
- Or check before evicting. In
PromptMemory.allow_checkpoint(server/prompt_memory.py), the loopwhile self.projected(..., extra_bytes=size) > self.budget: if not self._reclaim(): return Falseevicts retained checkpoints one at a time. Only after the store is empty does it find the new checkpoint still doesn't fit. Checking first whether the checkpoint would fit with the store empty (and returning False without evicting if not) would keep the other conversations' prefixes. That's the "evictions 5→6, then 0 checkpoints" pattern above.
Per-turn serve.log, request bodies and results are in the report's archive.
Activity
benwilson commentedon Sep 29, 2026
Re-tested on 0.3.6.2: still reproduces at stock settings.
--spill-gibis a real mitigation.Same Mac and fixture as the report above. This time: TensorFold 0.3.6.2 (
71377a5), mlx 0.32.3,tensorfold serve Vontra/Qwen3.8-27B-MLX-4bit --name benchwith DFlash2. Fitted context is 140,288, unchanged from 0.3.5.1.Stock 0.3.6.2 behaves exactly like 0.3.5.1. The store goes 6.06 → 6.07 GiB → 0 checkpoints, 0.00 GiB after the 101,937-token turn, and the next turns re-prefill everything. Single requests do the same: a 131,134-token resumed request had 0 cached tokens and took 572 s, and a 139,950-token one had 0 and took 627 s. A 98,365-token resumed request still hits (98,304 cached, 0.60 s).
The same growing conversation with
--spill-gib 16. Each run first sends one separate conversation of about 8.2K tokens (8,225 stock, 8,226 spill), then the session, then that separate conversation again. The prompt-token column is the spill run's; the stock run is within 60 tokens of it on every turn.--spill-gib 16: cached / TTFTtoken_shaas before the sessionWhat spill fixes, and what it doesn't:
checkpoints=0 (0.00 GiB)after each of those turns; in the source that'sallow_checkpointreturning False), so there's nothing to spill. That's why turn 17 resumes from 95,497, not from about 102K. Every later turn resumes from the same 95,497-token spill and re-prefills a tail that grows by about 6K tokens a turn, adding roughly 40 s per turn.A suggested fix building on spill. When
--spill-gibis set andallow_checkpointrefuses a checkpoint for memory, write that checkpoint straight to the spill directory instead of dropping it. Its arrays exist at that moment, and 6 GiB wrote in under a second here. Each turn would then resume from the previous one, not from the last checkpoint that happened to fit, and the curve above would stay flat past 100K. Separately, the two earlier suggestions still apply to users without--spill-gib, which is off by default: size the default window so a request and its checkpoint fit with the drafter resident, or check whether a checkpoint can fit before evicting others to make room.cdepuy commentedon Sep 29, 2026
Adding a 96 GB M3 Ultra datapoint (same 0.3.5.1, same failure shape, different machine) — from a live Hermes session on the box:
--prompt-cache-gib 80.evictionsflat) — the 80 GiB store does hold a ~30 GiB / 193k prefix, because on a 96 GB box there is headroom the 64 GB machine never had.cached=135,641against a 191–192k prompt — and cost 480–503 s TTFT (a 58k-token cold re-prefill) instead of resuming. The store was 16–28 GiB before those turns, i.e. it had evicted + refilled and the newest prefix didn't round-trip.So: on a machine with headroom the trap widens (bigger prefix can be kept longer, then cliff-rotates when two or more conversations interleave or the session grows another ~60–70k); on a 64 GB box it's the documented 7–11 minute every-turn version. Both are "the fitted window admits prompts whose checkpoint doesn't fit, and
allow_checkpointonly discovers that after evicting everything."I'd land on suggestion 3 (check fit before evicting in
PromptMemory.allow_checkpoint) as the minimal fix, with 1 or 2 as the honest UX layer on top: a "prompts resume up to N tokens" second number at startup is what a client (Hermes compression, Claude Code, Pi) actually needs to compact before N rather than before the window — otherwise the client optimizes for the wrong boundary and the user pays minutes on the next turn.Happy to share the full live-log table (14 warm + 2 cold turns at 188–194k with per-request checkpoint GiB / evictions) if useful.
ashhart commentedon Sep 29, 2026
Thanks @benwilson. Your two tables pointed at two separate faults, and both are fixed in 0.3.6.3.
draft. Each prompt token kept 50 KB of the target's hidden states (five layers of 5,120 halves) alive in a lazy MLX
graph, beside the 27B's 64 KB of KV. That peaked exactly when the prompt's checkpoint was copied. The head now
evaluates the drafter's 2,047-row window after each chunk. Our startup probe went from 114.0 to 64.0 KB a token,
and the fitted window didn't move (144,384 on our emulated 64 GB budget; your M5 Pro reported 140,288).
for its own checkpoint then evicted every conversation and still failed: your turns 15, 16 and 17. The scheduler
now lets go of it. @sanjaibalajee's PR fix: preserve prefixes when checkpoint cannot fit #74 also landed, so a copy that can't fit evicts nothing.
I measured it on an M3 Ultra with the 64 GB class emulated (
TENSORFOLD_MEMORY_LIMIT_GB=44.8,--prompt-cache-gib 8) and your checkpoint revisions. One conversation grew by about 6,900 tokens a turn. After a101,950-token cold start (360 s), every turn resumed from the one before, 108,871 through 143,481 tokens, in 38 to
46 s each, and kept its own prompt (6.9 to 9.0 GiB). The next turn, 150,403 tokens, got the HTTP 400 for the
144,384 window. MLX's peak stayed at 40.1 GiB of its 41.8 GiB share. With the taps fix alone, the same run lost its
prefix on every resumed turn and prefilled from zero on the turn after.
That's an emulated budget, not your hardware, so I'd value a rerun of your ladder on the M5 Pro once 0.3.6.3 is
out. If you start with an explicit
--contextpast what can be kept, startup now says so ("requests up to N tokenskeep their prompt for the next turn").
benwilson commentedon Sep 29, 2026
Verified on the M5 Pro 64 GB with 0.3.6.3: fixed. Fresh venv, TensorFold 0.3.6.3 (
1911880), mlx 0.32.2 as pinned,tensorfold serve Vontra/Qwen3.8-27B-MLX-4bit --name benchwith DFlash2, same checkpoint revisions and fixture as before. Stock settings; no--spill-gib, no memory override.Startup. "then 64.0 KB a token" (0.3.6.2: 114.0). "context window 139,264 tokens: the most one request can use in the 44.8 GiB memory budget and still keep its prompt for the next turn." That's 1,024 below 0.3.6.2's 140,288, and the promise now holds.
With an explicit
--context 200000startup says: "requests up to 140,032 tokens keep their prompt for the next turn in the 44.8 GiB memory budget; a longer one is served, and its next turn prefills again". That's exactly the second number a client needs. It's 768 above the default window's 139,264; I didn't test whether a 140K request resumes under that setting.The ladder (cold, then the same prompt plus one turn; 64 reply tokens, greedy):
The store kept each top-of-window prompt:
checkpoints=1 (8.24 GiB)after the 131K request and(8.73 GiB)after 139K.The growing conversation (+6,144 fixture tokens a turn, real replies kept):
Every turn resumed from the one before, and the checkpoint store grew from 6.84 GiB at turn 16 to 8.39 GiB at turn 21. That matches your emulated run: 36.7–43.5 s here against your 38–46 s.
Unchanged costs, all fine: the exact lifetime peak was 43.67 GiB for the ladder (0.3.6.2: 43.67) and 43.57 GiB for the session, and swap stayed flat at 768 MB. Exactness on this build: 8/8 release checks, 4/4 with a real 8,192-token resume, and
bench_concurrent --alone --serial180/180 equal with every solo run equal to"draft": false.One expected limit, for the record. A separate 8K conversation sent before the session was pushed out by the end of it (cached 0 on replay, 19.0 s). That's what finite memory does at stock settings. On 0.3.6.2,
--spill-gib 16brought such a conversation back in 0.44 s, so the two combine well.feat: Flash Next NVFP4 on CUDA, replies that keep decoding while prom…