mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[GH-ISSUE #310] --parallel: per-request timings and cached_tokens can come from another request (shared StrataEngine.last) #117
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#117
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 @pepuscz on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/310
Summary
With
--parallel N, every request'sDONEline is parsed into one shared field,StrataEngine.last.Service.runreads that field after its own stream ends. If another request'sDONEarrives in between, the response can carry the other request's figures:timings(prompt_ms,predicted_msand the per-second rates);usage.prompt_tokens_details.cached_tokens.The
/metricsrequest history and/v1/statuslast_timingsget the same mix-up.Where (v1.1.17)
StrataEngine._parse_donewritesself.last: serve/server.py#L634-L641_generate_multicalls it when this request'sDONEarrives: #L921, #L939Service.runreadsself.engine.lastin itsfinally(#L2240) and buildstimingsfrom it (#L2265-L2268).cached_tokenscomes from those timings (#L2285, #L2502).engine_last0(#L2099) shows that someDONEarrived, not that it was this request's.Why it matters
Under
--parallel, requests decode in lockstep and often finish within a step of each other. In our four-request runs (GLM-5.3-Flash Maya-S24,--parallel 4), the fourglm multi: request N donelines landed within about 0.2 s. A client that reports speed fromtimings(the llama.cpp-style fields), or that checkscached_tokensto confirm prompt reuse, can then show another request's numbers.We did not catch a wrong figure in practice. We gave each of four concurrent requests a different expected cache reuse, and the reported values were right each time. We found this while reading the code to interpret those runs.
Suggested fix
Keep the
DONEfigures with the request. For example,_generate_multicould store the parsed dict on the request's thread (self._tls.last) or pass it back through the request's route.Service.runwould then use that when the engine runs several requests.A test with the mock engine at
multi = 2would cover it: two requests finishing back to back with differentreusedvalues.@mw00 commented on GitHub (Oct 21, 2026):
Thanks @pepuscz - a careful read. Fixed in v1.1.20 as you suggested: each request keeps its own DONE figures when the engine runs several conversations, so
timingsandcached_tokensare always the request's own (with a test of three concurrent requests of different lengths).