mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #104] [MERGED] The Monitor's live tok/s is a rate over the last seconds, not the mean since the first token #2456
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#2456
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/104
Author: @xyzzing
Created: 9/29/2026
Status: ✅ Merged
Merged: 9/29/2026
Merged by: @Niko1221
Base:
main← Head:fix/live-token-rate📝 Commits (1)
b6e1176The Monitor's live tok/s is a rate over the last seconds, not the mean since the first token📊 Changes
2 files changed (+128 additions, -4 deletions)
View changed files
📝
serve/server.py(+35 -4)📝
serve/test_server.py(+93 -0)📄 Description
What
GET /metrics → live.tok_swasgenerated / (now − first_token)— the mean since the first token, not a rate. Its first sample is1/elapsed, so the Speed card, the header pill and thetok_ssparkline showed impossible numbers for the first instant of every answer and then undershot for the first second (one token counted over up to a second of elapsed time).Against a mock engine paced at a known 25.0 tok/s, sampling
GET /metricsthe way the web app does:that is 1092× the engine's own rate before, 1.12× after.
What changed
live.tok_sis the rate over the lastRATE_WINDOW_S(2 s) of(time, generated)samples taken per token. While a request is younger thanRATE_MIN_SPAN_S(0.25 s) there is no rate yet: the mean so far is reported with its span floored there, so no sample can diverge._tok_s_mean()and is still reported —live.tok_s_mean, andstatus.tokens_per_s_meanon/status. Nothing is lost.DONEline (engine death, error, client disconnect) used to record the previous request'sgenerated/decode_msas its owndecode_tok_s. The engine's counters are now trusted only when itsDONEreplaced the object captured at request start, and the row also carries the engine's own token count asengine_generated.serve/webneeded no change.The engine's own per-request counters — what the Speed card shows for "last request", and the only number to trust for a finished request — are untouched. The server's progress and
done:log lines keep their whole-request mean on purpose: they describe a finished request, not a live rate.Tests
serve/test_server.py::LiveRate, no GPU and no pack:test_the_live_number_is_a_rate— aMockEngine(delay_s=0.02)(50 tok/s) with/metricspolled at 10 ms: the live feed never exceeds 4× the engine's own rate, and an idle server reportstok_s: None.test_a_request_without_a_done_keeps_no_engine_counters— an engine that dies mid-answer recordsdecode_tok_s: Noneinstead of the stale990.0 tok/sit used to inherit from the mock's previous request.Both fail on the unpatched server (the second with exactly
990.0, the number above) and pass with the change. The rest of the suite is unaffected:Notes
Found while porting the engine to HIP/ROCm on a Radeon RX 7900 XTX (gfx1100, Linux); this readout was the first thing there that looked wrong, and the fix is platform-independent. The measurements above were taken by replaying a paced
MockEnginethrough the unmodifiedserve/server.pyand through the patched one.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.