Correctness report · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/0cc2abc4-e8bb-4e06-bc08-4b51155593b8.md

Review of PR #540 at head 982a9ce3 — correctness lens

Key findings

Verdict: should-fix issues only (one documentation defect); no blocking correctness defect found in the code.

The PR was rewritten at 982a9ce and no longer contains the SAM/copy-draft/draft_source code that earlier review rounds of this PR discussed; those earlier findings are obsolete and not repeated here.


Should fix

Current text:

Ordinary valid execution earns refresh credit at 0.002 / 0.998 times its measured duration, capped at 5 ms. … Refresh pays for one complete physical program, including its proposal and verification work. Another refresh waits for full credit. Idle discards positive credit and preserves debt.

Both highlighted clauses are now wrong for the shipped runtime:

Why it matters: helios/README.md:439 links to ../docs/scheduling-runtime-design.md#funded-timing-refresh, which now states the opposite rule (docs/scheduling-runtime-design.md:436-444: compute duration excluding readiness wait; "Idle retains bounded earned credit (<= 5 ms) and negative debt; abort discards positive credit and preserves debt"). The same rule is restated at docs/scheduling-runtime-design.md:492-499 for acceptance learning. A reader of the runtime README is told that a 1-second-burst workload can never fund a refresh, which is exactly the defect this PR fixes. AGENTS.md:52-58 requires repository documents to "State support as present qualification: what is implemented" and to mark anything not implemented as "designed, not implemented"; this passage is neither — it is stale. The PR updates the two design docs and the simulator docs but leaves the runtime README untouched.

Fix: rewrite those two sentences to match the design doc — credit is earned from measured compute execution duration excluding measured readiness wait (with samples whose device interval does not exceed readiness wait earning nothing, matching ActionCosts::observe), and idle retains bounded earned positive credit (<= 5 ms) plus negative debt, while abort discards positive credit and preserves debt. Optionally add one sentence that a wait_ns >= gpu_ns refresh completion charges unexcluded physical/wall time.

Nit

1. helios/src/scheduler/cost.rs:303-305 — refresh_order sentinel collides with a genuine observed_at_ns == 0

refresh_order returns observed_at_ns.max(last_attempt_ns) (line 304) and map_or(0, …) for a missing entry; 0 therefore means both "no observation" and "observed when now_ns was 0". The refresh selection sorts ascending by this key, so such a key would get top priority. In practice ActionCosts::prepared starts observed_at_ns = 0 and advance_to moves now_ns forward past the first completion, and stale_keys (cost.rs:298-301) already excludes entries with nanos == 0 that are not fresh, so a stale entry can only carry 0 if it also has nanos != 0 — i.e. it was observed in the same instant the clock started. Behaviour matches main; the note is only because the PR body argues about this ordering as the starvation guard. No change required; if desired, use Option<u64> keyed to (nanos != 0).then_some(observed_at_ns) as observation() already does at cost.rs:314-318.

Verified non-defects (traced in code)

Open questions / what could not be confirmed

Link: https://github.com/NVIDIA/hyperflare-inference/pull/540