Explore scratchpad · NVIDIA/hyperflare-inference #692

Raw Markdown for agents: https://autobot.eidonix.com/p/8448ecca-a8da-4534-8281-0b5beee4391e.md

#1 [high] Change: what PR #692 actually changes (verified against diff)

PR #692 (jcartu), head 348c06c, base main (branched at c513e46), open, ready for review, 4 files +1068/-32, no reviews, no CI checks. Files: helios/src/server/runtime.rs (+443/-15), helios/src/server/runtime/phase_tests.rs (+585/0), helios/src/server/http.rs (+20/-9), helios/src/server/protocol/decisions/mod.rs (+20/-8).

Mechanics (verified in the diff and head files):

#2 [high] Why: issue #679 (filed same day) is the filed report this fixes

Issue #679 "Output-layer stream failures (tool-call parse rejection) are counted as cancellations; requests_failed_total stays 0", opened by ktsaou 2026-12-02 11:31, labels area:api, bug, priority:P2, triage:investigate, no discussion yet. PR #692 opened the same day and declares "Fixes #679" (read_item 679 shows #692 in "Referred to by" as fixes). Evidence in the issue: engine main at a3c80e19 + two unrelated local patches, Qwen3.8-Flash-Next gb202 TP2, streaming Chat Completions with ChatML tool calls. Two server_error journal lines ("tool parameter names must be nonempty and unique", stage=stream) at 09:00:39 and 09:43:50; counters over the same period: completed 9046, cancelled 2, failed 0, with each cancelled increment 1 s after a journal line. An earlier occurrence on 2bdc8472 was a Responses stream ending "tool function requires parameter or closing tag". Issue's code trace at a3c80e19: chatml.rs:136 rejects empty/duplicate parameter name → server/output.rs:359-364 aborts with Termination::ExecutionError → http.rs stream arm yields Delivery::Failed and drops receiver → runtime emit() sees TrySendError::Closed and sets cancelled (runtime.rs:387-388 at that revision) → counted at metrics.cancelled.fetch_add (runtime.rs:1402/1423/1442/1493) → metrics.failed only incremented in finish_error (runtime.rs:357). The issue explicitly says "Failing the request is the right behaviour, and this issue does not ask to change it. The bug is only the outcome accounting." It asks only that output-rejected failures not appear as cancellations. Related cited in the issue: #133 (closed, GLM sibling symptom, report-only), #548 (open; its review notes the parallel-tool-limit path where runtime says cancelled but HTTP completes), and #549 (unrelated local patch). docs/api.md:330 documents completed = "Requests whose generation completed successfully"; docs/api.md:332 documents failed = "Requests failed by admission, execution, grammar, or output processing"; helios/src/server/metrics.rs:1093 HELP string says the same for requests_failed_total, and metrics.rs:1078 says completed_total = "Requests whose model generation completed successfully, including explicit token stops"; metrics.rs:1088 cancelled = "Queued or active model requests cancelled before completion." So the code was already documented as intending failed for output-processing failures.

#3 [high] Research summary

Summary of the case file for PR #692

The change (verified against the diff). PR #692 (jcartu, head 348c06c, base main, branched at c513e46, "ready for review", 4 files +1068/−32, no reviews, no CI checks on the head commit) adds a shared RequestOutcome state machine to helios/src/server/runtime.rs:109-296 — an Arc<AtomicU8> shared by Incoming (worker) and Generation (consumer) with states PENDING/GENERATED/READER_DROPPED/COMPLETED/CANCELLED/FAILED, where every transition CASes into an absorbing terminal state so exactly one of metrics.{completed,cancelled,failed} increments once per request. Completion moves out of the worker's stop path: two metrics.completed.fetch_add + emit(Finished) sites become Incoming::emit_finished() (runtime.rs:553-582), which reserves a channel slot with try_reserve() first and fails the request (rather than completing it) on Full. All four worker cancellation sites now call record_cancelled() instead of touching the counter directly (runtime.rs:1647-1653, 1667-1671, 1680-1690, 1735-1740). finish_error records FAILED before notifying admission/first-token/event channels (runtime.rs:583-595). A new deferring entry point ModelRuntime::generate_for_output (runtime.rs:1145-1151) parks worker completion in GENERATED until the consumer calls Generation::complete_output() (:348) or fail_output() (:352, record-FAILED-then-cancel), or drops the Generation (Drop → on_reader_drop, :378-383). HTTP submission collapses to a single generate_for_output call (http.rs:328-334, removing the generate_many_observed/generate_observed branches; generate_observed is now #[cfg(test)]), and fail_output() + decoders[i].abort(ExecutionError) are added on every Delivery::Failed exit (http.rs:402-410, 426-434, 445-450, 582-590), with complete_output()/fail_output() settling the taken generation on Finished (http.rs:561-566). Decision scoring switches to the same entry point and settles on every exit (decisions/mod.rs:838-886). Tests: two unit tests in runtime.rs (terminal budget overflow / deferred drop orderings, and a 2-thread Barrier test asserting exactly one counter increment across all worker×consumer pairs and both defer modes) plus four HTTP-to-Worker integration tests appended at phase_tests.rs:8437-9020 (ChatML duplicate-parameter rejections on chat/messages/responses; mid-stream and at-EOS failures after worker completion, streaming and buffered; genuine client disconnects on four routes; normal completions across four routes × stream and a n=2 failure/sibling-cancel case).

What the description does not say, and vice versa. The description does not mention that generate_observed loses its non-test visibility, that the observation plumbing in http.rs is re-expressed via .then_some(...), or that the decisions score() path is also converted and its mid-loop ok_or_else replaced by explicit fail_output() branches. Conversely, the description's claim that worker fail-then-cancel double counting is fixed matches the code: emit_finished/emit's Full arms still set cancelled, but record_cancelled can no longer reach an absorbing FAILED. The description does not say that docs/api.md/metrics.rs HELP text is left unchanged — but that text already promised exactly this behaviour (docs/api.md:332, helios/src/server/metrics.rs:1079,1088,1093), which supports the "no doc change needed" choice.

Why. Issue #679 (ktsaou, 2026-12-02 11:31, labels area:api/bug/priority:P2/triage:investigate, zero comments) is the operator report: two server_error frames from the ChatML parser tracked by two 1-second-later cancelled increments with failed at 0, at main a3c80e19. It explicitly says failing is correct and only the accounting is wrong, and it points at the same call chain the PR edits. #679 also cites #133 (closed; GLM sibling parser rejections, which turned out to be prepared-graph corruption fixed by #129 — so #133 is not the same defect as #679, despite the issue linking it) and #548.

Related work. Overlapping files: #548 and #560 (open, WynnD) both rewrite the same completion/cancellation accounting in runtime.rs — #548's review by lukealonso already flagged the parallel-tool-limit path where "runtime metrics count the request as cancelled rather than completed, despite the successful API response" (documented at docs/api.md:700-702), which #692 changes behaviour around without editing that doc; #560 stacks on #548 and touches the same GenerationEvent::Finished sites. #691 (same author, same day) changes the first_token oneshot payload to Result<u64> on the same Incoming/Generation structs #692 just extended with outcome — a likely textual conflict. #689 (same author) also touches http.rs+phase_tests.rs. #562/#552 (closed) and #560 are earlier attempts at the same metrics area. The ResponseLifecycle conformance harness in response_lifecycle_tests.rs drives generate_many/emit/cancel directly, which is why the PR keeps direct completion semantics for generate_many.

Evidence. The PR reports 1,884 helios tests passing, 254 flare, 245 flare-cli, and a full verification/helios-lifecycle/check.py (not opened) --mutations run (365,508 transitions against ResponseLifecycle.tla, 26 Rust guard mutations detected). None of that is verifiable from here — CI reports no checks on 348c06c. The lifecycle conformance is significant because docs/design-review.md (Layer 3, per lukealonso's review on #548) makes it mandatory for changes to worker admission/completion/publish/park paths, which this PR rewrites; the description names the run, and the accounting change is not reflected in any new TLA+ or conformance action. Not run: GPU-gated tests and live serving.

Project fit and reach. Charter line 9 ("solve the right problem in the right place") and the "bring real evidence / root cause" rule fit: this is a metric-attribution defect with an operator repro. Reach: /metrics consumers only (no request/response wire change, no config, no defaults). Behaviour that does change: mid-stream output failures now log failed not cancelled; deferred (HTTP/decisions) requests whose reader drops after the worker finished but before validation now count cancelled where they previously counted completed; a parallel_tool_calls: false cancellation still counts cancelled while the API returns 200, contradicting docs/api.md:700-702's wording only if the drop lands in GENERATED. tests/server/test_protocols.py:676 (cancel-count assertion) and tests/server/test_decisions.py:230-261 (decision-disconnect cancels) are the Python integration checks whose expectations this shift most directly depends on; they were not run in the stated evidence.

Process/community. Opened today, ready for review, no reviews, no comments, no CI, no labels; a third of a same-day batch from jcartu (#687-#693). Nothing has engaged with it yet. All detailed findings are in the scratchpad (entries 1-2 are the verified change map and the #679/why/documented-contract note).

#4 [high] Related work: overlapping PRs on the same completion/cancellation accounting

Overlapping open/closed PRs (related_items on 692 returned these as same-file changes; all verified via read_item/search):

Why #133 is not the same bug: #679 links #133 (GLM argument-tag rejections, report-only) as a sibling, but #133's close-out (eduffd, 2026-10-28/11-05, closed 2026-11-08) traced those rejections to prepared-graph storage lowering, fixed by merged #129 and by re-exporting the package; original-el8's close-out explicitly says "Malformed tool calls from otherwise valid model output remain a separate parser/API concern." So #679/#692 is the accounting defect for genuinely malformed output, not the #133 graph defect.

#5 [high] Claims and evidence: what #692 asserts and what actually backs it

Claimed: helios --release --features runtime-core,server 1,884 passed / 0 failed / 84 ignored (lib 1,822 passed/47 ignored; 14 integration binaries 62 passed/37 ignored); flare 254 passed/4 ignored; flare-cli 245 passed/3 ignored; verification/helios-lifecycle/check.py --mutations exit 0 with all 8 TLA+ models, 365,508 Rust transitions against ResponseLifecycle.tla (states=65989 edges=365508 depth=10), 13 TLA+ mutations, 26 Rust guard mutations and 1 observed-edge safety violation (DispatchRing SlotReuseSafe) detected. All run on Linux CPU with chat templates from tests/frontend/prepare_templates.py via FLARE_TEST_TEMPLATE_DIR and a 512 MiB locked-memory limit (they say parallel Engram staging tests exceed 64 MiB when all unit tests run concurrently). What backs it: nothing verifiable from the repository — CI on head 348c06c reports no checks (orientation packet). The counts are self-reported; the test code they point at does exist and is substantial (2 unit tests incl. the 2-thread Barrier exactly-one-counter test; 4 tokio HTTP↔Worker integration tests at phase_tests.rs:8437-9020). No benchmark/performance claims are made, so the charter's benchmark rule does not bite. Why the TLA+ run matters: lukealonso's #548 blocker #1 cites docs/design-review.md Layer 3 requiring verification/helios-lifecycle/check.py plus --release tests whenever Worker admission/completion/publish/park paths or RequestScheduler::admit_planned_with_checkpoint_accounting change; #692 rewrites completion/cancellation inside the worker, so that gate applies. The PR reports the run but adds no new TLA+ action or conformance transition for the outcome state machine — the ResponseLifecycle harness (helios/src/server/runtime/response_lifecycle_tests.rs:100-195) drives generate_many/emit/cancel/fail directly and therefore only exercises the non-deferred (defer_completion=false) half of the new state machine. Not run, disclosed: 84 ignored helios / 4 flare / 3 flare-cli checkpoint- and GPU-gated tests, live GPU serving via flare run, Kani harnesses (description says no completion-vector/state-view validators were touched). Not disclosed as unrun: the Python tests/server/*.py integration suites (e.g. tests/server/test_protocols.py:676 asserting cancelled increases on n=4 disconnect; tests/server/test_decisions.py:230-261 asserting decision disconnects increment cancelled; tests/server/test_deepseek41.py:78-79 and tests/server/test_scheduler.py:176-177 asserting failed stays flat while completed rises), which are the closest existing coverage of the counters whose semantics this changes.

#7 [high] Amendments after 7f298698 + Autobot review round (2026-12-02 22:18)

AMENDMENTS to report #6 (case file PR #692). Everything else in #1-#6 stands.

  1. Head/shape changed: head 348c06c -> 7f2986984e2898f39c97d9ce9ccac8c7db459027 (7f298698, "helios: count output-layer stream failures under requests_failed_total"), now 7 files, +968/-46 (was 4 files +1068/-32). New files in the PR: helios/src/server/metrics.rs (+3/-3), docs/api.md (+9/-2), helios/src/server/runtime/response_lifecycle_tests.rs (+2/-2); runtime.rs +362/-22, phase_tests.rs +552/0, http.rs +20/-9, decisions/mod.rs +20/-8. Labels now area:api, bug, priority:P2, triage:review (was none in my report). PR body (read_item #34) now carries the four charter sections and documents the metrics/docs work.

  2. My "no doc change is required" finding is superseded. Docs + HELP text were changed in 7f298698:

    • docs/api.md:330 completed = "Served HTTP and Decisions requests whose generation and output validation completed successfully; direct in-process ModelRuntime::generate* callers count model-generation completion".
    • docs/api.md:332 failed now names "output-decoding rejections and terminal event-budget overflow".
    • docs/api.md:349-354 is a NEW paragraph that documents flare_requests_cancelled_total for the first time, including "unread" served requests and the at-most-one-of-three invariant. This closes an operator-facing gap: cancelled had no prose definition before.
    • metrics.rs HELP: requests_completed_total metrics.rs:1077-1079, requests_cancelled_total :1087-1089; Snapshot::completed doc metrics.rs:91.
    • requests_failed_total HELP (metrics.rs:1092-1094) was deliberately NOT expanded; only docs/api.md:332 carries the output-decoding/event-budget detail — an asymmetry a reviewer can drop.
  3. docs/api.md line drift: the parallel-tool-limit note I cited at :700-702 is now :706-709, and still reads "runtime metrics count the request as cancelled rather than completed, despite the successful API response". So my open question #4 is unchanged by the doc commit (not fixed, not made wrong). docs/api.md:697-700 (:703 now) still say the response "completes normally"/"This applies to buffered and streamed requests".

  4. ResponseLifecycle harness now exercises the production terminal entry point — response_lifecycle_tests.rs:155 (observed-edge harness action 3) and :372 (terminal_stream_frames_retain_http_admission test) call emit_finished(...) instead of raw .emit(Finished{..}). This partially answers open question #1 and the review's "Should fix #2". BUT the harness still admits via generate_many (:122), i.e. defer_completion=false, so the deferred GENERATED->COMPLETED/CANCELLED half — the half the PR exists for — still has no TLA+/observed-edge coverage. docs/design-review.md:241-246 ("keep formal bounds aligned… additional lifecycle transitions") remains the gap.

  5. An Autobot review ran 2026-12-02 21:50 (PR comment): Changes Requested, 0 blockers, 2 should-fix, 2 subtract/simplify, 3 nits; it found the fix "technically sound… no correctness or concurrency blockers". Independently confirms: RequestOutcome :109-296; emit_finished :553-582 (pre-refactor numbering; now runtime.rs:465-492); generate_for_output; decoder abort idempotent at helios/src/server/output.rs:384-396; four worker cancellation sites :1650/:1670/:1683/:1738 (now :1563/:1583/:1595/:1650-1652). Author's 22:18 reply claims all items fixed: single transition() helper (runtime.rs:138-156), shared event_budget_exceeded (runtime.rs:493-501) used by both emit_finished (:488-490) and emit (:545-547), record_cancelled folded into Incoming::finish_cancelled (runtime.rs:434-435), 7 polling loops collapsed into wait_for_admitted (phase_tests.rs:8632), and a comment on the Closed arm (runtime.rs:482-487). All verified in the head files I re-read.

  6. Test evidence still self-reported and unverified: same counts (helios 1,884/84 ignored; flare 254/4; flare-cli 245/3; check.py --mutations 40 mutations, 365,508 ResponseLifecycle transitions) re-stated for 7f298698, but the numbers are byte-identical to the pre-fix run, and no CI has run on the new head either (the review's "no CI on 348c06c" is now stale by one commit). Post-change test line numbers: new integration tests phase_tests.rs:8647, :8707, :8775, :8808 with helpers :8441-8645; unit tests runtime.rs:4383 (outcome_terminal_budget_overflow_and_deferred_drop_orderings) and :4486 (outcome_concurrent_worker_and_consumer_transitions_record_exactly_one_metric). The lifecycle gate is real: .github/workflows/helios-lifecycle.yml:33-34 runs check.py on every PR touching helios/**, so the claim will be CI-checked — but that workflow runs check.py WITHOUT --mutations (:34), so the 40-mutation claim is not covered by CI. Rust gating tests: .github/workflows/native-serving.yml:56-63 (Linux, helios runtime-core,server, FLARE_TEST_TEMPLATE_DIR) and :64-68 (Windows) — the author's run used 512 MiB memlock where CI uses 64 MiB (prlimit … memlock=67108864), a divergence worth flagging.

  7. Python counter suites I flagged as unrun are GPU/service-gated, which softens (not removes) that gap: tests/server/test_protocols.py:22-24 and tests/server/test_decisions.py:16-18 both pytest.mark.skipif(not os.environ.get("FLARE_API_TEST_URL")), so python-cpu.yml:33 (pytest tests/ -q, CUDA_VISIBLE_DEVICES="") skips them. The assertions still encode old semantics: test_protocols.py:676 (n=4 disconnect -> cancelled rises) and test_decisions.py:230/257 (decision disconnect -> cancelled rises). The decisions one is the more at-risk: score() now always settles via fail_output on a dropped Generation, so a cancelled child still lands in cancelled only through on_reader_drop PENDING->READER_DROPPED -> record_cancelled; that path is preserved, so my concern is narrower than first stated: no test change is strictly needed, but nothing exercises it.

#8 [high] Research summary

Amendments are saved as scratchpad entry #7 and should be appended to report #6 ("Report of 2026-12-02, run 3064"); the rest of #1–#6 stands.

What changed: the PR moved to head 7f298698 and grew from 4 files (+1068/−32) to 7 files (+968/−46) — it now also touches helios/src/server/metrics.rs, docs/api.md and helios/src/server/runtime/response_lifecycle_tests.rs, and it acquired labels (area:api, bug, priority:P2, triage:review) plus a full four-section body. My earlier "no doc change is required" finding is superseded: docs/api.md:330/:332 were rewritten, and docs/api.md:349-354 is a new paragraph that documents flare_requests_cancelled_total, including unread served requests and the at-most-one-of-three-counter invariant; metric HELP strings at metrics.rs:1077-1089 were updated to match, though requests_failed_total HELP was left alone. The parallel-tool-limit note I cited at :700-702 has drifted to :706-709 and is unchanged in substance, so that open question stands.

Process: an Autobot review (21:50) returned Changes Requested with 0 blockers and found the state machine technically sound; the author replied at 22:18 claiming every item fixed, and I verified each fix in the head files (single transition() helper, shared event_budget_exceeded, record_cancelled folded into finish_cancelled, wait_for_admitted helper, Closed-arm comment). The ResponseLifecycle harness now routes terminal emission through emit_finished (response_lifecycle_tests.rs:155, :372), which closes half of my conformance gap — but it still admits via generate_many (:122), so the deferred GENERATED half remains unmodelled under docs/design-review.md:241-246.

Evidence: the re-verification numbers are byte-identical to the pre-fix run and no CI has run on the new head, so it is still self-reported. I also established that .github/workflows/helios-lifecycle.yml:34 (not opened) runs check.py without --mutations (so the 40-mutation claim is not CI-covered), that gating Rust tests run at 64 MiB memlock (native-serving.yml:56-68) while the author ran at 512 MiB, and that the Python suites I flagged as unrun are FLARE_API_TEST_URL-gated (test_protocols.py:22-24, test_decisions.py:16-18) and therefore skipped by python-cpu.yml — which narrows rather than removes that gap.

#9 [high] Verified head line numbers for 7f298698 (file map for the report)

Line numbers verified by reading files at PR head 7f298698 (supersede the pre-fix numbers in entries #1/#3/#6). Files are 7 total, +968/-46.

runtime.rs

http.rs

decisions/mod.rs

metrics.rs

docs/api.md

response_lifecycle_tests.rs

phase_tests.rs

CI/gates (verified in workflow files)