Subtraction and simplicity report · NVIDIA/hyperflare-inference #664

Raw Markdown for agents: https://autobot.eidonix.com/p/0c98d617-4e90-484d-8358-1eaf845213c9.md

Subtraction, Simplicity & Conventions review — PR #664 (helios,heliopause,ignition: support single-plane BF16 and identity-indexed offloaded embedding tables)

Head reviewed: 263dfe9b (23 files, +1722/−548). All citations below were re-verified in the code at that commit.

Key findings

The diff is lean and idiomatic for what it does — the [Plane; 2] → Planes { weights, scales: Option<Plane> } refactor consistently removes indexing assumptions rather than adding a second code path, and I found no env-var knob, supports_*/can_* flag, model allowlist, or new captured-graph op family in the code (the approval question belongs to the contracts lens and is not re-litigated here).

Four things are worth cutting, and two of them are branches that cannot execute today:

  1. HIGH — dead duplicate encoding validation in helios/src/core/schema.rs:367-372: five lines that re-derive exactly what engram_encoding_has_scales already rejects, with the identical error string.
  2. HIGH — dead None arm in helios/src/runtime_core/engram.rs:257-268: the scales.is_some() rejection inside the Planes construction is already performed for both shared (:191) and partitioned (:97-101) tables three hundred lines earlier.
  3. HIGH — speculative legacy fallback in helios/src/runtime_core/engram.rs:29-34 whose own comment says its justification is test fixtures; the strict Unspecified rejection this PR adds everywhere else means no published core can reach it.
  4. MED-HIGH — a third and fourth copy of the same engram-plane walk (heliopause/src/export/core.rs:96-142, :408-440, and helios/src/runtime_core/engram.rs:19-68 spans), with a duplicated error message in two of them.

Net: ~30 removable lines with zero behaviour change, plus one shared walker replacing three near-identical loops. Nothing else in the diff should be deleted.


1. HIGH — validate_engram re-validates the encoding it is about to validate again (delete 5 lines)

helios/src/core/schema.rs:365-372:

    let roles = [wire::PayloadRole::Weights, wire::PayloadRole::TunedWeights];
    for table in &engram.tables {
        let encoding = wire::engram_table::Encoding::try_from(table.encoding)
            .map_err(|_| invalid("engram table has no encoding"))?;
        if encoding == wire::engram_table::Encoding::Unspecified {
            return Err(invalid("engram table has no encoding"));
        }
        let has_scales = engram_encoding_has_scales(table.encoding)?;

engram_encoding_has_scales (helios/src/core/schema.rs:316-327) is:

pub fn engram_encoding_has_scales(encoding: i32) -> Result<bool> {
    match wire::engram_table::Encoding::try_from(encoding) {
        Ok(
            wire::engram_table::Encoding::Fp8E4m3E8m0
            | wire::engram_table::Encoding::Nvfp4E4m3Global,
        ) => Ok(true),
        Ok(wire::engram_table::Encoding::Bf16) => Ok(false),
        _ => Err(invalid("engram table has no encoding")),
    }
}

Unspecified is Ok(Unspecified) and unknown tags are Err, so both fall into the _ arm and return the same "engram table has no encoding" message. The try_from/map_err and the if encoding == Unspecified are unreachable-by-effect.

Concrete change: delete lines 367-371, keep let encoding = wire::engram_table::Encoding::try_from(table.encoding).map_err(...)?; only if the typed encoding is still needed — it is, at :433 (encoding == Encoding::Bf16) and :457/:501 pass table.encoding untyped. So keep one line, drop four:

        let encoding = wire::engram_table::Encoding::try_from(table.encoding)
            .map_err(|_| invalid("engram table has no encoding"))?;
        let has_scales = engram_encoding_has_scales(table.encoding)?;

This is also the conventions point: the PR's stated goal is that scale-plane validation is centralized in engram_scales/engram_encoding_has_scales; the leftover hand-rolled copy is exactly the duplication that centralization was meant to remove.

2. HIGH — the Planes construction carries an unreachable rejection (delete 7 lines)

helios/src/runtime_core/engram.rs:257-268:

        let planes = Planes {
            weights: plane(weights, row_bytes)?,
            scales: match scale_bytes {
                Some(bytes) => Some(plane(scales, bytes)?),
                None => {
                    if scales.is_some() {
                        return Err(invalid("single-plane Engram table cannot carry scales"));
                    }
                    None
                }
            },
        };

scale_bytes is None exactly when the encoding has no scale plane (:139-156: FP8 → Some(8), NVFP4 → Some(10), BF16 → None). In that case both call paths have already rejected a present scale plane:

So the inner if scales.is_some() can never fire, and its message is a third wording of the same invariant ("cannot carry scale bindings" / "cannot carry scales" / "cannot carry scales plane" — cf. helios/src/core/schema.rs:337, :383).

Concrete change: replace the whole match with

            scales: scale_bytes.map(|bytes| plane(scales, bytes)).transpose()?,

No test coverage is lost: the only test touching this area, helios/src/runtime_core/engram.rs:1091-1094, builds shard_scales and asserts both validate_shards and decode fail with "cannot carry scales" — both errors come from validate_shards (:99), which decode calls at :158, i.e. before this block.

3. HIGH — the legacy encoding == 0 shim is justified only by a hand-encoded test fixture

helios/src/runtime_core/engram.rs:28-35:

    for table in index.engram.iter().flat_map(|e| &e.tables) {
        // Legacy pre-encoding `ModelIndex` fixtures leave `encoding == 0` with two planes.
        let encoding = if table.encoding == wire::engram_table::Encoding::Unspecified as i32 {
            wire::engram_table::Encoding::Fp8E4m3E8m0 as i32
        } else {
            table.encoding
        };
        let has_scales = crate::core::schema::engram_encoding_has_scales(encoding)?;

Three reasons this should be deleted rather than kept:

Concrete change: delete the four-line if/else and keep let encoding = table.encoding; (or inline it), then drop encoding entirely and call engram_encoding_has_scales(table.encoding) / engram_scales(table.encoding, ...) as the sibling validate_engram does. Then add field 12 (encoding = Fp8E4m3E8m0) to the fixture bytes at :498-500, or construct the fixture with wire::EngramTable { encoding: ..., .. } in Rust instead of raw bytes. Caveat for the author: if a real pre-existing binary core exists with encoding unset, then this is a compatibility bug (missing migration) rather than excess code — either way, the shim as written cannot be the answer, because the PR rejects encoding == 0 everywhere else and signing would never have produced such a core.

4. MED-HIGH — the engram-plane walk exists three times (plus a duplicated error string)

The same for table { if shards.is_empty() { weights } else { for shard { weights, scales } } } walk, including the same engram_scales calls, appears at:

Difference worth noting: the two heliopause copies do not check shard.rank as usize >= index.ranks.len() in validate_ranks (heliopause/src/export/core.rs:426-437) although roles does (:119-121). That asymmetry is a symptom of the copy, not a separate bug to patch.

Concrete change (structural, not a line count): add one helper next to engram_scales, e.g. helios_core::core::schema::engram_planes(index) -> Result<Vec<(Option<usize>, &wire::Span)>> (the body is already written twice — runtime_core/engram.rs:19-68 and schema.rs has the catalog/Roles context to host it). Then roles() becomes for (owner, span) in engram_planes(index)? { result.push(Role { kind: 4, owner, span: span.clone() }) }, validate_ranks becomes for (_, span) in engram_planes(&source.index)? { locate(&source.payload, span)? }, and the duplicated "partitioned embedding tables cannot also hold shared planes" string disappears from both sites. If the author prefers not to cross the crate boundary, the minimum ask is to delete the second copy in validate_ranks by having it reuse the already-pub(crate) roles() for the engram spans.

5. LOW — shares_delivery_with is self == other with a doc comment restating Table::partition's

helios/src/engram.rs:195-201:

impl Index {
    /// Two ranks share one delivery group only when every table matches in
    /// planes, bindings, and partition ownership (`Table::partition`).
    pub(crate) fn shares_delivery_with(&self, other: &Self) -> bool {
        self == other
    }
}

The method does give the invariant a name at the call site (helios/src/runtime_core/model.rs:458-460, tested at helios/src/runtime_core/engram.rs:1079-1084), which is why I list it last and would not insist. If anything is cut, it is seven lines of wrapper replaced by a != b at the two call sites plus the invariant moved into the comment above Table::partition (helios/src/engram.rs:179-180). Judgement call; keeping it is defensible.


6. Checked and cleared — do not report these as excess

I looked for dead code in every new public item; all are used:

Refactors that net-simplify and should not be re-litigated:

Conventions checked, not violated: no env-var knob, capability flag or model allowlist added; partition: Option<usize> (helios/src/engram.rs:180) is geometry, not model identity; proto additions are appended as = 3 (helios/proto/core.proto, helios/proto/runtime_core.proto (not opened)); ignition/preparation/runtime_core_pb2.py (not opened) is a pure +109/−109 regeneration with no hand edits; the four doc files were updated in the same change set as the behaviour; new tests are behavioural (buffers, decode errors, publish round-trips, descriptor counts), not source-text checks.


Open questions / not found