Architecture report · NVIDIA/hyperflare-inference #540

Raw Markdown for agents: https://autobot.eidonix.com/p/ad42ca77-0a96-4c7e-b73a-ca42cad3e1e7.md

Architecture & scope review — PR #540, head 982a9ce3 (base main 353551e9)

10 files, +647/−47 (docs/scheduling-runtime-design.md, docs/scheduling-theory.md, helios/src/scheduler.rs, helios/src/scheduler/cost.rs, helios/src/scheduler/policy_tests.rs, helios/src/scheduler/refresh.rs, scripts/scheduling_sim/learning.py, scripts/scheduling_sim/learning_policy.py, tests/test_scheduling_learning_experiments.py, tests/test_scheduling_learning_policy.py).

Judged against the charter (Autobot charter lines 12, 14, 35, 42), AGENTS.md (scope/rejection L188-199, task→doc map L227, compatibility L431-444) and docs/design-review.md ("Testing hierarchy" L171-203; principles 1, 3, 12, 13, 15).

Key findings

Verdict: should-fix issues only. No blocking correctness or architecture defects; the approach belongs in this repository and is the right place for the fix.

Should fix

S1. helios/README.md:437 (unchanged file) still states the rule this PR deletes, and omits the readiness-wait exclusion. The paragraph at helios/README.md:432-439 reads: "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." That is exactly the behaviour removed here: RefreshState::idle is gone from helios/src/scheduler/refresh.rs (only complete :71-93 and abort :95-99 remain, and abort does credit_ns.min(0.0)), and RequestScheduler::idle (helios/src/scheduler.rs:1158-1168) now only asserts submissions.is_empty() and keeps bounded credit (<= CREDIT_CAP_NS, refresh.rs:9) and debt. The same paragraph also says nothing about the new readiness-wait exclusion. Why it matters: AGENTS.md:227 names helios/README.md as required reading for "Change Helios runtime, scheduling, caches, transport, or frontend"; the runtime's own description of the funded-refresh policy now states the opposite of the code, and AGENTS.md:165-166 admits inaccurate documentation as a contribution category — inaccurate documentation of the very behaviour being changed is not shippable. docs/scheduling-runtime-design.md:434-474 and docs/scheduling-theory.md:727-738 were updated; helios/README.md was missed. Fix: rewrite helios/README.md:432-439 to state that ordinary valid execution earns 0.002/0.998 of measured compute duration excluding readiness wait (cap 5 ms), that idle retains bounded earned credit and negative debt while abort discards positive credit, and that a refresh episode pays its compute duration excluding readiness wait (falling back to unexcluded physical/wall duration when the GPU sample does not exceed readiness wait).

S2. scripts/scheduling_sim/learning_policy.py:47 — retain_idle_credit: bool = False leaves the simulator's default modelling the policy Helios no longer has. LearningScheduler::idle (scripts/scheduling_sim/learning_policy.py:671-677) only skips credit_ms = min(0.0, credit_ms) when the flag is set; Helios has no such switch — after this PR RequestScheduler::idle (helios/src/scheduler.rs:1158-1168) retains unconditionally. So after merge, a default retained-refresh simulator run models a rule the runtime does not implement, and the flag is only reachable as an explicit CLI option (learning.py:109) or an explicit --configs field (learning.py:48-56 configuration_id produces …:retain_idle_credit=True) — for --preset validate, the flag form is rejected outright (learning.py:479-484: "validation policy parameters come exclusively from --configs"), so the mandated catalog cannot express it on the command line at all. Why it matters: docs/design-review.md:200-201 — "Do not diverge Helios from the simulator's qualified policy without updating and validating the rule across that catalog"; and AGENTS.md:188-190 — "Do not add … configuration switches without a concrete requirement". The PR's own prose concedes the divergence: docs/scheduling-theory.md:730-733 ("Without --retain-idle-credit, idle discards positive credit … with --retain-idle-credit (as in Helios)"). Helios is now the definition of correct, so the default should follow it. Fix: default retain_idle_credit=True for retained-refresh (keep a documented opt-out for reproducing main), or make the value mandatory in PolicyConfig.__post_init__ (learning_policy.py:85-88 already uses that mechanism for funded/estimator). Add one sentence to docs/scheduling-theory.md:730-733 that the 64-seed --preset validate run encodes the setting in the --configs JSON, so operators do not try the flag against the preset.

Nits

N1. helios/src/scheduler/cost.rs:31-45 — "compute duration" and "Mirrors ActionCosts::observe" overstate the formula. observed_compute_duration_ns returns max(gpu_ns, wall_ns) - wait_ns for isolated executions (:43-44), whereas ActionCosts::observe (cost.rs:330-353) records the GPU interval less wait and never uses wall_ns. The docstring at :33 claims parity, and the new prose at docs/scheduling-runtime-design.md:436-441 / docs/scheduling-theory.md:734-737 calls the quantity "compute execution duration". The max-with-wall term is inherited from observed_duration_ns (:21-29) and is not new, but the naming and the parity claim are. Fix: narrow the docstring/prose to "device interval (or isolated wall time) less readiness wait", or credit income on gpu_ns - wait_ns and keep the wall-inclusive form only as the strictly-positive charge fallback the design actually needs.

N2. helios/src/scheduler/cost.rs:53-57 dead fallback, and helios/src/scheduler.rs:1158-1168 now an assertion-only API. timing_refresh_duration_ns's third term unwrap_or(timing.wall_ns) is unreachable for validated completions: RefreshState::validate_completion (refresh.rs:63-68) rejects a probe whose observed_duration_ns is None and wall_ns == 0, so the second fallback always fires first. Reduce to observed_compute_duration_ns(..).or_else(|| observed_duration_ns(..)).unwrap_or_default() with a comment naming the reachable callers. Separately, RequestScheduler::idle is now purely a precondition check (submissions.is_empty()), called once per idle-loop iteration from helios/src/server/runtime.rs:1184; either fold the assertion into the doc sentence and drop the method, or state in the doc comment that the retention rule is the only remaining semantics.

Verified positives (no action)

Open questions for maintainers

  1. docs/design-review.md:190-201 requires that timing-estimation/funded-refresh changes be qualified against the simulator catalog. Should the qualified retained-refresh policy simply become the idle-retaining one (S2), making the flag temporary? That would remove the divergence permanently instead of documenting it.
  2. Is the wall-inclusive term in timing-refresh income intentional (N1)? Charging refresh debt on max(gpu, wall) - wait while the funded estimate uses the device interval alone means a refresh can be charged more than the cost it updates. No test or doc justifies that asymmetry.
  3. Is idle() still needed as an API (N2), or is a documented invariant on RequestScheduler enough?

What I could not verify