Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #397

Raw Markdown for agents: https://autobot.eidonix.com/p/32f82700-0b7f-4bec-8a60-bb5c1d54eb92.md

#1 [high] #397 lens findings: correctness/contracts/system-level (with citations)

PR #397 head b49b3675, helios/src/runtime_core/mod.rs +20/-0 (3 hunks: :790-794 map, :892-900 guard, :985-990 log).

F1 (Blocker, correctness): guard matches ANY non-zero status for ANY zero-payload recorded attribute id. File: helios/src/runtime_core/mod.rs:892-901

if status != 0 && value.iter().all(|word| *word == 0) {
    *skipped_attributes.entry((attribute.id, status)).or_insert(0) += 1;
    continue;
}
driver.check("cuGraphKernelNodeSetAttribute", status)?;

main's equivalent: driver.check("cuGraphKernelNodeSetAttribute", status)?; at main helios/src/runtime_core/mod.rs:1017 (verified at ref main). driver.check body: helios/src/runtime_core/driver.rs:177-199 returns Err for any status != 0. So statuses 3 (NOT_INITIALIZED), 4 (DEINITIALIZED), 700 (ILLEGAL_ADDRESS), 719 (LAUNCH_FAILED), 909 (CONTEXT_IS_DESTROYED) — context-fatal/sticky — are converted into "skip and keep building the graph"; load continues into cuGraphInstantiateWithFlags/cuGraphUpload (:1036-1046) and later serving on a possibly poisoned context. Impact: loss of fail-fast + precise operation name; worst case a load that "succeeds" and then misbehaves at serve time.

F2 (Blocker, contract/claim accuracy): the stated purpose ("attributes added after the driver's CUDA release") is impossible to reach — validate_node allowlists ids, so a genuinely newer attribute id is rejected before the skip. helios/src/runtime_core/format.rs:570-579

for a in attributes {
    if ![1, 2, 4, 5, 8, 9, 10, 11, 14].contains(&a.id)
        || a.value.data.len() != 64
        || !ids.insert(a.id)
    { return Err(invalid("unsupported or duplicate kernel-node attribute")); }

Called per node at mod.rs:798 before the attribute loop. Note the allowlist (9 ids) is even narrower than the exporter's KERNEL_ATTRIBUTES (10 ids incl. 13, heliopause/src/export/capture.rs:462). So the guard can only ever fire for ids 1,2,4,5,8,9,10,11,14 — all known to the driver family. Also exporter zero-fills absent attributes (capture.rs:857-887: emits zero for 1,2,4,5,8,9,10 always; 11 unless recorded; 14 unless all-zero), so zero payloads are the exporter's normal encoding, not evidence of an unknown attribute.

F3 (Major, system-level/observability): unconditional, unranked, unsynchronized stderr writes inside the per-rank loader threads. helios/src/runtime_core/mod.rs:985-990 eprintln with only graph.name, no rank. prepare_graphs runs concurrently per rank: helios/src/runtime_core/model.rs:876-899 (thread::Builder::new().name(format!("flare-load-{index}"))), and errors that do propagate get a rank prefix at model.rs:885 (invalid(format!("rank {index}: {error}"))). With TP2 both ranks print identical lines and nothing says which rank. No gate on diagnostics: contrast helios/src/server/runtime.rs:686 if log_to_stderr { eprintln!("warning: {warning}"); }, server/session.rs:35 bootstrap.server.log_to_stderr = false;, helios/README.md:114-115 "StartupProgress::observed exposes a bounded latest-stage snapshot without terminal output, and owned sessions disable stderr diagnostics by default". An in-process SDK host cannot suppress this line. Interleaving with the startup banner: startup.rs:310-325 (non-terminal writes every 10s) and startup.rs:555-581 Output::redraw does cursor-relative overwrite (write!(out, "\x1b[{}A", self.drawn_lines - 1) then \r\x1b[J), tracked in drawn_lines; unprefixed lines emitted mid-phase from 2 loader threads desynchronize that bookkeeping.

F4 (Major, metrics/observability span): the skip is not surfaced anywhere but stderr — no counter in Server::snapshot gauges (helios/README.md:103-121 documents /metrics and typed gauges), so an operator cannot tell a clean load from one that dropped recorded launch state.

F5 (Major, docs/contract): the tolerance is undocumented and contradicts the documented single-tolerance statement. docs/runtime-core-design.md:769-778: "If restoring the cooperative launch attribute returns CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE, the loader ... reduces the largest grid dimension to fit ... and retries the attribute once. A grid that cannot fit by reducing one dimension rejects loading." Limitations (docs/runtime-core-design.md:896-911) list no attribute-skip tolerance, and docs/core-format-design.md:219 still describes attributes only as "launch attributes". docs/design-review.md:103-110 (principle 13) requires old cores to load validated "through loading and serving"; this change achieves compatibility by dropping recorded state instead.

F6 (Blocker, charter verbatim): AGENTS.md:177-181 "Reject weakened guarantees. Preserve complete cache and speculative state ... Do not remove validation, suppress errors, silently substitute execution paths ..."; AGENTS.md:189-194 requires tests that "exercise the affected behavior or contract". docs/design-review.md:122-133 (principle 15) repeats the rejection criteria.

F7 (Major, tests): no in-repo test reaches the new branch. The existing replay fixtures do not set attributes except the cooperative one: helios/tests/cooperative_core_fixture.py:99-116 (only id 2, and it asserts the driver's status), helios/src/runtime_core/cooperative_tests.rs:41-81 (loads that fixture). The harness shape that would prove this exists (payload fixture + NativeResources::load + ReplayWorker), but a conforming driver cannot be made to reject a known id, which is itself the argument that the branch is unprovable — supporting F2. Unit-only evidence (cargo test --lib) cannot reach it.

F8 (Minor, claim accuracy): PR body log sample no longer exists. PR text: "skipping kernel-node attribute id=11 rejected by this driver (status=1) in graph vision32768 node 0" Head code (mod.rs:986-989): "graph {}: skipping zero-valued kernel-node attribute id={} on {} node(s); rejected by this driver (status={})" — no node index, aggregated per graph. b49b3675 replaced per-node lines; the description (and the 37,496-line figure, which aggregation would collapse to a handful) still reflects the pre-aggregation build.

Areas verified sound: BTreeMap is per-graph and bounded (<= ~9 keys); no new allocation on the hot replay path beyond the entry insert; no locking added; continue is semantically inert (nothing follows the check in the loop body); Windows/Linux parity unaffected (no cfg in this path); the cooperative id-2 clamp path (mod.rs:880-891) is unchanged and still aborts on a failed retry with a non-zero value; non-zero payloads still fail at :901.

#3 [high] #397 lens: verified quotes (banner, suppression, rank labels, docs, fixtures)

Verified quotes for the finish report.

startup.rs:568-580 (banner redraw is cursor-relative and tracked):

let visible = &lines[lines.len().saturating_sub(height.saturating_sub(1).max(1))..];
let mut out = std::io::stderr().lock();
if self.drawn_lines > 1 {
    let _ = write!(out, "\x1b[{}A", (self.drawn_lines - 1).min(height.saturating_sub(1)));
}
let _ = write!(out, "\r\x1b[J{}", visible.join("\n"));
let _ = out.flush();
self.drawn_lines = visible.len();

startup.rs:310-325: non-terminal progress lines every 10s; terminal 125ms redraw.

Suppression contract: helios/README.md:114-115 "StartupProgress::observed exposes a bounded latest-stage snapshot without terminal output, and owned sessions disable stderr diagnostics by default."; helios/src/server/session.rs:35 bootstrap.server.log_to_stderr = false;; helios/src/server/runtime.rs:686 if log_to_stderr { eprintln!("warning: {warning}"); }. The new eprintln at mod.rs:986 has no such gate.

Rank labelling: model.rs:883-886 spawn_scoped closure operation(rank, core, archive).map_err(|error| invalid(format!("rank {index}: {error}"))) — rank prefix exists only on the error path.

Docs: docs/runtime-core-design.md:769-778 (cooperative clamp is the one documented tolerance; "A grid that cannot fit by reducing one dimension rejects loading."), :896-911 limitations have no attribute-skip entry; docs/core-format-design.md:219 attributes described as launch attributes only; docs/design-review.md:103-110 principle 13 (load old cores, validate through loading and serving).

Charter: AGENTS.md:177-181 "Reject weakened guarantees ... Do not remove validation, suppress errors, silently substitute execution paths ..."; AGENTS.md:189-194 tests must exercise the affected contract; docs/design-review.md:122-133 principle 15.

Fixtures: helios/tests/cooperative_core_fixture.py:99-116 only sets id 2 and asserts the returned status; helios/src/runtime_core/cooperative_tests.rs:41-81 is the GPU harness that would be the shape for a skip test.

#4 [high] Research summary

I reviewed PR #397 (head b49b3675, +20/−0 in helios/src/runtime_core/mod.rs) through the correctness/contracts/system-level lens. Every finding below was verified by opening the PR head, main (c146d7be), the exporter in heliopause/src/export/capture.rs, the fixtures, and the design docs. Notes with exact quotes are in scratchpad entries 1–3.

Findings (details, verbatim quotes and fixes in scratchpad #1):

Verified sound: the map is per-graph and bounded; no new locking or hot-path allocation; continue is semantically inert; Windows/Linux parity unaffected; the id-2 clamp path and non-zero-payload failure path are unchanged. The one merge hazard: the hunk sits on the pre-#430 form of the loop, so it must be re-applied over main's green-context version (main:894-912, :1002-1016).

Verdict for this lens: request changes — the field failure is real, but this diff suppresses an error class it cannot explain, at the loader, without a test or any operator-visible signal, and its own justification is contradicted by the validator that runs immediately before it.

#5 [high] #397 lens: consolidated verdict + severity table (report skeleton)

Lens: Correctness, Contracts & System-Level Consequences. PR #397, head b49b3675, base 8b177cf1, main c146d7be. Change = helios/src/runtime_core/mod.rs +20/−0, three hunks (:790-794 map, :892-900 guard, :985-990 log). Full detail in entries 1 (findings + quotes), 2 (main-side context/merge hazard), 3 (verified quotes: banner, stderr gating, rank labels, docs, fixtures).

VERDICT: request changes. The field failure is real; this diff suppresses an error class it cannot explain, at the loader, with no test and no operator-visible signal, and its justification is contradicted by the validator that runs immediately before it.

FINDINGS, in report order:

  1. BLOCKER — guard is status- and id-agnostic. mod.rs:892-901 vs main:1017 + driver.rs:177-199. Any non-zero status (incl. context-fatal 3/4/700/719/909) on any zero-payload id becomes a skip; load continues to mod.rs:1036-1046 instantiate/upload and then serving. Fix: gate on the specific id(s) the exporter can emit and on a documented recoverable status set, or fix the exporter/driver-compat layer instead.
  2. BLOCKER — stated cause unreachable in this path. format.rs:570-579 allowlist rejects unknown ids at :798 before the attribute loop; capture.rs:857-887 zero-fills absent attributes. So the branch can only fire for ids every supported driver knows; the author's own probe returns 0 for the exact call. Fix: establish the real cause first (per dossier: #2's forward-compat-library remedy), or make the export side drop/re-encode the attribute (dcb1d7b1 precedent).
  3. MAJOR — observability/system-level regression. mod.rs:985-990: per-rank, no rank label (parallel loader model.rs:876-899, rank prefix only on errors model.rs:885); ungated by log_to_stderr (server/runtime.rs:686, server/session.rs:35, README.md:114-115); desynchronizes banner redraw (startup.rs:310-325, :568-580); no metric (docs/api.md:285-292). Fix: route through the existing progress/warning channel with rank label and a counter, or emit nothing.
  4. MAJOR — undocumented contract change. docs/runtime-core-design.md:769-778 (cooperative clamp is the only stated tolerance; unfit grid "rejects loading"), :896-911 (no attribute-skip limitation), docs/core-format-design.md:219. Fix: document any accepted tolerance and its trigger, with maintainer sign-off.
  5. BLOCKER (charter) — AGENTS.md:177-181 ("Do not remove validation, suppress errors, silently substitute execution paths"), AGENTS.md:189-194, docs/design-review.md:122-133. Fix: none available at this layer; needs a maintainer decision on the design (dossier: #2 compat-libs / minimum-driver diagnostic).
  6. MAJOR — no test reaches the branch. Only attribute fixture is helios/tests/cooperative_core_fixture.py:99-116 (id 2, asserts status); harness shape exists at cooperative_tests.rs:41-81. cargo test --lib cannot reach it. Fix: a fixture-based test that forces a rejection status and asserts both the skip (zero) and the abort (non-zero) branches.
  7. MINOR — claim accuracy: PR text quotes "skipping kernel-node attribute id=11 ... in graph vision32768 node 0"; head mod.rs:986-989 aggregates per graph with no node index, so the "37,496 skip lines" figure is from the pre-aggregation build.

SOUND (state plainly): BTreeMap per graph and bounded (<= ~9 keys); no new locking, no hot-path allocation beyond an entry insert; continue is inert (nothing follows in the loop body); no platform cfg in the path, so Windows/Linux parity unchanged; id-2 cooperative clamp (:880-891) and the non-zero-payload abort (:901) unchanged.

MERGE HAZARD (not a diff defect): hunk sits on the pre-#430 loop; main has (graph_context, upload_stream, partition_sms) at :894-912 and status == 720 || (status == 0 && partition_sms.is_some()) at :1002-1016 — naive resolution drops the green-context re-clamp.

#2 [medium] #397 lens: main-side context for the guard's insertion point

main (c146d7be) helios/src/runtime_core/mod.rs:865-1018: prepare_graphs now selects (graph_context, upload_stream, partition_sms) per graph (main :894-912) and the id-2 clamp condition is status == 720 || (status == 0 && partition_sms.is_some()) (main :1002-1016), with driver.check("cuGraphKernelNodeSetAttribute", status)? at main :1017. PR head still has the pre-#430 form at mod.rs:880 (... && status == 720) — verified by reading PR head :867-902. So the PR hunk must be re-applied on top of #430; if resolved naively, the clamp regression (green-context re-clamp) is a merge hazard, not a diff defect.

Also verified: prepare_graphs is where "Prepare execution" progress lives — model.rs:736-745 builds progress.phase("Prepare execution", Some(nodes)), and StartupStage::PrepareExecution is "prepare_execution" (startup.rs:40, :81). Errors from a rank are wrapped with a rank prefix only on the final Err (model.rs:885), so the new eprintln is the only per-rank message with no rank label.