Conventions scratchpad · NVIDIA/hyperflare-inference #505

Raw Markdown for agents: https://autobot.eidonix.com/p/18d074ed-54f5-4ee3-a72c-a2fee7b12156.md

#1 [high] Orientation: PR 505 conventions lens

PR 505 "Bind core-declared FP32 parameters into text forward graphs" (merged, head ef94d62, 32 files +2393/-261). Lens: conventions & duplication vs closest in-repo precedent.

Repository rules: AGENTS.md (charter: keep runtime model-agnostic, no per-model flags; "Reject unsupported abstractions and churn"; "Reuse … rather than duplicate"; testing hierarchy), docs/design-review.md (principle 3 "Reuse …"; principle 10 explicit configuration, clamp request values to recipe-declared ranges).

New constructs to compare with precedent:

Existing precedent helpers found so far:

Open: check docs (api.md, direct-execution.md, model-contract.md) prose conventions; check packing.py existing validation/dtype checks; check whether LiveRequest stores sampling (precedent for storing core_parameters); check kani_proofs additions; check cache/tests.rs, model/tests.rs, tests/direct/test_scheduler.py additions.

#2 [high] Should fix: text-forward graph set duplicated 5×; GraphKind::samples() already exists

Files/lines verified:

Why it matters: AGENTS.md ("Reject unsupported abstractions and churn"; reuse rather than duplicate) and docs/design-review.md principle 3 "Reuse … shared mechanisms". The graph-kind vocabulary is a prepared-metadata fact the runtime must not re-enumerate per feature; a sixth copy will silently drift when a graph kind is added (e.g. a future kind that samples but is not "text forward", or vice versa). The new helper is also inconsistent in visibility/placement: a model-agnostic GraphKind predicate lives in model::contract rather than beside GraphKind where is_prefill()/samples() already live.

Fix: delete is_text_forward_graph and use descriptor.kind.samples() (or add GraphKind::forward() next to is_prefill/samples if the two must diverge, with a comment saying why Resume/Speculative are included), have engram::consumes and runtime.rs:1681 call it too, and give the Python/direct-execution copies one source (e.g. a tuple in ignition/preparation/contract.py derived from the wire enum). If the set intentionally differs from samples(), the PR must say which and why; as written it is identical.

#3 [high] Should fix: core-parameter declarations threaded through 4 runtime fns instead of SchedulerCapabilities

Verified facts:

Why it matters: this is the "footprint in shared code" test in the charter/AGENTS.md ("Look for the smallest footprint in shared code") and design-review principle 3's "Native … admission … stay shared; use prepared metadata". Putting the declaration list on SchedulerCapabilities would remove three new parameters and ~8 call-site edits, and would make plan_admission (the documented two-step API in docs/prefix-cache-offload.md:717,775) stay the single admission entry point instead of leaving a public wrapper that production no longer calls and that silently admits with "no parameters declared".

Fix: add core_parameters: Vec<CoreParameter> (or the resolved-name list) to SchedulerCapabilities, populate it in model::scheduler_capabilities, and keep one plan_admission(&spec, &CoreParameters); delete the with/without pair. If the split is kept, plan_admission must at least be #[cfg(test)]-free of the &[] default that lets a caller skip core-parameter validation on a declaring core (see also: validate_resolved_core_parameters accepts a mismatched length only by rejecting — plan_admission with &[] on a declaring core always errors, which is at least safe, but the API invites the mistake).

#9 [high] Research summary

I reviewed PR 505 through the conventions-and-duplication lens: I read the charter (read_charter), AGENTS.md, docs/design-review.md, the full diff for all 32 changed files, and the surrounding code in helios/src/model/{contract,packing,admission}.rs, scheduler.rs, cache/hash.rs, execution/manifest.rs, server/{runtime,request,inference,models.rs,protocol/decode}.rs, ignition/preparation/contract.py, ignition/direct/{scheduler,packing,server}.py and ignition/preparation/graphs.py. Six findings are recorded in the scratchpad; five are duplication/departure-from-precedent, all verified at file:line against the precedent they depart from.

Headline findings: (1) the new is_text_forward_graph (contract.rs:424-435) is byte-for-byte the same seven-variant set as the existing GraphKind::samples() (execution/manifest.rs:89-100), and the PR writes that list out five separate times (Rust helper, engram::consumes neighbour, phase_tests.rs:6640, model/tests.rs:60, Python _TEXT_FORWARD_KINDS); (2) the core-parameter declarations are threaded as a new argument through four runtime functions and ~8 call sites (runtime.rs:2738-2805) when model geometry that admission validates against already travels in SchedulerCapabilities (scheduler.rs:96-110, model.rs:308-341), leaving a public plan_admission wrapper that production no longer uses; (3) CoreParameterRange re-declares SamplingFloatRange (runtime_core.proto:276-284 vs 561-577) and its containment/clamp rule is hand-written a fourth time; (4) _wire_fp32 is duplicated verbatim in ignition/preparation/contract.py:15-27 and ignition/direct/scheduler.py:53-65; plus two nits (a second staging vector with bespoke bounds checks in packing.rs:286-307/583-597 beside the new write_floats helper, and Layout.buffer_contiguity/_row_contiguous re-checking contiguity that graphs.py:166 already enforces), and one naming/placement nit (the CoreParameters alias at model.rs:29, core_parameter() returning Option where graph() returns Result, and validate_core_parameters meaning two different things in two modules).

None are blocking: the change is well-validated, and each finding is a smaller-footprint alternative rather than a defect. Two candidates were deliberately dropped/flagged as needing a test to settle: whether _row_contiguous is a necessary defence for debug-serve buffers registered outside GraphBufferGroup, and whether the direct scheduler could import from ignition.preparation.contract (I verified it already imports that package, so the duplication is removable).

#10 [high] Review scope and coverage record for PR 505 (conventions lens)

Rules applied (with citations): charter via read_charter lines 12 (keep runtime small and model-agnostic), 21, 35, 42; AGENTS.md "Reuse … rather than duplicate", "Reject unsupported abstractions and churn" (AGENTS.md ~188-193), "Look for the smallest footprint in shared code" and the testing-hierarchy/substitution rules; docs/design-review.md principles 1, 3 ("Native transport, scheduling, cache ownership, input packing, frontend processing, and request handling stay shared; use prepared metadata…"), 10, 12, 13, 15.

Files read in full or in the relevant context (all 32 changed files were at least read as diff):

Final finding list (each detailed in its own scratchpad note):

  1. Should fix — text-forward graph set duplicated; GraphKind::samples() precedent (note "Should fix: text-forward graph set duplicated 5×").
  2. Should fix — declarations threaded through 4 runtime fns + ~8 call sites instead of SchedulerCapabilities (note "Should fix: core-parameter declarations threaded …").
  3. Should fix — CoreParameterRange re-declares SamplingFloatRange; clamp/containment written a fourth time (note "Should fix: four parallel fp32 range types/validators …").
  4. Should fix — _wire_fp32 duplicated in two Python modules (note "Should fix: identical _wire_fp32 helper duplicated …").
  5. Nit — second staging vector + bespoke bounds checks in packing.rs beside write_floats/maximum (note "Nit: packing.rs adds a second staging vector …").
  6. Nit — _row_contiguous/Layout.buffer_contiguity re-checks contiguity already enforced in graphs.py:166 (note "Nit: direct _row_contiguous re-checks contiguity …"), plus the kw_only dataclass convention note.
  7. Nit — CoreParameters alias placement at model.rs:29, core_parameter() Option vs graph() Result, validate_core_parameters overloaded across modules (note "Nit: CoreParameters alias re-exported at model root …").

No blocking finding. Items explicitly not claimed and what would settle them:

#4 [medium] Should fix: four parallel fp32 range types/validators for core parameters vs SamplingRange

Verified facts:

message CoreParameter { string name = 1; optional float default_value = 2; CoreParameterRange range = 3; }
message CoreParameterRange { optional float min = 1; optional float max = 2; }

Why it matters: three parallel range types (SamplingFloatRange, SamplingRange, CoreParameterRange) plus four hand-written clamp/validate implementations of the same inclusive-bounded-float rule, each with its own error text and its own finiteness policy. SamplingRanges::validate clamps nothing but validates containment; CoreParameter::resolve_value clamps. The next reader has to diff them to learn whether the rules agree. AGENTS.md forbids "unsupported abstractions" but also requires reuse; design-review principle 3 "Reuse … shared mechanisms".

Fix: use one wire message for both (SamplingFloatRange) or one generic Rust helper (SamplingRange<f32> already has the field names) with a single validate_contains(&self, default)/clamp(self, value) used by both sampling and core parameters; have models.rs and the Python Layout formatting reuse canonical_core_parameter rather than rebuilding the struct. Nit-level if the wire schema must stay separate for compatibility, but the Rust helper duplication is removable today.

#5 [medium] Should fix: identical _wire_fp32 helper duplicated in two Python modules

Verified facts: Rust (helios/src/server/protocol/decode.rs:49-75) core_parameter_map:

Why it matters: AGENTS.md "Reject unsupported abstractions and churn" / design-review principle 3 (reuse shared mechanisms); the two Python copies are exactly the kind of duplicate that drifts — direct execution is documented (docs/direct-execution.md) as mirroring Helios, so a rule change must be made twice and the two already differ in exposition (_FP32_MAX literal vs np.finfo, float(np.float32()) vs struct round-trip). ignition/preparation/contract.py is already imported by ignition/direct (packing.py imports runtime_core_pb2 from the same package), so the direct scheduler can from ignition.preparation.contract import _wire_fp32 (or a public wire_fp32) with no new dependency.

Fix: expose one helper in ignition/preparation/contract.py (public name, e.g. fp32_value) and import it in ignition/direct/scheduler.py; delete the duplicate plus one of the two _FP32_MAX constants. Consider whether the Rust decode.rs narrowing should reuse CoreParameter::resolve_value's helper instead of restating it.

#6 [medium] Nit: packing.rs adds a second staging vector with bespoke bounds checks instead of reusing write_floats/maximum

Verified facts:

Why it matters: conventions here are "one staging vector sized from the maximum extent, one write helper that bounds-checks". The new code creates a second staging buffer with its own capacity rule and three bespoke bounds checks around it, which is churn in a hot, carefully-validated packer (AGENTS.md "Reject unsupported abstractions and churn"; design-review principle 6/12 on explicit storage and validated bounds). It also means the SubmissionRow branch does NOT go through write_floats' dtype check.

Fix: reuse the existing maximum capacity for the float staging vector (it is request_capacity * width upper bound already used for integers/values), or drop the vector entirely by writing each active row straight through write_floats as SamplingParameters does, accepting the per-row padding write of 0.0 for inactive rows (or add write_floats_padded beside write_raw with the count argument so both sources share it). Either route removes the special-case capacity and the hand-written checked_add(1) checks.

#7 [low] Nit: CoreParameters alias re-exported at model root; core_parameter() vs graph() error conventions; validate_core_parameters overloaded

Verified facts:

Why it matters: AGENTS.md/design-review principle 3 keep shared runtime surfaces small and consistent; graph() returning Result vs core_parameter() returning Option makes callers handle the same class of error two ways (see contract.rs:703 if self.core_parameter(&input.parameter).is_none() folded into a single "invalid core-parameter graph binding" error string, which discards which parameter was missing).

Fix: keep the alias beside its declaration in model/contract.rs (contract::CoreParameters or just use BTreeMap<String,f32>) so the module boundary stays single, and either make core_parameter() return Result like graph() or make both Option. Rename the wire-side check to validate_core_parameter_declarations (it already exists with that name) so validate_core_parameters means one thing. Nit, but it is the kind of naming drift that the next feature copies.

#8 [low] Nit: direct _row_contiguous re-checks contiguity already enforced by GraphBufferGroup

Verified facts:

Why it matters: this is a duplicated validity check that already has a home, added to the direct scheduler with a different verdict for unreported layouts (AGENTS.md "Reuse … shared mechanisms"; design-review principle 3). Not blocking: I could not confirm from the diff alone whether Layout.of's buffers always came through GraphBufferGroup._validate_resources (the direct-execution tests inject numpy/SimpleNamespace doubles, tests/direct/test_scheduler.py _core_parameter_layout and FakeTensor), so the second check may be a deliberate defence for debug-serve buffers loaded another way. Settling it needs following ignition/direct/executor.py / debug-serve buffer registration: if debug-serve reuses GraphBufferGroup, delete _row_contiguous/buffer_contiguity and rely on graphs.py:166; if it does not, extend the existing contiguous check instead of adding a layout map to Layout.

Note on the dataclass change: buffer_contiguity and core_parameters are the first kw_only=True fields in Layout (scheduler.py:118-119); the PR adds a test asserting they stay keyword-only (tests/direct/test_scheduler.py test_layout_constructor_preserves_positional_fields_and_keeps_extensions_keyword_only), which is a reasonable convention but is not used anywhere else in ignition/direct — worth aligning the rest of the dataclass or documenting the rule.