Prose review — PR 560 "Emit vLLM-compatible per-request metrics from runtime instants"
Head reviewed: 046aaef (base main, 22 files, +1757/−77). Lens: the description, commit messages, changed docs and code comments, judged against the charter, AGENTS.md, docs/design-review.md and .agents/skills/repo-prose/SKILL.md (not opened). Every claim below was checked against the code at the head commit; the only thing I did not do is execute the test suites.
Key findings
- Blocking — the docs present
[server] per_request_metricsas the flag's default, but Ignition rejects the key.docs/api.md:1007,docs/cli-design.md:736,:1317-1318and the:1349example all introduce it;ignition/cli/config.py:23-24has no such key and_validateraisesUsageErrorfor anything outside the schema (config.py:112-114), so a host that prepares cores withignition export(or runsbench,debug-serve,convert,edit,combine,sign) fails on the file the docs told the user to edit. This contradictsdocs/cli-design.md:1313and:1385-1387. - Should fix —
docs/api.md:1045-1050is the HTTP reference's only mention ofperformance/token_timestamps_ns, and it never defines the shape it refers to (placement inchoices[0], the alignedtoken_ids, thereturn_token_timestamps requires return_token_idsrule athelios/src/server/observation.rs:37-39). - Should fix —
docs/cli-design.md:736records[server] per_request_metricsas the flag's default although only nativeflare runreads it:ConfigFile::applyhas noOrbitRunbranch (flare-cli/src/config.rs:57-75), so the documented default silently resolves to "off" forflare orbit run. - Nits (3) — both
--helpstrings omit the configuration key the docs table names; the description's "This PR adds no clock read" is contradicted by its own diff because the per-step read belongs to #548's commit66245920; and that read is per step, shared by every lane, not per request. - Everything else verified accurate: description order and framing, the #552/#553 replacement rationale, the field table against
Encoder::metrics_value, placement and null rules, the queue-arrival boundary,performancecontents, themodel-contract.mdupdate, the documentedinclude_usagegap, and the evidence section againstAGENTS.md:103-112.
Blocking
B1. docs/cli-design.md:736, :1317-1318, :1349; docs/api.md:1007 — the documented configuration key does not exist in Ignition's schema
The new prose introduces [server] per_request_metrics in four places:
docs/api.md:1007: "flare run --enable-per-request-metrics, or[server] per_request_metrics = truein the host configuration, adds vLLM's per-requestmetricsobject…"docs/cli-design.md:736, the default column: "[server] per_request_metrics, otherwise off".docs/cli-design.md:1317-1318: "Nativeflare runapplies[server] host,port,api_key,thinking_token_budget,scheduler_checkpoint_extra_work_fraction, andper_request_metrics, …"docs/cli-design.md:1349, inside the[server]block that:1311-1312says is "Written on first export with the resolved values present as comments":# per_request_metrics = false # Add vLLM's per-request \metrics` to OpenAI output.`
Ignition's schema does not contain it. ignition/cli/config.py:21-24:
"server": {"host": str, "port": int, "api_key": str, "thinking_token_budget": int,
"scheduler_checkpoint_extra_work_fraction": (int, float)},
and Configuration._validate (config.py:108-118) raises on any other key: f"{path}: unknown key {key} in [{section}]" (:112-114). A search of the whole ignition/ tree for per_request_metrics returns nothing, as does a search of tests/cli.
That matters because Ignition reads the same default file (config.py:19, DEFAULT_PATH = Path("~/.config/flare/config.toml (not opened)")) and loads it for every command: convert/edit/combine/sign (ignition/cli/publishing.py:31,73,174,194), export/_export_hosts/_prepare/debug_serve/join (ignition/cli/serve.py:127,174,264,431,590) and bench (ignition/cli/bench.py:144 (not opened)). So the ordinary flow the docs describe — uncomment the line in the generated config, later run ignition export to prepare a core — ends in a usage error on a key this PR tells the user to set. write_initial (config.py:183-192) also does not emit the key, so the doc example is additionally wrong about what "written on first export" produces.
Two documented statements this contradicts:
docs/cli-design.md:1313: "Ignition and native Flare read this file".docs/cli-design.md:1385-1387: "Ignition rejects any section or key outside its schema. Native Flare ignores keys it does not use, except in[prefix_cache]…"
per_request_metrics is also the only [server] key native Flare reads (flare/src/configuration.rs:28-35: host, port, api_key, thinking_token_budget, scheduler_checkpoint_extra_work_fraction, per_request_metrics) that Ignition rejects, i.e. the first exception to a rule the document states without qualification.
Fix (either):
- (a) Add
"per_request_metrics": boolto_SECTIONS["server"](config.py:23-24), a"server.per_request_metrics": Falseentry to_BUILT_IN(config.py:37-53, required soget()at:156cannotKeyError), a commented line inwrite_initial's[server]block (config.py:188-192), and a case intests/cli/test_config.py(the file already pins such rejections at:151-177); or - (b) If the key is meant to stay Flare-only, say so at each of the four places, matching the phrasing
:1317already uses for nativeflare run.
Option (a) is the one consistent with the charter's rule against silently ignoring or breaking a documented setting (charter line 13) and with AGENTS.md's requirement that docs and behaviour agree.
Should fix
S1. docs/api.md:1045-1050 — the new section is not readable from the HTTP API reference alone
A Chat request with `return_token_timestamps: true` also receives a top-level
`performance` object holding `ingress_ns`, `enqueue_ns`, `first_scheduled_ns` and
`reused_prompt_tokens`; the three instants are absolute nanoseconds on the same
process-local origin as `choices[0].token_timestamps_ns`. The
[prepared model contract](../helios/model-contract.md#token-and-timing-observation)
defines those fields.
A whole-file search of docs/api.md for return_token_timestamps|token_timestamps_ns|return_token_ids returns only :992 (a passing mention that "Chat token observation extensions" exist) and this passage. Nothing states:
- that
token_timestamps_nssits inchoices[0]beside the alignedtoken_ids, and that a Chat stream emits one metadata-only chunk per token (helios/src/server.rs:915,helios/src/server/http.rs:603,helios/model-contract.md:328-342); - that
return_token_timestamps: trueis an error unlessreturn_token_idsis also true (helios/src/server/observation.rs:37-39); - that
performanceaccompanies only timed responses (observation.rs:70-74).
The anchor resolves (helios/model-contract.md:326), so this is not a dangling reference, but the sentence compares an origin to "choices[0].token_timestamps_ns" as though the HTTP reader already knew that field. AGENTS.md requires prose to make sense to a reader who has the repository, and the repo-prose rules forbid definite references to things the text has not introduced.
Fix: one sentence in the "Chat token observation extensions" paragraph at docs/api.md:991-992, e.g. "return_token_timestamps requires return_token_ids: true; it places per-token instants in choices[0].token_timestamps_ns, aligned with choices[0].token_ids, and adds a top-level performance object on buffered responses." The new section can then compare origins without redefining.
S2. docs/cli-design.md:736 — the recorded default is not the default for flare orbit run
Row: | --enable-per-request-metrics | … | [server] per_request_metrics, otherwise off |.
The flag exists on both commands (flare-cli/src/cli.rs:646-649 for OrbitRun, :860-863 for Run), and docs/cli-design.md:170-173 lists it among the options Orbit applies to rank zero, so the row reads as covering both. But the configuration fallback lives in ConfigFile::apply, whose branch matches only cli::Command::Run (flare-cli/src/config.rs:57, key applied at :73-75). OrbitRun takes the value from its flag alone (flare-cli/src/cli.rs:698, forwarded to the ranks at :729), and the Orbit arm at flare-cli/src/config.rs:141-151 only sets cache paths. The flare/src/configuration.rs:34 → settings.rs:224 → controller.rs:2566 path is the native-run and desktop path, not Orbit.
Consequence: an operator who sets [server] per_request_metrics = true, launches flare orbit run, and trusts this table gets no metrics and no error.
Fix: in the default column, "[server] per_request_metrics for native flare run, otherwise off" — the phrasing docs/cli-design.md:1317 already uses.
Nits
N1. flare-cli/src/cli.rs:646-648 and :860-863 — help text omits the configuration key
Both now carry identical text ("Add vLLM's per-request metrics timing object to OpenAI Chat, Completions, and Responses output."), which is good, but neither names [server] per_request_metrics, which docs/cli-design.md:736 gives as the flag's default. One clause would make --help and the doc agree. Low severity: the two-line form matches neighbouring options.
N2. PR description, "Result" — "This PR adds no clock read; the one monotonic read per scheduled model step comes from #548"
The attribution is correct (commit 66245920, "… stamp scheduled time after packing", belongs to #548), but this branch carries #548, so this PR's diff shows the read arriving: helios/src/server/runtime.rs:2269-2285 adds let scheduled_ns = super::observation::monotonic_ns(); and the stamp loop with get_or_insert at :2282-2283. Read against the diff, the sentence looks contradicted — especially since it follows the bullet saying the performance object "gains first_scheduled_ns". Fix: name the commit, e.g. "the one monotonic read per scheduled model step arrives with #548 (66245920)".
N3. Same sentence — "per scheduled model step" is right, but the sharing is unstated
One instant is read per packed step and shared by every lane through get_or_insert (helios/src/server/runtime.rs:2272-2284). docs/api.md:1025-1026 says exactly this for completion instants; adding "per step, shared by its lanes" to the description's cost sentence keeps the cost claim precise.
Verified accurate — no change requested
- Description structure. Why (aggregates only; HTTP round-trip timing mixes queueing, prefill and transfer), what changed, result, evidence,
Closes #551, Discord line — in the orderAGENTS.md:72-112prescribes. The #552/#553 replacement rationale (llama-swap double-counts cached tokens when both objects are emitted; HTTP-layer clocks cannot report queue time) states a defect rather than claiming parity, which is what the charter's "What gets merged" asks for. - Field table
docs/api.md:1016-1023againstEncoder::metrics_value(helios/src/server/protocol/encode.rs:251-274):queue_time_ms= scheduled − arrival withsaturating_sub(:265);time_to_first_token_ms= scheduled → first committed token (:262);generation_time_ms= first → last (:260);mean_itl_ms= generation ÷ (generated − 1) only whengenerated > 1(:266-268);tokens_per_second= generated over scheduled → last, suppressed on a zero span (:269-273);time_to_content_token_msa hardnull(:263). - Placement and null rules
docs/api.md:1031-1043againstenable_request_metrics(encode.rs:233-241), the usage chunk (encode.rs:711-718), the Responses terminal object (encode.rs:731-743) and the JSON body (helios/src/server/http.rs:613-615): never for Anthropic Messages; absent without a usage chunk; absent for multi-prompt Completions;nullforn > 1. - Queue-arrival boundary
docs/api.md:1026-1029againsthelios/src/server/runtime.rs:908-947:arrival_nsis read while buildingIncoming, beforetry_send. The earlier round's finding that the description misattributed this to the HTTP layer is resolved. performancecontentsdocs/api.md:1045-1048againstObservationOptions::finish(helios/src/server/observation.rs:70-74): emitted only whentimestamps, and holds exactlyingress_ns,enqueue_ns,first_scheduled_ns,reused_prompt_tokens.helios/model-contract.md:343-355: "when the worker reserves and packs that step before submitting it" matches the stamp afterpack_inputsand beforesubmit(runtime.rs:2269-2289); "a preempted request keeps its original value" matchesget_or_insert; "null when no model step included the request" matches theOption.docs/cli-design.md:170-173,:736,:1349againstflare-cli/src/cli.rs:649,:863,flare-cli/src/config.rs:73-75,flare/src/configuration.rs:34,flare/src/settings.rs:224,flare/src/controller.rs:2566(not opened) — apart from S2.- The
include_usagegap (docs/api.md:1031-1038) is stated as a limitation with its llama-swap consequence and the vLLM option that would close it, rather than left implicit; the description says the same. - Evidence section. Hardware (RTX PRO 6000 Blackwell), package, llama-swap v250, the 40-check matrix, the 819-passed/1-known-template-failure test split, the "measured on the earlier revision" caveat for the CPU numbers, and "Not run: multi-GPU cores and the Windows build" satisfy
AGENTS.md:103-112andSKILL.md:35-46: each claim is measured here or named as not run. - New doc comments (
encode.rs:232-250,runtime.rs:2269-2271,helios/src/server.rs:127-129) state invariants, not history.
Open questions and what I could not settle
- Whether
[server] per_request_metricsis meant to reach Ignition at all. If yes, B1 is a code fix inignition/cli/config.pyplus a pytest case; if no, it is a wording fix in four doc places. A pytest case asserting the currentUsageErroris the reproduction a reviewer would want; my check is static (schema listing +_validate+ absence fromignition/andtests/cli) and I did not run pytest. - Whether
flare orbit runshould read the key. If it should, S2 becomes a code change inflare-cli/src/config.rs(Command::Orbitarm) rather than a doc qualification. - Whether
helios/model-contract.mdis intended as the canonical definition oftoken_timestamps_ns. If maintainers say yes, S1 shrinks to one clause, but thereturn_token_idsrequirement still belongs indocs/api.md, which is the surface a client reads. - The magnitude of the extra span in
queue_time_ms(admission checks, channel send, worker pickup) is a measurement question. The docs state the boundary without asserting a size, which is the right treatment; nothing further is needed from this lens.