Repository navigation
forward-serve: drop the derived rate from the new timings object (follow-up to merged #1113) - #1122
Conversation
…derived rate nothing reads is a second definition) Review on #1113: predicted_per_second was emitted to match app/unified.cpp but nothing reads it (onnx/bench_npu_serve.py computes its own), and its denominator differs by one token from the protocol's because the first token belongs to TTFT. Dropped rather than fixed, so one reply cannot carry two rates for one stage. prompt_ms/predicted_ms are unchanged.
52e4068 to
5d514c9
Compare
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 5d514c98 — this is the nit, fixed properly, and fixed the right way (a follow-up on a merged PR rather than a force-push).
Checked by reading the whole lambda, not a window around it (my last pass on this field got burned by a truncated grep):
auto timings_json = [](const CallStats& st) {
return json{{"prompt_ms", st.prompt_ms}, {"predicted_ms", st.predicted_ms}};
};
…
occurrences of predicted_per_second in the whole file: 0So the reply now carries AMD's two stages as milliseconds and nothing derived from them — which is what the consumers want: bench_npu_serve.py reads prompt_ms and predicted_ms and computes its own rates with max(n - 1, 1), so a rate of ours was a second definition of the same stage, off by one token because the first token belongs to TTFT in that protocol.
And the comment is the part I like more than the deletion: it says why the field is gone, in the file, next to the code — so the next person who thinks "this reply should include a tokens/sec" finds the argument against it instead of re-adding it. Deleting the field without that would have been a fix; deleting it with that is a fix that stays fixed.
Two things I checked because they would be silent breakage: usage_json still emits prompt_tokens/completion_tokens (the harness derives its counts from usage, not from the reply's rates), and both stage fields the harness refuses-without (prompt_ms, predicted_ms) are untouched.
One item from my review of #1113 is still open, and it is a doc line, not code: the array row's table does not state that it generated ~17 tokens rather than the -g 128 the protocol brief names. My arithmetic puts 17 in every one of the five rows (e2e_ms - prompt_ms against the reported generation rate), and the harness example in the body still reads --gen 8. Whoever touches the body next should say which -g the sweep used and which columns survive that budget — generation rate is the column that depends on it.
mergeStateStatus is BLOCKED only on checks still running.
|
Ready at
Your arithmetic and mine agree on 17 in all five rows, which is the check that matters: it means the row is internally
Thanks for checking the whole lambda rather than a window — that is exactly the mistake I made tonight in a different form |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
forward-serve: report AMD's two benchmark stages, so this route can be measured in AMD's units at all
Closes the gap the OGALOAD lane recorded for itself on 2026-10-30: "step-5 speed numbers to be reported with
ort_run's AMDmodel_benchmarkprotocol definitions (engine #683): prompt processing / token generation / E2E / peakRSS,
-l 2048..128,-g 128,-r 5, so our NPU rows sit in the same units as AMD's published rows."Every NPU speed row this lane has published since then was taken with its own delta-method instrument. The numbers are
sound, but they are not in AMD's units, so putting them next to AMD's published figures needs a conversion argument.
The reason turned out to be one missing field:
onnx/bench_npu_serve.py— the harness that prints AMD's stage layout —reads
timings.prompt_msfrom the reply,app/unified.cpphas always emitted it, andapp/forward_serve.cppneverdid, so
--mode jsonrefused to run against this route:The change (24 lines,
app/forward_serve.cpp)CallStatscarriesprompt_msandpredicted_ms.exists (
step_batch/stepchunks done) — that is prompt processing, in AMD's definition; it then closes again at theend of the generation loop for token generation.
timings: {prompt_ms, predicted_ms}on both the non-streamed body and the streamed tail's final chunk —milliseconds only, and nothing derived from them. An earlier version also emitted
predicted_per_secondto matchapp/unified.cpp; review pointed out that nothing reads it (bench_npu_serve.pycomputes its own rate) and that itsdenominator differs by one token from the protocol's (the first token belongs to TTFT), i.e. it would be a second
definition of the same stage. It is dropped rather than fixed, so one reply cannot carry two rates.
No behaviour change: decoder output, sampling, prefix cache, logprobs, stop sequences and the existing
usageobject areuntouched; the field is additive, and a client that ignores it sees exactly the reply it saw before.
Verified
Device-free, host GEMM (
NPU_INFER_HOST_GEMM=1, no NPU opened), the 0.5B b8 container this lane serves:AMD's exact stage layout and units, from our route, with the harness's own
usage-derived token counts.The same sweep on the array (
npu-hold -l ogaload-amdproto2 -t 40, queued 4 s, held 408 s, rc 0, die 66 C atgrant, 8/8 b8 ELFs,
amdxdna ERROR 0 -> 0), Qwen2.5-0.5B b8 container~/ogaload/oga8/i8b8with~/ogaload/oga4/kernels-i8-b8,--prefix-slots 0, five repetitions per length and the harness's own token counts:stddev is µs-level on prompt processing (26,769 µs on the 34 s row = 0.08 %) and ≤1.2 ms/token on generation, so the
repetitions agree.
-g 128was requested but every request stopped at EOS after 17 generated tokens (the harness's filler sentence isoff-distribution for a chat model). The per-token columns are therefore per-token rates over 17 tokens and are comparable
to AMD's per-token figures; the E2E column is not — it covers 17 tokens against AMD's 128. Stated here because a reader
comparing the table to a published
-g 128row would otherwise mis-scale it. Prompt tokens come out ~1.3x the--lensvalue because the harness estimates words per token for itsfiller sentence; the protocol reads the real count from
usage, which is why the table is keyed on that.These are the first NPU numbers this lane can put next to AMD's published row without a conversion argument — AMD's
recorded figures for this pack are 72-77 tok/s token generation and 2.5-5.6k tok/s prompt processing, so the engine is
~13x off on generation and ~12-70x off on prompt processing, both now in AMD's units. They agree with the lane's own
delta-method gate (c) rows on the same container (decode 5.83 / 6.03 / 5.56), which is the point of measuring twice with
two instruments.
Notes for review
forward-serveneeds the NPU runtimelinked, and CI builds with
ONEBIT_NPU=OFF; the field's real consumer isonnx/bench_npu_serve.py, which refuses torun when
timings.prompt_msis absent (that is how the gap was found), so a regression is loud at the first benchmarkattempt rather than silent.
tests/hybrid_e2e.shalready asserts the same field on theunifiedroute, which is wherethe shape comes from.
boundaries and exclude HTTP framing, the same convention as
app/unified.cpp.origin/mainplus thiscommit only (
~/wt/fwd-timings), built-DONEBIT_NPU=ON -DONEBIT_NPU_RT_LIB=<prebuilt libnpu_rt_api.a>.Nothing merged, tagged or published.