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

Raw Markdown for agents: https://autobot.eidonix.com/p/9062ea24-0101-424d-93b7-ef5b99c6a613.md

#1 [high] PR #664 subtraction-lens findings (verbatim + citations)

Head 263dfe9b. All line numbers verified this run.

F1 (HIGH, dead duplicate check) helios/src/core/schema.rs:367-372:

        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 (schema.rs:318-327) already returns Err("engram table has no encoding") for both Unspecified (=0) and unknown. Lines 367-371 are unreachable-by-effect duplicates with the identical message. Keep let encoding (used at :433,:457) but drop the try_from/map_err + Unspecified if → 5 lines.

F2 (HIGH, dead fallback branch) 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
                }
            },
        };

The None+scales.is_some() case is already rejected earlier for both sources: shared → :191 else if !table.scale_buffer.is_empty() || table.scales.is_some(); partitioned → validate_shards(..., false) at :97-101 rejects shard.scales.is_some(). Replace with scales: scale_bytes.map(|bytes| plane(scales, bytes)).transpose()?, (test at :1026 expects a different error string from :191 path, so no test loss).

F3 (HIGH, speculative legacy fallback) helios/src/runtime_core/engram.rs:29-34:

        // 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
        };

Its own comment says the justification is fixtures. The fixture is engram.rs:496-503 (hand-encoded bytes without field 12) asserting 2 planes at :513-518. Delete the fallback, set the encoding byte in the fixture (or make encoding explicit). AGENTS.md "Reject unsupported abstractions and churn: ... speculative compatibility, fallback layers". If a real pre-existing core has encoding unset this is instead a compat bug (correctness lens) — flag both readings, but the comment names only fixtures.

F4 (MED-HIGH, duplicated plane walk) heliopause/src/export/core.rs:96-142 roles() and :408-440 validate_ranks() repeat the same table walk incl. duplicated error "partitioned embedding tables cannot also hold shared planes" (:113-117 and :421-425). validate_ranks could call roles(&source.index) and locate each engram Role span instead of re-walking the catalog. NOTE: weight_reuse.rs:389-402 engram_uses is a third copy (unconditional weights.chain(scales)) and was not touched by the PR.

F5 (LOW) helios/src/engram.rs:195-201 Index::shares_delivery_with body is literally self == other; its doc comment duplicates Table::partition's doc (:179). Not worth changing alone; mention only as optional.

#2 [high] Research summary

Reviewed PR #664 at head 263dfe9b for subtraction, simplicity and conventions. The diff is mostly a disciplined [Plane; 2] → Planes { weights, scales: Option<Plane> } refactor, and most of it earns its keep; I found three high-value deletions and one duplication, and otherwise nothing to cut.

Findings (all citations verified this run, saved to scratchpad #1):

  1. Dead duplicate validation — helios/src/core/schema.rs:367-372. The try_from(...).map_err(...) plus if encoding == Unspecified { return Err("engram table has no encoding") } is fully subsumed by engram_encoding_has_scales(table.encoding)? on the next line, which returns the same message for Unspecified and for unknown tags. Five lines to delete; retain encoding for the later BF16 checks.

  2. Dead fallback branch — helios/src/runtime_core/engram.rs:257-268. The None => { if scales.is_some() { return Err("single-plane Engram table cannot carry scales") } None } arm is unreachable: shared tables are already rejected at :191 (!table.scale_buffer.is_empty() || table.scales.is_some()) and partitioned tables at :97-101 via validate_shards(..., false). Replace the whole match with scale_bytes.map(|bytes| plane(scales, bytes)).transpose()?.

  3. Speculative legacy fallback justified only by a test fixture — helios/src/runtime_core/engram.rs:29-34. The encoding == 0 → Fp8E4m3E8m0 shim's own comment says "Legacy pre-encoding ModelIndex fixtures"; treating a missing Encoding as two-plane contradicts the PR's explicit Unspecified rejection everywhere else and docs/design-review.md (not opened)'s compat rule, and AGENTS.md rejects "speculative compatibility, fallback layers". The single consumer is the hand-encoded fixture at :496-503 (asserting two planes at :513-518). Delete the shim and give the fixture an explicit encoding field; if a real pre-existing core can carry encoding == 0, this is a compatibility bug rather than a subtraction, and should be settled explicitly either way.

  4. Duplicated plane walk in the exporter — heliopause/src/export/core.rs:96-142 (roles) and :408-440 (validate_ranks) traverse the same engram catalog with the same branches and the same error string duplicated twice ("partitioned embedding tables cannot also hold shared planes"). validate_ranks can call roles(&source.index) and locate each kind-4 span. A third copy lives in heliopause/src/export/weight_reuse.rs:389-402 (engram_uses, untouched by this PR) — worth noting as the direction of the fix, not as a demand.

  5. Cosmetic only — helios/src/engram.rs:195-201: Index::shares_delivery_with is literally self == other with a doc comment that repeats Table::partition's. I would not change it on its own; it does name the invariant at the call site.

I verified and found no excess in the rest: Planes helper methods are each used; the TableSource.scales: Option<(PlaneSource, String)> pairing removes a two-element unwrap dance rather than adding one; the Python _receive_embedding_tables extraction is a net simplification (it exists so the test can exercise the loop); engram_scales/engram_encoding_has_scales genuinely centralize what would otherwise be five copies; and no environment-variable knob, supports_* flag, or model allowlist was introduced. Total reasonable reduction: roughly 25-30 lines across items 1-3, plus a shared walk for item 4.

#3 [high] PR #664 subtraction lens — what I checked and cleared (keeper)

Head 263dfe9b. Companion to note #1 (the five findings). This note records what must NOT be reported as excess, so the report does not over-claim.

Verified-USE, no dead code (search_code over helios/ this run):

Net-simplifying changes (not findings):

Conventions checked and NOT violated:

Net reduction available from findings 1-3 only: ~25-30 lines, zero behavior change (each is a branch already unreachable or a check already performed by a callee). Finding 4 is a structural de-duplication, not a line count.

Verdict for the report: the diff is lean and idiomatic for what it does; the five items are the whole of my list, and items 1-2 are the only ones I would insist on.