Concurrent cold prefills of multiple sessions collapse throughput (1365 t/s solo -> 5-95 t/s each with 2 simultaneous prefills)
Environment
- Mac Studio M5 Ultra, 256 GB, Metal backend
- Qwen3.8-Flash-Next Q4 (
qwen38-q4k, 69.7 GiB resident), BF16 n-grams on disk ds4-server --ctx 2097152 --batched-session 4 --kv-disk-space-mb 153600 --prefill-chunk 8192(+DS4_QWEN4_YARN_FACTOR=2)- Observed on two separate incidents on 2026-10-01, and reproducible on demand
Solo cold prefill (reference, same machine/config)
| prompt | rate |
|---|---|
| 468,960 tok | 1365 t/s (343.7 s) |
| 188,960 tok | 1645 t/s |
| 33,960 tok | 1804 t/s |
Two concurrent cold prefills
Incident 1 — a 282k-token session and a 91k-token session started cold prefill at the same time. Both collapsed to ~5 t/s per chunk-progress entry (aggregate ~10 t/s vs 1365 solo):
chat ctx=0..282540:282540 prefill chunk 27136/282540 (9.6%) chunk=4.78 t/s avg=141.45 t/s 191.846s
chat ctx=0..91087:91087 prefill chunk 512/91087 (0.6%) chunk=4.75 t/s avg=5.40 t/s 94.810sIncident 2 — one ~70k session (turn 1) plus its next turns re-prefilling, two sessions prefilling concurrently. Both at 51-95 t/s:
chat ctx=20480..78997:58517 prefill chunk 36864/58517 (63.0%) chunk=83.92 t/s avg=79.88 t/s 461.510s
chat ctx=25728..70972:45244 prefill chunk 16384/45244 (36.2%) chunk=84.81 t/s avg=81.07 t/s 202.091sNotes:
- The collapse is much worse than a fair time-share: two prefills should give ~600-700 t/s each; instead aggregate drops to 10-170 t/s (8-100x total loss).
- KV disk cache is not the cause: budget is 150 GiB, cache dir was purged between tests, no
disk-cache-fullevictions in the incident-2 window. - Warm/decode behavior while another session prefills is fine (65 t/s decode alongside 500-800 t/s incremental prefill chunks in normal operation).
What I tried
--mixed-prefill-quantum 4096(default 128) — no improvement, concurrent prefills still ran at 83-95 t/s.
Secondary observation (possibly related)
During/after concurrent prefill, the next turn of the same session only hit ~20-25k tokens of KV disk cache instead of the full 70k+ prefix — turn 2 re-prefilled from offset 20480/25728 (chunks are stored with reason=continued, cold_max=30000). Under solo operation, full-prefix hits work as expected (e.g. kv cache hit text tokens=133120 ... load=295.9 ms).
Repro
# two parallel fresh (uncached) 70k+ prompts to /v1/chat/completions
# (stream=false, max_tokens small) -> both prefill at 50-95 t/s instead of ~1400Workaround
We now serialize big cold prefills at a proxy in front of ds4 (FIFO lock, released on first streamed token), which restores solo-speed prefills for queued requests. But it feels like the mixed-prefill scheduler could either serialize large prefills internally or interleave them without the collapse — is there a flag/approach I'm missing, or is this worth investigating in the scheduler?
Thank you for ds4 — it's genuinely impressive engineering; single-session performance is in a different league from anything else on this hardware.
Source: antirez/ds4