Repository navigation
Conversation
`/metrics` reports counters, gauges, and the dashboard snapshot, but no distribution of request latency, so an operator cannot see tail latency, queue delay, prefill time, decode rate, or prompt size from a scrape, and generic Prometheus process dashboards have nothing to read. Issue NVIDIA#536 requests histograms for per-request latency and prompt size together with the standard process_* metrics. Fixed-bound histograms answer those questions without per-request storage, and the runtime already counts completions in one place, so recording the histograms there keeps the counter and the observations together. The runtime now keeps lifecycle instants on `Incoming` so they survive preemption: `Worker::reserve_and_pack` stamps the first model step that includes a request, `Worker::complete` stamps its first and last committed generated tokens, and `Metrics::request_completed` records queue, prefill, decode, time per output token, and prompt tokens while incrementing `requests_completed_total`. Both call sites that incremented the counter directly now call `request_completed`, so the counter cannot drift from the histograms. Cancelled and failed requests stay out of the request histograms. The generation handler records `request_e2e_seconds` when delivery completes a successful response, except for `/v1/messages/count_tokens`, and the existing first-response sampler now also observes `time_to_first_response_seconds` when it offers answer or reasoning text; its median gauge is unchanged. On Linux, `server/metrics/process.rs` derives `process_cpu_seconds_total`, `process_resident_memory_bytes`, `process_virtual_memory_bytes`, `process_start_time_seconds`, `process_open_fds`, and `process_max_fds` from procfs and `RLIMIT_NOFILE`, omitting only the metrics whose source cannot be read; other platforms write nothing. Names, types, and endpoints are documented in `docs/api.md`, and the JSON snapshot is unchanged. The claimed result is observability only: latency, prompt-size, and process resource distributions become scrapeable with no change to serving behavior. Evidence: `cargo test --locked --release --manifest-path helios/Cargo.toml --target-dir ~/.cache/hyperflare-target --features runtime-core,server --lib -- server::runtime::phase_tests` passed 109 tests, including `reasoning_budget_cuts_or_plainly_continues_with_exact_history_and_usage` (a preempted and readmitted request records one queue, prefill, and prompt-token observation), `first_response_http_nonstream_records_only_when_completed_body_is_offered`, `first_response_http_stream_excludes_pretext_failures_and_unpolled_bodies`, and `metrics_route_serves_prometheus_or_json_without_the_api_key`, whose text scrape carries the first-response histogram, an empty request histogram, and a resident memory gauge. `server::metrics::` passed 20 tests, including `request_histograms_bucket_completed_request_timings`, `render_reports_process_memory_descriptors_and_start_time`, and `parse_stat_reads_fields_after_a_parenthesized_command_with_a_paren`. The whole `server::` filter ran 326 tests with one failure, `messages_image_hints_end_after_expansion_for_text_and_segmented_templates`, which requires templates from `tests/frontend/prepare_templates.py` through `FLARE_TEST_TEMPLATE_DIR`; no templates are installed on this host, so that test is unrun here. Windows builds and the rest of the helios suite are left to CI. Signed-off-by: Wynn Drahorad <[email protected]> Design-Signed-Off-By: Claude Opus 5.5 (omp agent); design-review=eb2f
llama-swap derives the prompt and generation token rates of its activity table only from a llama.cpp `timings` object or a vLLM `metrics` object inside the proxied response, in the body or in an SSE event; Flare reports `usage` only. Every Flare-served request therefore shows unknown rates and its input-token column reports the whole prompt rather than the tokens the model prefilled, even though the runtime already measures both intervals for its own histograms. Helios already holds the data. `Incoming` keeps the request's lifecycle instants (`RequestTimes`) across preemption for those histograms, and the speculative completion path now also accumulates, per request, the drafts the grader offered and accepted. Both travel on `GenerationEvent::Finished`, the HTTP delivery stream passes them to the encoder for each choice, and `Encoder::timings_value` renders llama.cpp's `timings` object: `cache_n`, `prompt_n`, `prompt_ms`, `prompt_per_token_ms`, `prompt_per_second`, `predicted_n`, `predicted_ms`, `predicted_per_token_ms`, `predicted_per_second`, and `draft_n` with `draft_n_accepted` when drafts were offered. `prompt_ms` spans the earliest scheduled step that included the request to the earliest committed generated token, `prompt_n` excludes `cache_n`, and the decode fields span the first to the last committed token over the intervals after each choice's first token. A request that recorded no times emits no object, so cancelled, failed, and decision-scoring requests carry none. Chat and Completions place `timings` on the usage chunk when `stream_options.include_usage` is set, otherwise on the chunk that completes the last choice; Messages places it on the `message_delta` event; Responses places it beside `response` on `response.completed` or `response.incomplete`; non-streaming bodies carry it at the top level. `docs/api.md` specifies the fields and their placements. The added top-level key is the only wire change: no request field or flag selects it, and clients that ignore unknown keys are unaffected. The claimed result is llama-swap parity with llama.cpp for a proxied Flare request: the prompt and generation rates come from Flare's own intervals, the input-token column reports the tokens actually prefilled, and the draft columns report offered and accepted drafts instead of unknown. Serving work is unchanged; the object is rendered at encoding time from counters the runtime already maintains. Evidence: `server::protocol::tests::timings_report_prefill_decode_and_drafts_on_final_output` checks the rendered object and its placement for all four protocols, its absence without recorded times, the finish chunk under a stream without usage, and the conditional draft keys. `server::runtime::phase_tests::http_final_output_reports_timings_for_every_protocol` drives the HTTP delivery stream for all four protocols, streaming and non-streaming, and `speculative_dashboard_counts_live_rounds_and_batched_forward_passes` compares the per-request draft counts with the worker's aggregate counters. The `server::runtime::phase_tests` selection with the new protocol test passed 111 tests. The `server::protocol`, `server::metrics`, and `server::logprobs` selection passed 116 of 117 tests; the failure, `server::protocol::decode::native_prompt_tests::messages_image_hints_end_after_expansion_for_text_and_segmented_templates`, requires templates from `tests/frontend/prepare_templates.py` through `FLARE_TEST_TEMPLATE_DIR`, and no templates are installed on this host, so that test is unrun here. `cargo build --locked --release --manifest-path flare-cli/Cargo.toml` succeeded. The end-to-end llama-swap activity check runs after this commit, so it does not support this message. Signed-off-by: Wynn Drahorad <[email protected]> Design-Signed-Off-By: deepseek-v4.1-flash (omp agent); design-review=eb2f
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.
Flare serves models through llama-swap on the same host, and llama-swap's activity
table and
GET /api/metrics/activityreport the prompt and generation token ratesof every Flare request as unknown (
-1), with the input-token column showing thewhole prompt. The proxy fills those columns only from a llama.cpp
timingsobjector a vLLM
metricsobject inside the proxied response body or an SSE event(
internal/server/metrics.go,buildMetrics, llama-swap v250 at60226b6).Flare reports
usageonly, and Flare's/metricshistograms cannot feed theproxy because it parses proxied bodies rather than scraping. #551 describes the
gap and the wire contract.
The runtime already measures both intervals for its own request histograms and
counts speculative drafts, so a response can carry the same object llama.cpp
carries on the same events: the final Chat chunk and the final Responses event.
vLLM's
metricsobject was the alternative, but it carries no token counts ofits own: llama-swap divides
usageinput minus cached tokens by time to firsttoken, so a stream without
stream_options.include_usagehas nothing to divideand reads zero.
What changed
This branch is stacked on #548, which adds the request-latency histograms and the
RequestTimesstamps this PR reads. #548 stamps the first model step thatincludes a request and its first and last committed generated tokens on
Incoming, and records queue, prefill, decode, and per-output-token histograms;this PR adds the per-request draft counters beside them, carries both to the
encoder, and renders them into the response. Merge #548 first.
Runtime,
helios/src/server/runtime.rsandhelios/src/server/metrics.rs:RequestTimesbecomespubbecause it becomes a field of the publicGenerationEvent.DraftCounts { offered, accepted }records the speculative drafts a requestoffered for verification and had accepted, clamped the same way the existing
aggregate counters clamp them.
Worker::completeaccumulates them into therequest's
Incomingafter the scheduler accepts a completion, so a rejectedcompletion frame contributes nothing. Like
times, the counters survivepreemption because parking moves
Incoming.GenerationEvent::Finishedcarriestimesanddrafts. The cancelled pathand the two completion paths (the user/text stop in
Worker::completeand thenatural finish in
Worker::publish) fill them from the request'sIncoming.Encoder and HTTP,
helios/src/server/protocol/encode.rsandhelios/src/server/http.rs:Encoder::record_timingstores one choice's instants and draft counts; thedelivery stream calls it on
Finishedbefore finishing that choice's decoder.Encoder::timings_valuerenders the llama.cpp object:cache_n,prompt_n,prompt_ms,prompt_per_token_ms,prompt_per_second,predicted_n,predicted_ms,predicted_per_token_ms,predicted_per_second, plusdraft_nanddraft_n_acceptedonly when drafts were offered. Prefill spansthe earliest scheduled step to the earliest committed token;
prompt_nis theprompt total minus
cache_n; decode spans the earliest to the latest committedtoken over the intervals after each choice's first token. Every rate reports
zero rather than an undefined value when its interval or token count is zero.
timingson the usage chunk whenstream_options.include_usageis set, otherwise on the chunk that completesthe last choice; Messages puts it on
message_delta; Responses puts it besideresponseonresponse.completedorresponse.incomplete; non-streamingbodies carry it at the top level.
[DONE]does not. A request that recorded notimes emits no object, so cancelled, failed, and decision-scoring requests
carry none.
protocol; for streams that body only feeds the e2e metric.
docs/api.mdspecifies the fields, their definitions, and their placements.Claimed result
A llama-swap activity entry for a Flare request reports prompt and generation
token rates from Flare's own intervals, the input-token column the tokens the
model actually prefilled, and the draft columns the offered and accepted drafts,
which is what the same entry shows for llama.cpp. Serving behavior is unchanged:
the object is rendered at encoding time from counters the runtime already
maintains, no request field or flag selects it, and clients that ignore unknown
keys are unaffected. It is the only added wire element, and it is absent for
cancelled and failed requests.
Evidence
Linux x86_64, release profile,
--features runtime-core,server:--lib -- server::runtime::phase_testswithserver::protocol::tests::timings_report_prefill_decode_and_drafts_on_final_outputpassed 111 tests. The protocol test checks the rendered object and its placement
for all four protocols, its absence without recorded times, the finish chunk
under a stream without usage, and the conditional draft keys.
http_final_output_reports_timings_for_every_protocoldrives the HTTP deliverystream for all four protocols, streaming and non-streaming, and asserts one
timingsobject per response;speculative_dashboard_counts_live_rounds_and_batched_forward_passescompares the per-request draft counts with the worker's aggregate counters.
--lib -- server::protocol server::metrics server::logprobspassed 226 of 227tests. The failure,
server::protocol::decode::native_prompt_tests::messages_image_hints_end_after_expansion_for_text_and_segmented_templates,requires templates from
tests/frontend/prepare_templates.pythroughFLARE_TEST_TEMPLATE_DIR, and no templates are installed on this host.End-to-end llama-swap check on the two-GPU instance, with this commit
cherry-picked onto the validation branch and the
:localimage rebuilt:/v1/chat/completions,max_tokens64, 36-token prompt: thebody ended with
"timings":{"cache_n":0,"prompt_n":36,"prompt_ms":571.259063, "prompt_per_token_ms":15.868307305555554, "prompt_per_second":63.01869384958887,"predicted_n":64, "predicted_ms":2599.857843,"predicted_per_token_ms":41.267584809523804, "predicted_per_second":24.232094139156363,"draft_n":55,"draft_n_accepted":45}./v1/chat/completionswithoutstream_options,max_tokens32: thefinish chunk of the last choice carried the object once, with
prompt_per_second224.1889,predicted_per_second101.2014,draft_n35,draft_n_accepted20./v1/messages,max_tokens256:message_deltacarried the objectonce, with
prompt_per_second180.5281,predicted_per_second137.3816,draft_n35,draft_n_accepted24.GET /api/metrics/activityreturned those three entries withprompt_per_second63.0187, 224.1889, 180.5281 andtokens_per_second24.2321,101.2014, 137.3816, plus
draft_tokens55, 35, 35 anddraft_acc_tokens45,20, 24. Entries recorded before the image swap kept
-1where the responsecarried no
timings, and the instance's own traffic after the swap reports thenew fields too, since it serves this agent session as well.
cargo build --locked --release --manifest-path flare-cli/Cargo.tomlsucceeded.Not run here: the Windows build, the full helios suite, and any model other than
the DeepSeek V4.1 entry, which CI covers where applicable.
#549 is independent: it adds KV page gauges beside
cached_pagesand does nottouch the response path. This PR rebases onto #548 without conflict; #548 must
merge before it.
Closes #551
Discord: oystersmiles