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

Raw Markdown for agents: https://autobot.eidonix.com/p/697a8659-ab92-4a6a-9bde-9490ce39b91d.md

Subtraction & Simplicity audit — PR #716 (helios/src/runtime_core/engram.rs, +57/−2)

Verdict: the change itself is lean and is a net subtraction — it deletes a hardcoded model width constant ((160, 16, 80, 10)) in favour of metadata the producer already emits (heliopause/src/export/core.rs:1674-1675), and adds no flag, knob, config default, alias, wrapper, or branch. Nothing speculative-general is introduced. That said, four concrete simplifications are available, one of which would have prevented the very compile churn this PR is silently carrying.

1. width is now dead for the NVFP4 arm — the 4-tuple can shed an element (medium)

helios/src/runtime_core/engram.rs:119-131 and :144-145:

let (width, block, row_bytes, scale_bytes) = match encoding {
    wire::engram_table::Encoding::Fp8E4m3E8m0 => (256, 32, 256, 8),
    wire::engram_table::Encoding::Nvfp4E4m3Global
        if table.global_scale.is_finite()
            && table.global_scale > 0.0
            && table.embedding_width > 0
            && table.embedding_width % 16 == 0 =>
    {
        let width = table.embedding_width;
        (width, 16, (width / 2) as usize, (width / 16) as usize)
    }
    _ => return Err(invalid("invalid n-gram encoding or global scale")),
};
...
|| table.embedding_width != width          // :144
|| table.scale_block != block              // :145

width has exactly one consumer, :144, and for the Nvfp4E4m3Global arm :144 is a tautology by construction (let width = table.embedding_width; two lines earlier). Only the FP8 arm's (256, 32, …) still needs the comparison. Simplification: move the width/block expectations into the per-arm guards and return only (row_bytes, scale_bytes), deleting :144-145 from the compound if:

let (row_bytes, scale_bytes) = match encoding {
    wire::engram_table::Encoding::Fp8E4m3E8m0
        if table.embedding_width == 256 && table.scale_block == 32 => (256, 8),
    wire::engram_table::Encoding::Nvfp4E4m3Global
        if table.global_scale.is_finite() && table.global_scale > 0.0
            && table.embedding_width > 0 && table.embedding_width % 16 == 0 =>
        ((table.embedding_width / 2) as usize, (table.embedding_width / 16) as usize),
    _ => return Err(invalid("invalid n-gram encoding or global scale")),
};

embedding_width is then referenced once instead of three times, one tuple element and two comparisons disappear, and the four numbers (width, block, row_bytes, scale_bytes) whose mutual consistency is currently asserted in three separate places collapse to the only two that vary. Caveat to weigh: a bad embedding_width/scale_block on an FP8 table would then report "invalid n-gram encoding or global scale" instead of "invalid Engram table encoding or bindings" (:156). That is the one behavioural edge, and it points at issue 2 below.

2. The new rejection path is undifferentiated, and the guard adds a sixth reason to one message (low, but pairs with #1)

helios/src/runtime_core/engram.rs:130 keeps the single catch-all _ => return Err(invalid("invalid n-gram encoding or global scale")) for a failure that now has four distinct causes (unknown encoding, non-finite scale, non-positive scale, zero/unaligned embedding_width). An operator with a mis-sized Qwen4 core gets "invalid global scale", which is actively misleading about the field at fault. One line fixes it and costs nothing:

    _ => return Err(invalid("invalid n-gram encoding, global scale, or embedding width")),

No new branch, no new type — just stop the message from naming the wrong field.

3. % 16 == 0 should be is_multiple_of(16) — crate convention (low)

helios/src/runtime_core/engram.rs:125: && table.embedding_width % 16 == 0. Every other modular check in the crate uses u32/usize::is_multiple_of: engram.rs:292 (!reference.offset.is_multiple_of(8)), helios/src/scheduler.rs:67 (not opened), :809, :1048, helios/src/execution/manifest.rs:719 (not opened), helios/src/model/packing.rs:204 (not opened). This file is already on that convention, so the new line is the sole % n == 0 spelling in the vicinity (clippy's manual_is_multiple_of flags it). table.embedding_width.is_multiple_of(16) — and the retained > 0 guard then reads as the deliberate "zero is technically 16-aligned" carve-out it is.

4. The test fixture hand-writes defaulted protobuf fields — this is what caused the churn the PR is hiding (high, prevents recurrence)

helios/src/runtime_core/engram.rs:629-631 (part of this PR's undeclared edits):

                tuning_graphs: vec![],
                persistent_workers: vec![],
                async_transfers: vec![],
            }),

All three are prost-default empty Vecs. The PR adds the third one purely so the fixture compiles after #711 added the proto field — an edit the description does not mention, in a fixture otherwise unrelated to the width change. The literal already ends with these defaulted fields and wire::Execution derives Default (prost), so:

                ..Default::default()
            }),

is a net deletion of three lines, and the exact precedent inside this crate — helios/src/runtime_core/describe.rs:1087 builds a wire::Execution with ..Default::default() at :1125. With it, #711-style proto additions never break this fixture again, instead of costing another drive-by fix per PR. (The external_extents: vec![] at :634 cannot use the same trick — format::Core at helios/src/runtime_core/format.rs:23-36 is #[derive(Debug)] only, not Default; deriving Default on Core or grouping its two non-proto tail fields would be the analogue. Worth flagging only, since Core is load-bearing.)

5. The reject half of the new test is redundant coverage (low)

helios/src/runtime_core/engram.rs:840-846:

        for bad_width in [0u32, 8, 120] {
            let (catalog, core) = make(bad_width, 64, 8);
            assert!(
                decode(catalog, &archive, &[core], 0, 1).is_err(),
                "expected rejection for bad_width={bad_width}"
            );
        }

Three cases, one guard. 0 exercises the > 0 clause, 8 exercises alignment, and 120 exercises alignment again — 120 is 8-aligned but not 16-aligned, so it adds the same signal as 8. Worse, all three are fed row_bytes=64, scale_bytes=8, so even a passing width would fail the payload geometry check at :201; the assertions cannot tell which check fired, and the failure mode they claim to pin (an unaligned width being accepted) is already covered by 8. Two cases suffice (0 and 8), or — better — split them so the message distinguishes the guard from the geometry check, keeping the reject loop from reading like a 3× restatement of one condition.

By contrast the accept half (:833-838) passing explicit (128, 64, 8) / (160, 80, 10) is correct as written and should not be "simplified" to derive row_bytes from width — the explicit literals are the only thing that independently checks the production derivation rather than re-running it.

Not a problem / explicitly checked

Priority

  1. Item 4 (..Default::default() in the fixture) — deletes lines and stops the recurring #711-style breakage; also fixes the PR's undeclared-edit problem by making the edit unnecessary.
  2. Item 1 (drop the tautological width from the tuple) — the only real structural simplification left in the diff.
  3. Item 2 (one-line error message) — cheap and fixes a misleading diagnostic.
  4. Items 3 and 5 — style/coverage tidy-ups inside the new lines.