Repository navigation
Conversation
Contributor
Author
|
@flare-autobot review the pushed changes. The per-request metrics PR is new; the other two carry review fixes. |
WynnD
force-pushed
the
metrics/per-request-metrics
branch
from
November 27, 2026 05:02
fd5c67e to
d6d7c7f
Compare
Collaborator
|
A case file has been opened for 553. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Collaborator
Review StoppedAuto-Review halted due to finding: It is low value or does not align with the project charter. |
Collaborator
Review StoppedAuto-Review halted due to finding: It is low value or does not align with the project charter. |
OpenAI clients and proxy gateways that display per-request speed read timings
from the response body. Flare reports aggregates on `/metrics` but no
per-request timing, so a gateway cannot show prompt or decode tokens per second,
and billing or SLA tooling has to time the HTTP round trip itself, which mixes
queueing and client transfer into the number. vLLM answers this with a `metrics`
object on the response, enabled by `--enable-per-request-metrics`, and consumers
already read it. Matching its object and placement lets those consumers read
Flare responses unchanged. The HTTP layer already sees every offered token, so
the timings are recorded there without changing the runtime or prepared core.
The option is `--enable-per-request-metrics`, or `[server] per_request_metrics =
true` in the configuration file; both default to off. `generate` records the
instant of the first and last output token, the first non-empty answer or
reasoning frame on a stream, and the committed output-token count. A
non-streaming OpenAI Chat or Completions response carries a top-level `metrics`
object; a streaming response carries it only on the final usage chunk, so the
stream needs `"stream_options": {"include_usage": true}`, as vLLM requires. With
`n` choices the object is null, again as vLLM does, because one sequence's timing
cannot describe the whole response. The object uses vLLM's field names:
`time_to_first_token_ms`, `time_to_first_content_token_ms` (streaming only),
`generation_time_ms`, `queue_time_ms`, `mean_itl_ms`, and `tokens_per_second`.
Measurement contract: every interval starts at HTTP admission. vLLM measures from
scheduler admission, which the HTTP layer cannot observe, so
`time_to_first_token_ms` here includes admission-to-scheduler time and
`queue_time_ms` is null rather than a scheduler-queue value;
`tokens_per_second` covers admission to the last output token. Any interval the
request did not produce is null, and Anthropic Messages and OpenAI Responses are
unchanged. The cost is one clock read per output token while the option is on,
and none while it is off.
The claimed result is opt-in per-request timing in OpenAI response bodies, with
no change to serving behavior, the runtime, or the wire format when the option
is off.
Evidence: `cargo test --locked --release --manifest-path helios/Cargo.toml
--target-dir ~/.cache/hyperflare-target --features runtime-core,server --lib --
per_request_metrics` passes three tests. `per_request_metrics_report_vllm_timings_when_enabled`
checks a two-token non-streaming chat: positive first-token, generation, and
throughput values, a finite mean inter-token latency, null content-token and
queue fields, and no `metrics` key when the option is off.
`per_request_metrics_ride_the_final_usage_chunk` checks that the object arrives
on the usage chunk with an empty `choices` array and the content-token interval
present, and that a stream without usage reporting carries no object.
`per_request_metrics_suppress_multi_choice_responses` checks that two choices
return a null object with both choices present. The whole `server::` filter ran
326 tests with one failure,
`messages_image_hints_end_after_expansion_for_text_and_segmented_templates`,
which needs `FLARE_TEST_TEMPLATE_DIR` from `tests/frontend/prepare_templates.py`
and has no prepared templates on this host.
`cargo test --locked --release --manifest-path flare/Cargo.toml --lib --
per_request_metrics` passes the settings test over the absent, true, and false
`[server] per_request_metrics` values, and
`cargo test --locked --release --manifest-path flare-cli/Cargo.toml --bin flare --
per_request_metrics` passes the flag test. Windows builds and live gateway
verification are left to CI and to the caller.
Signed-off-by: Wynn Drahorad <wynn.drahorad@gmail.com>
Design-Signed-Off-By: Claude Opus 5.5 (omp agent); design-review=eb2f
WynnD
force-pushed
the
metrics/per-request-metrics
branch
from
November 27, 2026 19:36
d6d7c7f to
8ffcc72
Compare
WynnD
marked this pull request as draft
November 27, 2026 20:31
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/metricsreports server aggregates, not the timing of one request, so a client,gateway, or billing and SLA tool cannot report prompt or decode speed per
request; timing the HTTP round trip instead mixes queueing and client transfer
into the number. vLLM answers this with a
metricsobject on the response,enabled by
--enable-per-request-metrics, and gateways already read it.Emitting the same object lets those consumers read Flare responses unchanged,
and the HTTP layer already sees every offered token, so the timings are recorded
there without touching the runtime or the prepared core.
What changed
The option is
--enable-per-request-metrics, or[server] per_request_metrics = true; both default to off.flare runand the desktop controller pass it toServerConfig, whoseBootstraprejects a non-boolean value.helios/src/server/http.rs:RequestTimingrecords HTTP admission, the first and last output token, thefirst non-empty answer or reasoning frame on a stream, and the committed
output-token count.
GenerationEvent::TokenandGenerationEvent::LogprobTokenadvance it;
GenerationEvent::Finishedadds the committed count.metricsobject. A streaming response gains it on the chunk that reportsfinish_reason, which is the chunk a gateway parses for completion.time_to_first_token_ms,time_to_first_content_token_ms,generation_time_ms,queue_time_ms,mean_itl_ms, andtokens_per_second.Measurement contract:
scheduler boundary, so
queue_time_msis always null, andtokens_per_secondincludes queue and prefill time; it is a response-body timing, not the engine's
decode rate.
time_to_first_content_token_msis streaming-only and null for non-streamingrequests, matching vLLM.
mean_itl_msandgeneration_time_msare null for a single-token response;fields are null when the request produced no such interval.
nchoices, one object describes the whole response.while it is off.
docs/api.mddocuments the fields and placement;docs/cli-design.mddocumentsthe flag and the configuration key.
Claimed result
Opt-in per-request timing in OpenAI response bodies. With the option off, the
wire format, the runtime, and the cost are unchanged; no performance claim is
made for either state.
Evidence
cargo test --locked --release --manifest-path helios/Cargo.toml --target-dir ~/.cache/hyperflare-target --features runtime-core,server --lib -- per_request_metricspasses:per_request_metrics_report_vllm_timings_when_enabled: a two-tokennon-streaming chat reports a positive first-token interval, a positive
generation interval and throughput, a finite mean inter-token latency, and
null content-token and queue fields; the same request without the option has
no
metricskey.per_request_metrics_ride_the_final_stream_chunk: a streamed chat carries theobject on a data chunk with the content-token interval present.
cargo test --locked --release --manifest-path flare/Cargo.toml --lib -- per_request_metricspasses the settings test over absent, true, and false[server] per_request_metricsvalues, andcargo test --locked --release --manifest-path flare-cli/Cargo.toml --bin flare -- per_request_metricspasses the flag test.The whole
server::filter ran 325 tests with one failure,messages_image_hints_end_after_expansion_for_text_and_segmented_templates,which needs
FLARE_TEST_TEMPLATE_DIRfromtests/frontend/prepare_templates.pyand has no prepared templates on this host.
Live verification on the local two-GPU DeepSeek-V4.1-Flash setup: this branch
was cherry-picked onto the validation tree that serves that model (fork commit
5ffe4d54, which that model's core requires for its engram encoding, plus #548and #549), the image was rebuilt,
--enable-per-request-metricswas added to thellama-swap entry, and llama-swap reloaded its configuration. A non-streaming chat
with a 35-token prompt and
max_tokens16 returnedmetricswithtime_to_first_token_ms4925.84,generation_time_ms67.72,mean_itl_ms4.51,tokens_per_second3.20, and nulltime_to_first_content_token_msandqueue_time_ms; llama-swap recorded 7.11 prompt tokens per second and 221.5decode tokens per second for that request. A streaming chat with
stream_options.include_usagecarriedmetricson its final chunk withtime_to_first_token_ms473.78,time_to_first_content_token_ms473.79,generation_time_ms1920.16, andmean_itl_ms128.01; llama-swap recorded 7.81decode tokens per second for it.
That validation tree also carried an unpublished local
timingsobject, so thegateway's numbers are not attributable to this PR alone. Where the two objects
meet, their intervals agree: this state's
time_to_first_token_msequals thelocal object's
prompt_ms, andmean_itl_msequals itspredicted_per_token_ms.One limitation follows from that local object rather than from this PR: it
reports
prompt_nas the uncached prompt count while llama-swap subtractscache_nfrom it again, so a fully cached stream row shows a negative promptrate. A tree that emits only this PR's
metricsobject gives llama-swap theprompt count from
usage.Not run here: Windows builds and the full helios and flare suites, which CI
covers.
This PR does not depend on #548 or #549 and changes no code they touch; it merges
in any order with them.
Discord: oystersmiles