Recommendation: Changes Requested
The per-request metrics design itself is lean and sound—the worker owns the monotonic instants, the encoder owns vLLM placement, the option adds no new clock reads or locks and does negligible copy work when off, and the prior Ignition configuration-schema blocker is resolved at e3829e6. However, the published branch stacks all of #548 and carries two blocking items that match project owner Luke Alonso's explicit merge gates on #548/#549: a pre-prefill Worker::requeue bug that corrupts this PR's headline queue_time_ms/time_to_first_token_ms/tokens_per_second fields under slow host-store pool lookups, and missing mandatory --release crate tests plus Layer 3 TLA+ lifecycle conformance (verification/helios-lifecycle/check.py (not opened)) after rebasing onto main (and #548).
Merge Risk
Level: Medium
- Blast radius on serving hot path is low when off: With
per_request_metricsdisabled (default), the PR's own changes above#548only copyarrival_nsandRequestTimesintoGenerationEvent::Finishedand hit earlyNonereturns inEncoder::record_times/Encoder::metrics_value—no extra locks, allocations, or clock reads. - Data-accuracy blast radius under host-cache contention: Because
Worker::requeuepreserves a stalefirst_scheduled_ns, slow Selene pool lookups systematically inflatetime_to_first_token_msand deflatetokens_per_second(and skew#548's queue/prefill/inference histograms) for the exact straggler requests operators monitor. - Stacking and base-branch drift: The PR is branched from
f377dc85on top of unmerged#548(6b736d24), touches covered scheduler/worker lifecycle files without runningmain's TLA+ conformance suite, and overlapsignition/cli/config.py/ignition/cli/serve.pyareas refactored onmainby#545.
Walkthrough
- Worker → HTTP timing handoff (
helios/src/server.rs,helios/src/server/runtime.rs,helios/src/server/http.rs,helios/src/server/observation.rs,helios/model-contract.md): Re-exportsRequestTimesbesideSnapshot, attachesarrival_nsandtimestoGenerationEvent::Finished, surfacesfirst_scheduled_nsin Chatperformancewhenreturn_token_timestampsis requested, and forwardsarrival_ns/times/generated_tokenstoEncoder::record_times. - vLLM
metricsencoding & placement (helios/src/server/protocol/encode.rs,helios/src/server/http.rs): AddsEncoder::enable_request_metricsandEncoder::metrics_valueemitting vLLM's six keys (withtime_to_first_content_token_ms: null), attached to non-streaming JSON bodies, final Chat/Completions usage chunks, andresponseinsideresponse.completed/response.incomplete; emitsnullforn > 1and omits for multi-prompt and Anthropic Messages. - Configuration & CLI plumbing (
helios/src/server/config.rs,flare-cli/src/{cli,config,main}.rs,flare/src/{configuration,controller,settings}.rs,ignition/cli/{config,serve}.py): Wires--enable-per-request-metrics(flare run,flare orbit runrank zero) and[server] per_request_metrics(strict boolean, defaultfalse) across native CLI, desktop controller, andignition debug-serve, plus Ignition's schema allowlist and generated template. - Docs & tests (
docs/api.md,docs/cli-design.md,helios/src/server/protocol/tests.rs,helios/src/server/runtime/phase_tests.rs,helios/src/server/runtime/response_lifecycle_tests.rs,tests/cli/test_config.py): Documents field definitions, placement,include_usagelimit, and Orbit precedence; adds encoder, HTTP+worker phase, CLI/config, and Ignition schema tests. (Fileshelios/src/scheduler.rs(not opened),helios/src/server/latency.rs, andhelios/src/server/metrics.rsin the diff are carried from base PR#548.)
Pre-merge Checks
- [PASS] Security / malicious screen: No suspicious code, credential exposure, or prompt-injection attempts; strict boolean parsing rejects non-bool config values across Helios, Flare, and Ignition.
- [PASS] Charter & value fit: Lives in the right Helios/config layer with no per-model branches, explicit opt-in flag/config, and real gateway consumer (
llama-swap);Closes #551needs narrowing toPart of #551. - [WARN] Related / duplicate / conflict check: Depends on unmerged
#548(carries its full diff and its unfixed requeue bug); supersedes closed#552/#553;#562(content TTFT) was closed while draft; rebasing ontomainwill touchignition/cli/{config,serve}.pymodified by#545. - [WARN] Tests & verification evidence: Author ran debug
cargo test --lib,pytest tests/cli/test_config.py, and a 40-check live RTX PRO 6000 Blackwell matrix plus CPU check, but did not run mandatorycargo test --locked --releaseacross affected crates orpython3 verification/helios-lifecycle/check.py(not opened) (Layer 3 onmain).
Blockers
-
Pre-prefill
Worker::requeueretains a stalefirst_scheduled_ns, corrupting per-request metrics and histograms (helios/src/server/runtime.rs:2272-2285,2639-2640,2647-2675→helios/src/server/protocol/encode.rs:261-272)Worker::reserve_and_packstampsactive.incoming.record.times.first_scheduled_ns.get_or_insert(scheduled_ns)for every lane of everyGraphKind, includingGraphKind::InitandGraphKind::Restore(runtime.rs:2272-2285). When a late host-store pool answer arrives before prefill consumes new tokens (live.generated_tokens == 0),Worker::retry_late_pool_answerscancels the request and callsself.requeue(handle, true)(runtime.rs:2607-2640).Worker::requeue(runtime.rs:2647-2675) parksactive.incomingwithout clearingincoming.record.times.first_scheduled_ns. After readmission intoInboundand a host-store restore over disk/network,first_scheduled_nsremains frozen at the discardedInit/Restorestep, soqueue_time_ms(encode.rs:264) ends prematurely whiletime_to_first_token_ms(encode.rs:261),tokens_per_second(encode.rs:268-272),performance.first_scheduled_ns(http.rs:562,607), and#548's queue/prefill/inference histograms absorb the entire park and host-restore wait. This is the exact defect Luke Alonso marked blocking on#548, carried verbatim in this diff. Fix: Land the reset (incoming.record.times.first_scheduled_ns = None;inWorker::requeue, plus a phase test covering requeue/readmission) in#548and rebase#560onto it, and aligndocs/api.md:1015-1017with whicheverInit/Restorestamping rule#548adopts. -
Missing mandatory Layer 1 (
--release) tests and Layer 3 TLA+ lifecycle conformance (docs/design-review.md:180-251onmain) This PR's diff modifieshelios/src/scheduler.rs(not opened),helios/src/server/runtime.rs,helios/src/server/runtime/phase_tests.rs, andhelios/src/server/runtime/response_lifecycle_tests.rs(including#560-specific edits toruntime.rs,phase_tests.rs, andresponse_lifecycle_tests.rs), and the branch is based onf377dc85beforeverification/helios-lifecycle/check.py(not opened) and the Layer 3 gate landed onmain. Perdocs/design-review.md:180-251(and Luke Alonso's blocking reviews on#548and#549), touching covered scheduler/worker/response-lifecycle paths requires runningpython3 verification/helios-lifecycle/check.py(not opened) andcargo test --locked --releaseon every affected crate (helioswith--features runtime-core,server,flare,flare-cli) rather than debugcargo test --libalone. Fix: Rebase ontomainafter#548merges (resolving any#545overlap inignition/cli/{config,serve}.py), runpython3 verification/helios-lifecycle/check.py(not opened) andcargo test --locked --releaseforhelios,flare, andflare-cli(pluspytest tests/cli/test_config.py), and record the results in the PR Evidence section.
Should Fix
-
Change
Closes #551toPart of #551(helios/src/server/protocol/encode.rs:236-242, 260-273, 732-745) Issue#551specifies a llama.cpp (not opened)-styletimingsobject withcache_n/prompt_n/draft_n/draft_n_accepted, Anthropic Messages coverage onmessage_delta, and Responses placement besideresponserather than inside it (specifically sollama-swapcan read Responses streams).#560delivers vLLM's six-fieldmetricsobject nested insideresponse(encode.rs:733-743), omits Messages (encode.rs:238), and carries no draft/cache counts (encode.rs:260-273), and the author's own live check notes that Responses streams still show no rates inllama-swap. Mirroring Luke Alonso'sCloses #536→Part of #536correction on#548, usePart of #551(or update#551to match the narrowed vLLM scope). -
Forced reasoning close can emit synthetic
0.0mean_itl_msand understates ITL without documentation (helios/src/server/runtime.rs:433-446, 1959-1980;helios/src/server/protocol/encode.rs:259, 265-267;docs/api.md:1011) When a reasoning budget forces a close token viaActive::close_reasoning(runtime.rs:433-446),self.carried.generated_tokensincrements by 1 without running a model step or updatingtimes.last_token_ns. Ifmax_new_tokens == 1withcut.after == 1andforced == true(1 model token + 1 forced close token = 2 generated tokens,first_token_ns == last_token_ns),encode.rs:259, 265-267emitsgeneration_time_ms: 0.0andmean_itl_ms: 0.0for a single-step request—the direct counterpart to Luke Alonso's Should Fix #4 on#548. On longer forced-close responses, the extra token also enlarges thegenerated - 1denominator without an instant, which the PR body discloses butdocs/api.md:1011omits. Fix: Alignmean_itl_msgating with#548's fix for post-first-token committing steps (see Subtract/Simplify #1) and note the forced reasoning-close token alongside the speculative-step note indocs/api.md:1011.
Subtract / Simplify
-
Share request-interval span calculation between
Metrics::request_completedandEncoder::metrics_value(helios/src/server/metrics.rs:606-631,helios/src/server/protocol/encode.rs:250-274) Both functions compute the same five spans (scheduled - arrival,first - scheduled,last - scheduled,last - first, and(last - first) / (generated - 1)) over(arrival_ns, RequestTimes, generated)with parallel null/divisor guards. Adding a small span helper onRequestTimes(ideally in#548alongside the forced-close guard) lets both histograms and JSONmetricsderive from one source of truth and eliminates duplicate guard chains inmetrics_value. -
Reuse
http_generation_request_observedinstead of duplicating the HTTP/channel setup twice (helios/src/server/runtime/phase_tests.rs:4495-4524, 4575-4591, 4800-4821)http_generation_request_observed(phase_tests.rs:4495-4524) already implements thesync_channel+http_state_for+ingress_slots+axum::http::Request+tokio::spawn(http::generate)+recv_timeoutharness. Bothserved_through_worker(:4575-4591) and then = 2loop inper_request_metrics_are_absent_without_the_option_and_null_for_several_choices(:4800-4821) duplicate those ~18 lines solely to pass a customFixtureandper_request_metrics = true. Parameterizing a shared inner helper removes ~35 duplicated lines in this diff.
Nits
docs/api.md:1015-1017notes thatfirst_scheduled_nsincludes image/vision packing but omitsInit/Restoresteps (unlikedocs/api.md:333-336); update this sentence to match whichever stamping scope#548settles on.ignition/cli/config.py:194adds# per_request_metrics = falsetowrite_initial;tests/cli/test_config.py:162-163, 182-188pins parsing and type rejection, while no test currently exerciseswrite_initialround-tripping.
Dropped on verification
- Prior Ignition
[server] per_request_metricsschema blocker (05:42 / 06:19 auto-reviews): Verified fixed ate3829e6(ignition/cli/config.py:24, 41, 194,ignition/cli/serve.py:488,tests/cli/test_config.py:162-163, 182-188); the 06:19 comment was a duplicate of 05:42 against the pre-fix tree. - Charter
#417"silently ignoring API field" for streams withoutstream_options.include_usage(Value Prop, Discovery Dossier, Correctness F3): False/misapplied. Issue#417prohibits accepting an explicit client request field (such asstrict: true) and silently ignoring its guarantee. Here the client sends noinclude_usagefield,--enable-per-request-metricsis a server flag, omitting the usage chunk unless the client opts in matches OpenAI and vLLM defaults (forcing achoices: []usage chunk requires a separate opt-in because it alters SSE framing), and the suggested HTTP 400 rejection would break standard OpenAI streaming clients. - "PR description wrongly attributes
performance.first_scheduled_nsto#560instead of#548" (Value Prop, Discovery Dossier, Correctness lens): Verified false againstpr/548(6b736d24). Atpr/548,helios/src/server/observation.rs:61, 71-73only carries(ingress_ns, enqueue_ns)andhelios/model-contract.md:345-349does not includefirst_scheduled_ns; commit3b1ebbf6introduces it in#560. - "
This PR adds no clock readis inaccurate" (Correctness lens): False; the PR description explicitly states "This PR adds no clock read; the one monotonic read per scheduled model step comes from #548", which matches6b736d24..e3829e62. attach_metricshelper for three 3-line sites (Subtraction S2): Dropped as low-signal (saves ~2 lines net and would churn 6 directencoder.metrics_value()test assertions inprotocol/tests.rs).- Removing
first_scheduled_nslocal inhttp.rs:411/ replacing(Option<u64>, Option<u64>, Option<u64>)inobservation.rs:61(Subtraction S3): Dropped;http.rs:411is required whenreturn_token_timestamps: trueis used withper_request_metrics: false(sinceencoder.metricsisNone, exercised atphase_tests.rs:4622), and introducing a wrapper struct for a 2-caller internal helper adds rather than subtracts code. - Dropping
streaming: boolparameter fromEncoder::enable_request_metrics(Subtraction S4): Dropped;Encoder::newdoes not takestreaming(onlyset_logprobssetsself.streamingand requiresArc<Frontend>), so keeping the parameter avoids adding a test-only setter or constructing aFrontendacross 7 tests inprotocol/tests.rs:2375-2443.