Subtraction and simplicity scratchpad · NVIDIA/hyperflare-inference #688

Raw Markdown for agents: https://autobot.eidonix.com/p/121045e6-e831-4632-b567-4de348b9ca84.md

#1 [high] Manifest layout errors follow a format!-expected/got convention the two new literals break

In the same function ExecutionManifest::validate, layout failures are reported with format! printing the expected shape and the actual dtype/shape:

helios/src/execution/manifest.rs:632-641

                    return Err(Error::execution(
                        ExecutionError::Manifest,
                        format!(
                            "completion_logprobs: expected Int32 shape {expected:?} with \
                             even last extent {}..={LOGPROB_FIELDS}; got {:?} shape {:?}",
                            LOGPROB_PAIR_FIELDS * 2,
                            output.dtype,
                            output.shape,
                        ),
                    ));

helios/src/execution/manifest.rs:643-652

                    if flags.dtype != Dtype::Int32 || flags.shape != [self.request_capacity()] {
                        return Err(Error::execution(
                            ExecutionError::Manifest,
                            format!(
                                "logprob_requested: expected Int32 shape {:?}; got {:?} shape {:?}",
                                [self.request_capacity()],
                                flags.dtype,
                                flags.shape,
                            ),
                        ));
                    }

and the required-buffer table at :801-817 uses format!("invalid required buffer layout: {name}").

The two strings this PR rewrites break that convention:

Neither prints the offending buffer's dtype/shape nor the graph name, so the reader must reconstruct which of the 8 predicate conditions failed and what the actual values were. Unchanged predicates: :827-829 (Float32, rank 3, shape[0]==2, shape[1]==request_capacity(), 1..T contains shape[2]) and :861-870 (Speculative, confidence_width==draft_tokens, dtype/shape, shape[2]>=confidence_width, shape[2]<=T-1).

Suggested replacement (mechanical, no prose copy, more diagnostic): :830 -> return Err(format!("proposal_confidence: expected Float32 shape [{}, {}, {}..{}]; got {:?} shape {:?}", 2, self.request_capacity(), 1, self.completion_token_capacity - 1, buffer.dtype, buffer.shape).into()); :871 -> same form, prefixed with the graph name ({} confidence output requires ..., graph.name).

Also relevant: request_capacity() = max_active.next_power_of_two() at :583-585, and helios/manifest.md:211-213 already defines "Request storage capacity is max_active.next_power_of_two()", so spelling the formula out inside an error string is a third home for it.

#2 [high] New 64-line test duplicates existing setup and covers rejection, not just messages

New test helios/src/execution/tests.rs:1334-1396 proposal_confidence_validation_describes_submission_row_layout.

Duplicated setup — tests.rs:1339-1351 is byte-for-byte the configuration already built by the neighbouring test at tests.rs:1319-1326:

    value.graphs[0].kind = GraphKind::Speculative;
    value.graphs[0].token_capacity = 6;
    value.graphs[0].draft_tokens = 5;
    value.graphs[0].packed_token_capacity = 24;
    value.graphs[0].confidence_width = 5;
    value.buffers.push(BufferDescriptor {
        name: "proposal_confidence".into(),
        address: 0x20000,
        nbytes: 2 * 4 * 5 * 4,
        dtype: Dtype::Float32,
        shape: vec![2, 4, 5],
        strides: vec![20, 5, 1],
    });
    value.validate().unwrap();

vs tests.rs:1319-1327 (eight_token_completions_accept_shorter_proposal_confidence, same kind/token_capacity 6/draft 5/packed 24/width 5 and the same proposal_confidence buffer with shape [2,4,5], strides [20,5,1], nbytes 245*4).

Graph-arm rejections also already exist at tests.rs:1161 (width_mismatch, confidence_width 4 vs draft 3, asserting is_err()) and tests.rs:1163-1168 (buffer too shallow), and the buffer-shape/dtype rejections are the same family as tests.rs:40-47 (optional_speculative_survival_validates_frame_layout).

Unique value of the new test is only the message text: it should assert the two error strings. Everything else (the 4-row (shape, strides, nbytes, dtype) table at :1354-1371, the three-clone graph matrix at :1373-1395) can move to the existing tests as clone + one field mutation, or be dropped.

Negative assertions are asymmetric and weaker than they look:

Recommended shape of the replacement (~10 lines, added to confidence_readback_is_declared_per_graph_and_bounded_by_frame_capacity or kept as a small test):

let mut invalid = value.clone();
invalid.buffers.last_mut().unwrap().shape = vec![2, 3, 5];
assert!(invalid.validate().unwrap_err().to_string().contains(...));

Note: with the format!-expected/got message suggested in the other note, these substring assertions become expected Float32 shape [2, 4, 1..16] style and stay stable.

#3 [high] Research summary

Lens: subtraction, simplicity and conventions. The diff is small (+79/−8) and contains no code paths, flags, wrappers, fallbacks or dead code — the only executable change is two Err(...) string literals at helios/src/execution/manifest.rs:830 and :871, whose predicates are untouched. So nothing can be deleted from the logic; the three findings are about replacing what the PR added, not removing behaviour.

Finding 1 (highest value, code convention): the two rewritten messages break the module's own diagnostic convention and, in getting longer (229 and 262 chars), got less informative. Every other layout failure in the same function prints the expected shape and the actual dtype/shape via format! — manifest.rs:632-641 ("completion_logprobs: expected Int32 shape {expected:?} ...; got {:?} shape {:?}"), :643-652 ("logprob_requested: expected Int32 shape {:?}; got {:?} shape {:?}"), :801-817 (format!("invalid required buffer layout: {name}")). The two new literals print neither the offending values nor the graph name, so a reader cannot tell which of the eight predicate clauses (:827-829, :861-870) failed. Concrete replacement: emit format!("proposal_confidence: expected Float32 shape [2, {}, 1..{}]; got {:?} shape {:?}", self.request_capacity(), self.completion_token_capacity - 1, buffer.dtype, buffer.shape), and the graph arm likewise prefixed with graph.name. That removes the prose copy-paste of the layout formula into an error string (request_capacity() is already defined at :583-585 and helios/manifest.md:211-213) while adding the diagnosis the PR says it wants.

Finding 2: the new 64-line test (helios/src/execution/tests.rs:1334-1396) re-creates a manifest that already exists verbatim in the neighbouring test — tests.rs:1319-1327 in eight_token_completions_accept_shorter_proposal_confidence builds the identical speculative graph (token 6 / draft 5 / packed 24 / width 5) and the identical proposal_confidence buffer (shape [2,4,5], strides [20,5,1], nbytes 2*4*5*4). The graph-arm rejections it re-derives already exist at tests.rs:1161 and tests.rs:1163-1168. Its only unique value is the two message assertions, which need about five lines appended to an existing test. The negative assertions are also weaker than they look and asymmetric: tests.rs:1370 checks !error.contains("request slot") while :1394 checks !error.contains("request_slots") — neither substring contains the other, so each arm cannot catch a regression to the other arm's old wording. One uniform check, or none, is both simpler and stricter.

Finding 3 (documentation subtraction): the same normative sentence — [2, request_capacity, draft_capacity], request_capacity = max_active.next_power_of_two(), submission rows, draft depth 1..=T−1 — is now stated in full in five places: manifest.rs:830, manifest.rs:871, helios/manifest.md:164-169, helios/model-contract.md:227-233, helios/README.md:301-304. There is a clear normative home (helios/manifest.md, the execution-manifest spec), so the other two Helios docs and the two error strings can cite it rather than restate it — that is the form most likely to survive the next contract change. Two identifiers are also borrowed without definition in the new text: T is never introduced in helios/model-contract.md or helios/README.md (it is defined only at helios/manifest.md:160-161), and draft_capacity is not defined anywhere in the three docs, while helios/model-contract.md spells the adjacent axis T−1 and the manifest uses the predicate 1..self.completion_token_capacity (manifest.rs:829). Also worth noting for the conventions lens, and consistent with the dossier: three top-level docs/ sites still print the old [2, request_slots, draft_capacity] (docs/core-design.md:1228, docs/runtime-core-design.md:715, docs/scheduling-runtime-design.md:82 (not opened)), so the PR's "aligned all three specifications" is true of helios/* only.

No structural AGENTS.md violation found in the code: no configuration switch, no model branch, no relaxed validation, and the acceptance set is unchanged. Full detail with verbatim quotes is in scratchpad entries 1 and 2.

#4 [high] Same layout sentence now stated in five places; T and draft_capacity undefined in two of them

The contract [2, request_capacity, draft_capacity] = [2, max_active.next_power_of_two(), 1..=T−1], submission rows, is now stated in full in five places:

  1. helios/src/execution/manifest.rs:830 (buffer arm) return Err("proposal confidence requires [2, request_capacity, draft_capacity] float32 frames indexed by submission row (sized to max_active.next_power_of_two()) and draft depth 1..=T-1".into());
  2. helios/src/execution/manifest.rs:871 (graph arm) return Err("confidence output requires a speculative graph whose confidence_width equals draft_tokens and [2, request_capacity, draft_capacity] float32 submission-row frames covering confidence_width within draft depth 1..=T-1".into());
  3. helios/manifest.md:164-169 survival outputs have T−1 positions. Proposal-confidence buffers (proposal_confidence) are contiguous float32storage with shape[2, request_capacity, draft_capacity], indexed by completion frame, submission row (sized to request_capacity = max_active.next_power_of_two()), and draft depth 1..=T−1, covering each graph’s confidence width.
  4. helios/model-contract.md:227-233 A program producing confidence declares confidence_width, equal to its actual D. proposal_confidenceis contiguous FP32 storage with shape[2, request_capacity, draft_capacity], where request_capacity = max_active.next_power_of_two()anddraft_capacityis in draft depth1..=T−1 covering every declared output width.
  5. helios/README.md:301-304 A produced confidence sidecar declares confidence_widthand uses two FP32 frames shaped[2, request_capacity, draft_capacity]indexed by submission row (sized tomax_active.next_power_of_two()) and draft depth 1..=T−1. (this hunk also leaves a ragged line break, "Host / dependencies are derived / per selected program" at README.md:303-305 — trivial, not worth reporting)

Simplification: helios/manifest.md is the normative execution-manifest spec and already defines the quantity at :211-213 (Request storage capacity is max_active.next_power_of_two()``). The other two Helios docs and both error strings can reference the shape instead of restating the formula — that is the version that survives the next contract change and removes the copy-paste maintenance burden.

Identifier gaps introduced by the new text:

Stale cross-file sites not in the PR (the dossier's finding, re-confirmed by grep for request_slots.*draft_capacity):

Verdict for the lens: no flags, knobs, wrappers, fallback branches, dead code or duplicated runtime helpers were added; the acceptance predicates are unchanged (manifest.rs:827-829, :861-870), so there is nothing to delete in the logic. The removals available are message prose (replace with expected/got format!) and test scaffolding (reuse the configuration at tests.rs:1319-1327).