mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1870] [Bug]: timings.prompt_n ignores the DONE line's prompt_read — prompt_per_second inflated up to ~40,000x when the slot already held the prompt #741
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#741
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sdjger-xiaoniu on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1870
What happened
The
timingsblock on responses reports a prefill rate that is inflated by orders of magnitude whenever the prompt was already in the slot's session cache.cache_n/reusedonly track the conversation cache (which is off in this setup:/metrics→conversation_cache.enabled: false), soprompt_nends up being the whole prompt whileprompt_readsays the engine actually read a few tokens — or one.Measured on 0.1.41,
qwen3.8-flash-next-iq3_s(IQ3_S), 2x RTX 2080Ti 22GB, layer split,--slots 2. A 43,086-token prompt that repeats the previous request (the slot already held the whole prompt):Same pattern on other warm turns:
prompt_n 38922 / prompt_read 1 / prompt_per_second 139056.8, andprompt_n 1295 / prompt_read 1 / prompt_per_second 163924.1. Cold turns are fine (prompt_n 2052, prompt_read 2052, prompt_ms 5339.3 -> 384.3 tok/s).For callers that print
timings(llama-swap and friends) this shows a five-to-six digit tok/s number instead of "almost nothing to prefill", and any dashboard that averages it is off by 100-40,000x.Where it comes from
serve/server.py→request_timings():reusedis the conversation cache's count; the slot-session reuse is reported in the DONE line asprompt_read(field 14, used by/metricshistory and totals viaprompt_tokens_seen()), andreusedstays 0 when the conversation cache is disabled. The function's own docstring says "prompt_n is what was read, cache_n what the conversation cache already held" — so the implementation does not match the stated contract, andserve/test_server.py:2960(prompt_n + cache_n == usage.prompt_tokens) is preserved by derivingcache_nfromprompt_readinstead.Suggested fix
With this, the warm case above reports
prompt_n 1, cache_n 43085, prompt_per_second ~1.8(andcache_nfinally tells the client the truth about how much was reused).Strata version, GPU, OS
0.1.41 · 2x RTX 2080Ti 22GB (layer split,
--slots 2) · Ubuntu 26.04, driver 595.91.07@Niko1221 commented on GitHub (Oct 11, 2026):
Thank you, correct again, and the docstring quote pointed straight at it.
timings.prompt_n was prompt_tokens minus the conversation cache's count, so a prompt the slot's own session already held showed up as fully read. (A request that was moved from the solo path to a slot also got the slot copy's one-token read as its own; it keeps the first read now.) 0.1.43 uses the DONE line's prompt_read when the engine reports it (0.1.36 and newer) and the request was not cancelled: prompt_n is what was read, cache_n is the rest, and prompt_n + cache_n still equals usage.prompt_tokens. Your 43,086-token warm case now gives prompt_n 1, cache_n 43,085 and a rate of about 2 tok/s. Cold turns, older engines and cancelled reads are unchanged. Unit tests are in serve/test_request_accounting.py.