Code review summary report · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/336f9cd9-6838-4523-9d0c-ba55636a5653.md

Review — PR #483 "Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans"

Head ab9a432b (branch rickybrent:core/gemma4-image-frontend) → main 27716185, 38 files, +2490/−251. Round 4; supersedes the round-3 review of 2b4a31e.

Verdict: no blockers. Every should-fix from the previous round is fixed and verified in code (list below). What remains is one scope/evidence question that needs a maintainer answer, three small code/test items, and ten nits. This is a read-only review: I re-read every cited site, but ran no cargo test, cargo check or pytest, and the head commit reports no CI checks, so every behavioural claim below comes from code and callers. The author's reported test counts are not relied on anywhere in this report.

Key findings

Verified resolved this round — do not re-litigate

Blockers

None. Nothing in this change is incorrect on the served path, no existing core stops loading, and no compatibility guarantee is broken. The items below are gaps in coverage, one authoring default, and cleanup.

Should Fix

S1 — The profile lands ahead of the exporter that can use it, and nothing mounts it end to end

Finding. End-to-end serving is deferred to an unlanded companion PR in local-inference-lab/hyperflare-recipes, and docs/TODO.txt:330-337 records the qualification (E2B/E4B/26B-A4B/31B export and serving, plus the partial-span prefix-cache audit) as open. No prepared contract exercises the profile: helios/tests/support/contracts/gemma4_frontend.json:16-17 (not opened),38 declares image_preparation: null, image_layout: null, image_tokens: null, and no contract JSON under helios/tests/support/contracts/ uses layout 9 (Bracketed) or preparation 11 — the layouts in use are 1, 2, 3, 5, 6, 10 (qwen38.json:38-39 (not opened), mimo_v2.json:38-39 (not opened), deepseek4.json:36-37 (not opened), step5_frontend.json:16-17 (not opened), nemotron_h_frontend.json:16-17 (not opened), inkling2_frontend.json:52-53 (not opened)). Gemma 4 is covered only by Rust-constructed configs (helios/src/model/prompt.rs:1171-1284, helios/src/server/config.rs:935-1023, frontend/images/gemma4.rs) and by Ignition-side tests (ignition/preparation/frontend.py:114-173, tests/preparation/test_frontend_gemma4.py), none of which goes Bootstrap::load (server/config.rs:290-298) → validate_loaded_image_processor → a served image request.

Request. Either state in the description that a maintainer approved landing the profile ahead of its recipe (the author's stack-order argument — recipes were extracted, so the core profile must land first — is plausible and needs one line of confirmation), or split the shared half (the patch_features field, contract-driven Bracketed packing, Bracketed spans, envelope bounds) onto its own PR, since it stands alone and fixes a defect on main. Either way, add one contract fixture shaped like qwen38.json (not opened) with image_layout: 9, image_preparation: 11, a declared image_tokens.span, and vision { patches_per_feature: 9, patch_features: 768 }, loaded through the same helper the other fixtures use. Otherwise say plainly in the description that Gemma 4 serving is unqualified.

Why. The charter makes export-and-serve the bar for a new format ("prove they export and serve cleanly from the PR branch, and support more than a single checkpoint") and separately requires that existing cores still load. The compatibility half is now genuinely tested; the export/serve half is prose. The author's limitations paragraph covers unmeasured timing and memory but not that the profile has never been served. Also note the head commit reports no CI checks, so even the unit evidence has not run in CI.

S2 — The Gemma 4 processor file is not where the default path looks

Finding. ignition/preparation/frontend.py:310 resolves the processor as snapshot / "preprocessor_config.json (not opened)" when preprocessor is None, then feeds that JSON to image_settings (:311-314). Gemma 4 snapshots ship processor_config.json (not opened): the fixture generator reads snapshot / "processor_config.json (not opened)" (tests/frontend/generate_gemma4_image_fixtures.py:28), the padded_grid doc at frontend.py:100 already records the same split, and every test passes the path explicitly (tests/preparation/test_frontend_gemma4.py:88,246). So the documented call shape prepare_frontend(snapshot, eos_token_ids=[…], image_profile="gemma4") raises FileNotFoundError, and no test covers the default argument, so CI cannot catch it. Pre-existing for padded_grid too, so this is consistency plus a missing test rather than a new defect.

Request. Resolve the processor path per profile (try processor_config.json (not opened) for gemma4/padded_grid, or accept whichever of the two exists), or make preprocessor required for those profiles and document it; add one test that calls prepare_frontend without preprocessor against a snapshot holding processor_config.json (not opened).

Why. The first recipe author to follow the documented shape gets a FileNotFoundError instead of a prepared contract, and the failure is invisible to CI.

S3 — Only two of the five allowlisted soft-token budgets are ever loaded

Finding. helios/src/frontend/images/gemma4.rs:13 accepts [70, 140, 280, 560, 1120] and ignition/preparation/frontend.py:132 accepts the same five, but the fixture generator's specs are only 280 and 1120 (tests/frontend/generate_gemma4_image_fixtures.py:31-40), so processor_with_budget is only ever constructed at 280 (gemma4.rs:246-248) and 1120. max_soft_tokens drives max_patches() (gemma4.rs:98-100), the target pixel budget (:106), the aspect-clamp branches (:113-124) and max_envelope_tokens() (:90-92), which feeds the new load-time bound against prefill_chunk_size and span.max_tokens (server/config.rs:464-487). The clamp branches at :118-123 (one dimension rounding to zero) are exactly the edge that behaves differently at a small budget, and 70 is the value the checkpoint's own video_processor declares in the fixture's provenance block.

Request. Add (91, 37, 70), (10, 3000, 140) and one 560 case to the generator specs and regenerate, or add a table test that constructs a processor for each SUPPORTED_SOFT_TOKENS entry and asserts geometry for one fixed shape.

Why. A budget-specific geometry or parity defect would first appear at flare run on a real checkpoint rather than in cargo test. This also closes the cross-language drift risk on the allowlist at no extra cost.

S4 — The new legacy-core test hand-builds a manifest the shared builder could emit

Finding. helios/src/model/tests.rs:1343-1411 is a 68-line local build_manifest closure that repeats the descriptor/stride/address walk of helios/src/model/testing.rs:307-337 and the binding assembly of :369-377, plus nine hand-written ValueBindings at tests.rs:1304-1332. It exists because testing::manifest sends GraphOperation::Vision to _ => unreachable!() (testing.rs:344-355, the _ arm at :354) and fixes image tensor widths to 1 (testing.rs:257, _ => 1), so a vision graph cannot be described. Line tests.rs:1450 then rebuilds a manifest it already holds (base_manifest = build_manifest(1176); immediately before use).

Request. Add GraphOperation::Vision => GraphKind::Vision at testing.rs:344-355 and let the width for vision_pixel_values come from vision.bracketed_patch_features(); the test then overrides one buffer extent to (16, pixel_width), and the local closure, the hand-written bindings and the :1450 rebuild all disappear.

Why. Roughly 110 lines of duplicated manifest arithmetic is a second source of truth for graph layout; when ExecutionManifest changes, this test breaks for reasons unrelated to the behaviour it checks (a legacy core without patch_features loads and stages 1176-wide pixels).

Nits

  1. Per-profile patch width is still authored twice, over two different enums. helios/src/frontend/images/packing.rs:32-49 maps ImageLayoutKind → float width (Qwen|Mimo → 1536, Deepseek*|Moonvit|Step → 588, Bracketed → vision.bracketed_patch_features(), Radio → 768, Glm → 1176, ClassToken → 1200), while helios/src/frontend/images/mod.rs:459-471 (ImageProcessor::patch_features) maps Profile → the same numbers. They are linked only by the test at packing.rs:685-814. Fix: pass the processor width into tensor_layout from Inputs::new (helios/src/model/packing.rs (not opened)), so Profile stays the single authoring point.
  2. Duplicated test rows. helios/src/frontend/images/gemma4.rs:386-396 lists nine geometry rows, but seven are already pinned by grid/tokens/patches/resize/pixels/positions SHA-256 in canonical_processor_pixels_positions_and_resize (:314-381) against tests/frontend/gemma4_images.json (not opened); only (100,3000) and (3000,100) (:392-393) are unique. pixels_interleave_rgb_and_positions_are_xy (:404-420) restates the 91×37 fixture case by hand. Fix: keep the two tall/wide rows plus the tokens * 9 == patches invariant (:400) and the (x, y) ordering assertions at :415-418, which the hashes cannot express; delete the rest.
  3. packing.rs:685-814 is ~130 lines for four distinct outcomes. processor_patch_features_match_tensor_layout_for_every_profile repeats patch_features: 0 ten times. Fix: four rows (Gemma 4 9/768, PatchMerge 4→1176, PaddedGrid 1200, one of 588/1536) cover every distinct path.
  4. The soft-token allowlist exists twice, in two languages, with nothing tying them. helios/src/frontend/images/gemma4.rs:13 SUPPORTED_SOFT_TOKENS and ignition/preparation/frontend.py:132 max_soft_tokens not in (70, 140, 280, 560, 1120). The Rust comment (gemma4.rs:11-12) argues the duplication is deliberate defence in depth, which is legitimate, but no test asserts the sets agree. Fix: cross-reference both sites in comments and add the table test in S3, or carry the allowed set in the prepared settings so Helios validates metadata instead of a literal.
  5. max_patches is computed twice in gemma4.rs. Checked at :61-64 (checked_mul, load-time bound) and unchecked at :98-100 (fn max_patches) for geometry (:104, :139). Fix: have load call max_patches() on the constructed value, or store the computed budget, so there is one expression.
  6. Validation style departs from its closest precedents. helios/src/frontend/images/patch_merge.rs:92 pins settings.patch_size != 14 and qwen.rs:22 (not opened) pins position_side != 48, while gemma4.rs:27-40 accepts ranges (1..=64, 1..=16) that no producer can emit (frontend.py:124-127,140-141 require 16 and 3; :168-173 emits them as literals). The caps are documented as defensive at :26, so this is tolerable. Fix: pin 16 and 3, or state in the comment that Ignition is the sole author of those values.
  7. Envelope is a shared frontend construct homed in a single profile module. helios/src/frontend/images/patch_merge.rs:10-17 declares pub(super) struct Envelope documented as "shared by PatchMerge and Gemma4", and gemma4.rs:8 imports it via use super::patch_merge::Envelope;. Fix: move it to frontend/images/envelope.rs (not opened) (or beside ImageGeometry in mod.rs); the extraction itself is genuine de-duplication and MiniMax semantics are unchanged (token-uniqueness validation moved verbatim, expand_prompt delegates).
  8. atomic_spans: bool should be Option<&ImageSpan>. Derived at helios/src/model/prompt.rs:52-65, consumed at layouts/bracketed.rs:23,58, and tests pass bare false (bracketed.rs:175,199). The gate itself is correct and must stay: helios/src/model.rs:467-469 rejects non-empty spans when the contract declares no ImageSpan, and MiniMax Bracketed cores declare none (helios/src/model/prompt.rs:478-484 sets span: None for every non-Deepseek layout), so unconditional emission would break existing cores. Fix: pass the prepared Option<&ImageSpan> so the derivation sits with its use, as class_token receives its token.
  9. % 3 is enforced on cores that never consume the field, and reported generically. helios/src/model.rs:89 rejects any vision core whose patch_features is not a multiple of three, but the value is only read through bracketed_patch_features() (model.rs:74-80, used from frontend/images/packing.rs:40-41 and the bracketed arm). The failure surfaces as the generic "invalid prepared vision capabilities" (:99). Fix: scope the rule to ImageLayoutKind::Bracketed or name the field and both values in the error.
  10. An untested invariant and two doc/wording fixes. (a) helios/src/scheduler/policy.rs:343-350 truncates end back to span.start when the computed end falls strictly inside a span, so any captured prefill capacity smaller than the envelope contributes no work for a span-bearing image request; the new bootstrap bound (server/config.rs:464-479) makes that unreachable when the captured capacity equals prefill_chunk_size, but no test pins the relationship — one sub-envelope capacity case would. (b) helios/README.md:806 regenerates the Gemma 4 fixture with "$SNAPSHOT", whose only prior definition is the Qwen3.8 command at :787-789 pointing at a different checkpoint — use GEMMA4_SNAPSHOT or name the directory at :798-802. (c) The description's "decodes, resizes, normalizes, packs, and validates" overstates: the profile rescales by 1/255 only (gemma4.rs:192-196; frontend.py:124-127 requires do_normalize: False, image_mean 0, image_std 1), as helios/README.md:716 correctly says — change to "rescales by 1/255".

Accepted as-is — do not re-raise

Checked and clean

Open questions / could not establish