PR #716: helios: derive NVFP4 engram row and scale widths from embedding_width

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/d46e54f2-ad16-47d9-b7e6-898089b24493

Opened by a workflow run, Dec 3, 2026 9:26 PM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: lukealonso (COLLABORATOR, one of three charter-named priority contributors; 48 merged PRs in 180 days, 33 touching helios/src; Discord: lukealonso) Motivation: Helios's runtime-core engram decoder hardcoded NVFP4 tables to a 160-element row (80 weight bytes, 10 scale bytes), which matches Qwen3.8-Flash but rejects Qwen4-35B-A3B, whose 2048-wide ple_embed_dim gives 128-element rows (64/8 bytes). The protobuf already carries embedding_width, so the fix is to derive the geometry from it instead of hardcoding a model's shape. Scale: +57 / −2 lines in 1 file Proposal:

Touches:

Related items:

Link: https://github.com/NVIDIA/hyperflare-inference/pull/716 Autobot comments: The description omits two edits in the diff: async_transfers/external_extents added to the test fixture to fix this file's own #711 breakage — so the stated #714 dependency is narrower than implied (only cache_memory.rs:1659 and other modules still need #714, verified still missing at this head). The "any 16-aligned NVFP4 width" claim is narrowed by line 145, which still requires scale_block == 16. Zero and unaligned widths fall into the same "invalid n-gram encoding or global scale" error, so the new rejection is not diagnosable. The reject half of the test reuses row_bytes=64, scale_bytes=8 for all bad widths, exercising only the alignment guard. Evidence is a cargo check only: no issue or bug report is linked, no 128-wide core exists in-tree to export or serve, Qwen4 is absent from the official recipe list (docs/model-preparation.md:317-327), and the producer/recipe PRs are external. No proto, schema, exporter or doc change; 160-wide cores are unaffected. Zero comments and reviews so far.

Full report · Notes

Value Proposition

Value Proposition — PR #716 (helios: derive NVFP4 engram row and scale widths from embedding_width)

Charter alignment: strong. The change deletes a hardcoded 160-wide NVFP4 engram geometry from helios/src/runtime_core/engram.rs and derives (width, 16, width/2, width/16) from the embedding_width field the exporter already emits verbatim (heliopause/src/export/core.rs:1674-1675). That is exactly the charter's "keep the runtime small and model-agnostic… no per-model branches": no new flag, alias, proto field, or default, and the only remaining constants are the NVFP4 block size 16 and the untouched FP8 tuple. It also addresses the root cause (a hardcoded width) rather than working around it.

Novelty & status: genuinely additive. Nothing merged touches NVFP4 engram geometry — #711/#659 caused unrelated fixture breakage, #714 repairs cache_memory.rs only, and #590/#566/#580/#539 are different engram work. #664 is overlapping, not competing: it also derives row bytes from embedding_width (for BF16) and rewrites the same match arm, but carries its own two blockers and does not remove the NVFP4 160 constant. So neither Superseded nor Obsolete applies; the two PRs will need an ordered rebase.

Value vs cost: low cost, modest but real value. +57/−2 in one file, purely additive compatibility: 160-wide cores decode identically (verified by arithmetic and retained test coverage), FP8 untouched, no schema or wire change. Reach is narrow — only cores carrying NVFP4_E4M3_GLOBAL — and the beneficiary is a Qwen4-35B-A3B path whose recipe lives outside this repo (hyperflare-recipes#154) and whose kernel support is external (flashinfer#215); Qwen4 is absent from the in-tree recipe list (docs/model-preparation.md:317-327).

Evidence gaps that must close before merge:

  1. No linked issue, failing run, or reproducer. Evidence is a cargo check, not an exported or served 128-wide core, and there is no replay of an existing 160-wide core. An exported core plus a serve/replay result (or a linked bug) is required under "Bring real evidence."
  2. "Any other 16-aligned NVFP4 width" is overstated: line 145 still rejects scale_block != 16. Either narrow the claim or derive scale_block too, and explain the asymmetry.
  3. The two undeclared fixture edits (async_transfers, external_extents, introduced by #711) are not disclosed, and #714 is described as blocking the test when it only blocks the crate-wide build.
  4. The new rejection guard still funnels to the generic "invalid n-gram encoding or global scale" message; the width is never named.
  5. The reject half of the new test exercises only the alignment guard, not a geometry mismatch — tighten it.

Verdict: Worth it with changes. Charter-aligned, minimal, and authored by a priority/area-owner contributor — but the benefit is currently asserted, not demonstrated.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Classify intake

Selected: triage:review, bug, enhancement, area:engram

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +bug, +enhancement, +area:engram

Gates and contracts

Contracts, Charter & Verification Gates Audit — PR #716

Verdict: no contract-boundary, vendored-dependency, or Charter violations. One mandatory-verification gate is unsatisfied at head d061454: the Layer-1 cargo test for a core-loading change was replaced by cargo check, and the PR's own new test has never executed.

Gate 1 — Signed core-format / wire / captured-graph / public contract boundaries: PASS

Gate 2 — Vendored upstream dependencies & cross-PR conflicts: PASS

Gate 3 — Mandatory verification evidence: ONE GATE UNSATISFIED (Major)

No formal/lifecycle/benchmark gate applies, correctly:

But Layer 1 is not met. This is a core-loading change, and cargo check cannot substitute for cargo test.

Gate 4 — Material scope / claim contradictions: PASS (no Major)

Info / Nit (not blocking, not pedantic process)

  1. Two undeclared diff edits, and the #714 dependency is narrower than described. The diff adds async_transfers: vec![] (engram.rs:631) and external_extents: vec![] (:634) to decode_fixture, repairing this file's own #711 breakage; the description credits #714 for unblocking test execution without saying it already fixed its own fixtures. Residual blocker is only cache_memory.rs:1659 (and any other module with the same omission). Worth one line in the description because it changes the remedy for the Major above.
  2. scale_block is still pinned to 16 — engram.rs:144-145 (table.scale_block != block) rejects any table whose scale_block != 16, and scale bytes are derived as width/16 on that assumption. The claim "any other 16-aligned NVFP4 width" reads as consistent with this, since 16 is NVFP4's defining block size, so I do not treat it as a contradiction — but a sentence stating the retained block-16 requirement would remove the ambiguity.
  3. Textual overlap with open #664 (kbenkhaled), which rewrites this same match arm and the Plane type. Whichever lands second rebases; informational only.
  4. No live export/serve replay of a 128-wide core, and no 160-wide core replay artifact. The producer (hyperflare-recipes#154) and kernel support (flashinfer#215) are external to this repo, and mis-derivation is structurally blocked by the span-length check at engram.rs:201-203, so I am not raising this as a separate gate — but a replay note after the unit test runs would close docs/design-review.md principle 12's "preserve model core compatibility" evidence loop.
  5. Design-Signed-Off-By trailer on the head commit cannot be verified with the tools available (repository history queries fail repo-wide), so I make no finding either way.

Bottom line

No hard contract, vendored-file, Charter, or scope violation. The single actionable gate is #3: run the crate test layer — possible now that #714 exists as a one-line fix — and report the result before merge; cargo check is explicitly not sufficient for a change to the signed core-loading surface.

Full report

Subtraction and simplicity

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.

Full report