Explore report · NVIDIA/hyperflare-inference #691

Raw Markdown for agents: https://autobot.eidonix.com/p/89956672-586e-4ffd-a995-5e027bf7579a.md

Case file: PR #691 — helios/server: report reused prompt tokens in continuous_usage_stats chunks

https://github.com/NVIDIA/hyperflare-inference/pull/691 · fixes #448 · author jcartu (CONTRIBUTOR, Discord jcartu) · branch fix/continuous-usage-cached-tokens → main · head ef45ca9, base c513e46 · opened 2026-12-02 20:54, last updated same minute · 6 files, +868/−40 · ready for review, no labels, no CI checks, no reviews, no comments.

Key findings

What a reader cannot learn from the description:

  1. New silent default. Generation::wait_for_first_token now returns Ok(0) when the receiver was already taken (helios/src/server/runtime.rs:159-164), i.e. a path that used to be a Result<()> check now reports "zero cached tokens" rather than an error. Undeclared.
  2. New failure path out of the worker. Incoming::observe_token_with is fallible and its closure calls self.scheduler.request(token.request)? (runtime.rs:2011-2016). A retired/stale handle at first-token time now propagates an Err out of Worker::complete, and the worker's run loop returns it and fail_alls outstanding requests. Before this PR observe_token was infallible. The description says only that the lookup avoids "per-token scheduler lookups".
  3. Docs were deliberately not touched, although the bug issue offered two resolutions — fix the code, or amend docs/api.md to call cached_tokens final-only (see #448 body). The PR takes the first option and leaves docs/api.md:1013-1045 unchanged; the docs already promised the new behavior, so nothing drifts, but there is also no release note that these values are now populated mid-stream.
  4. No docs/TODO.txt entry for the untested GPU/live-serving path, although AGENTS.md:58 requires recording unrun checks there. docs/TODO.txt is not among the changed files.
  5. Test-weight and inconsistent suite counts. ~742 of the +868 lines are tests (helios/src/server/runtime/phase_tests.rs +649/−9, helios/src/server/protocol/tests.rs +108/−0); production delta is ~110 lines. The description's helios counts (1821 passed / 47 ignored) differ from the same author's same-day #692 (1884 / 84) for the same command, so the numbers were measured on different revisions and are not directly comparable.
  6. Merge-order debt. #692 (same author, same day), #548 and #560 all still carry the pre-#691 first_token: oneshot::Receiver<Result<()>> and the pre-#691 ObservedToken arm, so landing #691 first forces rebases in three open PRs (one the author's own, two WynnD's).
  7. Engagement: none. Zero comments, zero reviews, no CI run, and the repo's flare-autobot reviewer — which posts intake reviews on other PRs within minutes (e.g. #560) — has not posted here yet.

The change

Plain terms: with "stream_options": {"include_usage": true, "continuous_usage_stats": true}, intermediate Chat/Completions SSE chunks reported prompt_tokens_details.cached_tokens: 0 while only the terminal usage chunk reported the reused-prefix count. The count is already final when a request produces its first token (pre-token requeue transitions happen before generation; later preemption/close/grammar transitions lock the count into Carried::reused_prompt_tokens). The PR therefore hands the count to the HTTP layer through the existing first-token oneshot and writes it into the encoder's per-choice usage before any text chunk is emitted.

File map (verified against the diff):

Description vs diff: the description's claims about what changed match the code, with the exceptions in Key findings 1–4 above. Also worth noting: the mechanism is coupled to generate_many_observed — ObservedToken only exists on that path (http.rs:330-331, selected when continuous_usage), so no separate event was needed. max_tokens: 0 requests (moved to zero, http.rs:311-315, 453-466) are never polled, so they keep reporting zero cached tokens, consistent with docs/api.md:1058-1061. Completions echo frames are emitted before the event loop (http.rs:437-452) and necessarily carry zero — the description discloses this.

The why

Recent activity

People

Community

Nothing found: no comments, no reviews, no inline review comments, no reactions, no linked discussions, no labels (pr_comments returns "No comments").

Project fit

Claims and evidence

All evidence is self-reported; no CI ran on ef45ca9 and nothing was executed during this review.

Claim Backing
helios suite: 1821 passed, 47 ignored, 0 failed; 62 integration passed Not independently verifiable. The five named tests exist at protocol/tests.rs:1415, :1471 and phase_tests.rs:8449, :8756, :8869. Counts differ from #692's same command (1884/84), so they were measured on different revisions.
flare 246 / flare-cli 219 tests pass Neither crate is changed by this PR, so unaffected by construction.
verification/helios-lifecycle/check.py (not opened) all 8 models pass; ResponseLifecycle 868,192 states / 117,991 distinct / 365,508 Rust transitions 365,508 matches #692's independently reported ResponseLifecycle conformance figure, so the two are at least mutually consistent. The description does not show the TLC jar path or mutation counts that #692's does.
Every Chat chunk reports the finalized count phase_tests.rs:8646-8666 (real Worker + RequestScheduler, warms a 13-token prefix, asserts every chunk == 13) and protocol/tests.rs:1415-1466.
Count retained across post-token preemption/readmission chat_continuous_usage_preserves_initial_cached_tokens_across_preemption (phase_tests.rs:8869-9074), including the case where the readmitted request's live count is 13 while the stream must keep reporting 0.
Multi-choice does not let siblings overwrite the first choice's count; cumulative across prompts protocol/tests.rs:1471-1521 (4 choices / 2 prompts; sibling 9 must not overwrite 5; cumulative 8) and phase_tests.rs:8756-8866 (staggered readiness).
Messages unchanged phase_tests.rs:8744, :8750 assert message_start zero and message_delta final.
"no GPU or exported-core live serving test was run" (disclosed) Consistent: tests are CPU fixture-based; tests/server/test_protocols.py:196-259 (test_cached_usage_buffered_and_streaming) does not cover continuous_usage_stats at all — no match for the option anywhere under tests/.
"eliminating scanning once all representative first choices have started" True structurally (pending_cached shrinks to empty), but no measurement of the per-token retain cost is offered; cost is bounded by prompt count.

Reach

Process

Open questions / not found