Verdict: worth it with changes
The change is aimed at the right layer and the right problem, and it is built in the style the project already uses. It should not merge as-is: it carries a downgraded generated artifact, a hardcoded geometry table that contradicts its own stated goal, and one shared-code change (populating data.spans) with zero test coverage. Fix those five or six specific things and it is mergeable.
Charter fit: mostly good
Right layer. The charter says Helios "shouldn't accumulate per-model branches (#267, #334)" — but image preparation is already an explicit, enumerated extension point, not an ad-hoc branch. docs/model-contract.md:226-227 (not opened): "Tool parsers, reasoning parsers, image preparation, and image layouts each have an independent enum selector. Implementations are reusable syntax or image [implementations]." There are already eleven profiles (qwen, mimo, deepseek4, deepseek_row_major, moonvit, step, radio, glm, patch_merge, padded_grid), and the most recent, padded_grid, was added by a maintainer (Luke Alonso, 8628b7c5). Adding a twelfth profile is the sanctioned shape, not a violation.
Not a new model alias. It adds a preparation profile for a family the repo already supports: docs/model-preparation.md:345 lists gemma-4-e2b, -e4b, -12b, -26b-a4b, -31b and NVFP4 variants. The PR's Ignition side pins geometry shared by all of them (ignition/preparation/frontend.py:126-129: 27 layers, 1152 hidden, 16 heads, head_dim 72, 4304 FFN), so "more than a single checkpoint (#74)" is structurally satisfied — but see the evidence gap below.
A real gap. Today's Gemma 4 fixture has no image support at all: helios/tests/support/contracts/gemma4_frontend.json:16-17 (image_preparation: null, image_layout: null) and :38 (image_tokens: null). So Gemma 4 is text-only in Helios, and this PR is what unblocks images for it. That is a genuine user-facing benefit for people running Gemma 4 locally, which is exactly the focus the charter asks for.
Fits several "how we work" rules. The proto changes are strictly additive (ImagePreparationKind value 11, ImageSettings.profile tag 11 — helios/proto/runtime_core.proto:386,522), so existing cores stay wire-compatible. The Bracketed validation is generalised rather than special-cased: tokens.checked_mul(patches_per_feature) == patches replaces the old tokens == patches/4 && patches_per_feature == 4 (helios/src/frontend/images/packing.rs:488, cf. :527 in class_token, which was left alone). Extracting patch_merge::Envelope (helios/src/frontend/images/patch_merge.rs:11-81) instead of copying the envelope logic is the right call, and it reuses resize::resize rather than adding a second resampler. That is the "smallest footprint in shared code" the charter asks for.
Costs
- Code: one new file,
helios/src/frontend/images/gemma4.rs(416 lines, roughly half of it tests); ~130 lines touched elsewhere; a ~10-line generic addition toprepare_image_inputs. - Maintenance: a thirteenth-profile-shaped surface (describe JSON, protobuf decode, Ignition extraction, fixture) — the same recurring cost every existing profile carries, which is the accepted design.
- Performance: no serving-path cost. Decode/resize/pack already happen on the frontend pool; the only new work per image is the same bicubic pass other profiles do.
- Risk: concentrated in one place — the
data.spanschange in shared prompt code — plus one preparation-time validation hole.
Must fix before merge
- The checked-in protobuf is a downgrade.
ignition/preparation/runtime_core_pb2.py:5goes fromProtobuf Python Version: 7.36.2to7.36.1, and:16from minor2to1. Main's file was generated at 7.36.2 (from #430) andpyproject.toml:34pinsprotobuf>=7.36.2,<8. Regenerate with the pinned toolchain perhelios/manifest.md:468-472. This is a "pin everything (#215)" violation and would make the artifact look tampered with in review. - The hardcoded geometry table defeats the PR's own claim.
helios/src/frontend/images/packing.rs:16-21matches4 => (2, 1176), 9 => (3, 768)and errors otherwise. The PR description says the stride and width are "derived ... directly frompatches_per_feature... with no model-identity branching"; a two-entry literalmatchis a model-identity branch in disguise. Worse, the same constant is written three times:gemma4.rs:159computes3 * patch_size * patch_size,packing.rs:19hardcodes768, andconditioned.rs:192hardcodes768. Derive both from the profile/contract (e.g. carry patch feature width or the merge side next topatches_per_featureinVisionCapabilities), or at minimum from one shared helper. A future 2×2-merge encoder with 588-wide patches will otherwise silently fail upload. - The spans change has no test.
helios/src/model/prompt.rs:137-151now fillsprepared.data.spansfor any layout whoseImageTokenLayoutdeclares a span. That is shared code affecting scheduling (helios/src/scheduler.rs:1913-1934,helios/src/server/runtime.rs:1460(not opened)) for models beyond Gemma 4. Add tests for: (a) a span-declaringBracketedlayout gets spans equal to the conditioned input token spans; (b) layouts that already fill spans (ImageLayoutKind::Deepseek, which pushes athelios/src/frontend/images/layouts/deepseek.rs:149) are unchanged, since theis_empty()guard is the whole safety argument; (c) a layout with no span stays empty (helios/src/model.rs:452-454still rejects it). - Preparation doesn't validate what it will later depend on.
ignition/preparation/frontend.py:130-137hardcodes"<|image|>", "<|image>", "<image|>"with no check that each encodes to one atomic token — contrast_native_image_placeholder(frontend.py:231-245), which does exactly that for DeepSeek. Today a tokenizer mismatch only fails at request time insideEnvelope::expand(patch_merge.rs:38-48). Also:max_soft_tokensup to 1120 produces an image span of up to 1122 tokens, butvalidate_prompt_datarejects any span longer thanprefill_chunk_size(helios/src/model.rs:420-423, again atscheduler.rs:1926). Nothing validates that pair at preparation, so a recipe with a 512-token prefill chunk could export a core that rejects its own large images at admission. Reject the combination during preparation, with the reason stated. - Make the parity evidence durable. Both Hugging Face parity tests return silently unless
FLARE_GEMMA4_TEST_SNAPSHOTand../.venv/bin/pythonexist (gemma4.rs, the two tests near the end of the file), so CI proves nothing here — the 45-passing claim is a local run. Follow thepatch_merge.rs:174-212precedent but gate it on a checked-in fixture of reference pixels/positions rather than a livetransformersimport, or record the environment in the test output. The exactness claim is also narrower than it reads: f32 parity is against syntheticarangeimages at 91×37, 10×3000 and 3000×10. One real photograph and one second Gemma 4 checkpoint (the 26B-A4B or E4B, not just the 31B snapshot) would make the "#74 / prove it exports and serves" case. - Add the missing Ignition test and doc note. There is no
pytestforimage_settings(profile="gemma4")despite the new strict_expected()pins atfrontend.py:113-129— and those pins are exactly the kind of checkpoint-contract assertions this repo tests elsewhere. Also record the profile's pinned processor/vision fields and the prefill-chunk constraint somewhere indocs/, sincedocs/model-preparation.mdcurrently says nothing about Gemma 4 images.
Minor: SUPPORTED_SOFT_TOKENS is duplicated (gemma4.rs:8 and frontend.py:123); pick one owner.
Is there a simpler way?
Not for the preprocessing itself. Ignition is Python and serves nothing at request time, so the HF Gemma4ImageProcessor can't be reused; and the patch layout (interleaved (y, x, channel), (x, y) positions, 1/255 scaling) genuinely differs from patch_merge's channel-planar 1176-wide temporal patches — reusing that profile would mean parameterising patch layout, stride, normalization and geometry mode, which is more code, not less. The Envelope extraction already takes the one real reuse opportunity. The only place the PR makes itself more complicated than necessary is item 2 above.
The honest caveat: the atomic-span path has no in-repo consumer yet, since serving needs the companion recipe PRs in local-inference-lab/hyperflare-recipes. That is a reason to land the preparation profile (it is inert until a recipe selects it) but also a reason item 3 is non-negotiable — the one piece with cross-model blast radius is the one piece that end-to-end testing will not exercise.
Bottom line
Worth it with changes. The profile fills a real hole for an already-supported model family, lives at the sanctioned extension point, and is built with acceptable restraint and additive wire changes. Blocking items are mechanical (regenerate protobuf at 7.36.2; derive instead of hardcoding the 4/9 table; remove the three-way duplicated 768), one is a correctness risk in shared code (test the spans population across span and non-span layouts), and one is a preparation-time guard (single-token validation of the three image tokens; reject max_soft_tokens × 9 merges whose span exceeds the prefill chunk). With those plus a durable parity fixture and a second checkpoint, this is a clean merge.