Simplicity report · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/7a0b9109-c0b6-4b9e-a111-0bef10578c43.md

Review of PR #483 — simplicity lens (what can be deleted)

Charter/guidance used: docs/design-review.md:16 ("Keep Helios as simple as possible"), AGENTS.md:188-193 ("Reject unsupported abstractions and churn. Do not add … configuration switches without a concrete requirement. Unsolicited formatting … are not contributions by themselves"), AGENTS.md:194-199 ("Tests must exercise the affected behavior or contract"), AGENTS.md:431-444 (protobuf additions must be additive and preserve existing behavior), AGENTS.md:466-468 (tests may read opt-in variables but must not change what the code under test does).

Key findings


Unneeded options and configuration switches

1. patch_size / pooling_kernel_size are dead configuration that also add copies of 768 — should fix

Where it appears:

Why it is dead weight, not flexibility: the Python producer rejects every other value before the core is ever written (frontend.py:116-119), so no exported core can carry a different pair. Meanwhile nothing else derives from the fields consistently:

So there are three independent statements of the same number, and the only code that would notice a mismatch silently misbehaves: with a patch_size other than 16 (which load() accepts) valid_processed in conditioned.rs:185-194 is always false, so every cached Gemma 4 image is recomputed without an error.

Precedent in-tree: profile constants live in the module — helios/src/frontend/images/glm.rs:13 const FACTOR: usize = 28.

Smaller version:


Parallel paths and duplicated logic

2. prompt.rs back-fills data.spans that layouts already own — should fix

helios/src/model/prompt.rs:137-151:

if prepared.data.spans.is_empty()
    && config.contract.frontend.image_tokens.as_ref()
        .and_then(|layout| layout.span.as_ref()).is_some()
{
    prepared.data.spans = prepared.conditioned_inputs.iter()
        .map(|input| input.token_span.clone()).collect();
}

This is the only span producer that is not in the layout. helios/src/frontend/images/layouts/deepseek.rs:149 already pushes start + padding..start + block.len() while it builds the expansion, so for Deepseek is_empty() is false and the new block never fires; for Bracketed/Gemma4 it fires. The result is a construct where the guard silently prefers one producer's answer over another instead of establishing that they agree, i.e. a second path where a single check would do.

Smaller version, in order of preference:

  1. Have layouts/bracketed.rs::prepare_input push data.spans next to the expansion it computes — the conditioning/prompt path there is the natural owner — and delete lines 137-151 entirely. That puts Gemma 4's span production where the token expansion that produced it lives, and removes a model-shaped conditional from shared code.
  2. If the shared location is kept, drop the is_empty() preference and make overlap a defect: error unless exactly one producer filled spans, then let validate_prompt_data (helios/src/model.rs:436-452) keep checking them.

Either way the net deletion is the is_empty() branch; option 1 also deletes the shared block.


Tests that do not prove a behaviour

3. The envelope test shells out to Python for a template it never uses — should fix; also leaks a temp file

helios/src/frontend/images/gemma4.rs:236-332 (checkpoint_tokens_expand_the_image_envelope):

The assertions at 311-331 exercise Envelope::expand via frontend.encode("Look <|image|> now", false). Chat-template rendering is never called anywhere in the test, and FrontendAssets.chat_template is Option<Asset> (helios/src/frontend/mod.rs:96-100), so the whole subprocess block is deletable: load tokenizer.json (not opened) + tokenizer_config.json (not opened), pass chat_template: None, keep the four assert_eq!s. The shared expansion itself is already covered end-to-end with a real rendered prompt, two images, feature order and start/end tokens by helios/src/frontend/images/layouts/bracketed.rs:104-180 — a test this PR makes apply to Gemma 4 too by moving both profiles onto Envelope.

If the reviewers want the envelope covered for the Gemma 4 checkpoint specifically, the reduced test is roughly:

let frontend = Frontend::load(FrontendAssets {
    tokenizer: asset("tokenizer.json (not opened)"),
    tokens: crate::frontend::test_support::tokens(&asset("tokenizer_config.json (not opened)")).unwrap(),
    chat_template: None,
}, Default::default()).unwrap();
// ... then the existing asserts on expanded.token_ids / mm_token_type_ids

That deletes ~55 lines, one cross-language dependency, and one file-lifetime bug.

4. The checkpoint parity test depends on an unpinned local venv and proves nothing on CI — should fix

helios/src/frontend/images/gemma4.rs:334-415 (native_pixels_and_positions_match_the_checkpoint_processor):

This is the evidence behind the PR's headline claim ("exact f32 pixel and (x, y) position parity"), and AGENTS.md:194-199 requires tests that exercise the contract while keeping skips visible. Every other profile's parity evidence in this repository is a checked-in fixture: helios/src/frontend/images/glm.rs:147-199 reads tests/frontend/glm53_images.json (not opened) via include_str! and compares SHA-256 of resized bytes, pixels and positions; the generator lives at tests/frontend/generate_glm_image_fixtures.py (not opened). Qwen does the same (decoding_tests.rs with qwen38_images.json (not opened)).

Smaller and stronger version: add tests/frontend/gemma4_images.json (not opened) (width, height, grid, and hashes of resized, pixel_values LE bytes, position_ids LE bytes) plus a generator script, and reduce the test to the glm.rs shape — which also deletes the struct packing, the offset constants (pixel_offset = 32), and the two for loops of element-by-element comparison. Note the file also repeats the geometry expectations already asserted in geometry_matches_the_hugging_face_processor (197-216), so the fixture can carry geometry and the duplicate table can shrink.

Consequence to state in the PR description: with the current form, "45 passed" does not distinguish tests that ran from tests that silently returned.


Churn, redundant checks and duplicated constants (nits)

Nit 1 — redundant merge_side test. helios/src/frontend/images/packing.rs:486 checks h % merge_side != 0 || w % merge_side != 0, where merge_side comes from the same patches_per_feature as the adjacent identity at line 488. The only producer of these geometries is the Gemma 4 profile, which already guarantees the divisible grid: gemma4.rs:46-48 side_multiple() and geometry() floors both target sides to multiples of patch_size * pooling. bracketed_patch_geometry exists for that one check plus the width; if the shape check stays in the profile, packing.rs needs only geometry.tokens * patches_per_feature == patches and a const FEATURES width, and bracketed_patch_geometry's tuple return collapses to a width.

Nit 2 — unrelated reformatting. packing.rs:494-502 turns the previous one-line staging.put("vision_pixel_values", ...) into a six-line call with flat_map(f32::to_le_bytes); the actual change is 1176 -> patch_width. Under AGENTS.md:188-193 this is churn that makes the real one-token change harder to see. Keep the original line and change the constant.

Nit 3 — the new packing test only proves a table lookup. packing.rs:570-586 (bracketed_tensor_layout_derives_patch_width_from_patches_per_feature) asserts tensor_layout returns patches * 768 for patches_per_feature == 9 and errors on 16. The PR's claim is that bracketed() now handles 9; nothing tests bracketed() at 9 — not the tokens * ppf == patches identity, not the truncated-pixel error at 498, not the 47-row rejection. A bracketed(...) test with grid_thw [1, 48, 48] (2304 patches, 256 tokens) and a rejected odd grid would prove the behaviour; the current test proves an integer literal.

Nit 4 — the soft-token allowlist is written twice. helios/src/frontend/images/gemma4.rs:11 SUPPORTED_SOFT_TOKENS = [70, 140, 280, 560, 1120] and ignition/preparation/frontend.py:123 if image.get("max_soft_tokens") not in (70, 140, 280, 560, 1120). Nothing else in the profile branches on the value — geometry derives everything from it through max_patches() (gemma4.rs:50-52). Either keep the producer check and let Rust accept any positive value, or drop both and let the budget check at gemma4.rs:77-81 be the guard. The Rust copy cannot be exercised once the Python producer rejects other values first, so it is the one to delete.


Checked and fine (no finding)

Open questions / not verifiable from the code