Verdict: worth merging — PR #483 "Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans"
Head ab9a432b, base main 27716185, 38 files, +2490/−251. Third review pass; all verified against the current head.
One correction to my earlier summary: this is the eleventh image-preparation profile, not the twelfth — helios/src/model/contract.rs:68 (not opened) on main defines ImagePreparationKind 1–10 and the PR appends 11. The cross-profile consistency test has 11 rows because it includes Gemma 4.
Charter fit
Right layer. The charter says Helios "shouldn't accumulate per-model branches" (#267, #334). Image preparation is not an ad-hoc branch but a declared extension point: helios/model-contract.md:243-244 — "Tool parsers, reasoning parsers, image preparation, and image layouts each have an independent enum selector." Ten profiles already exist, the most recent (padded_grid) added by maintainer Luke Alonso in 8628b7c5. An eleventh is the sanctioned shape, and the only route by which a Gemma 4 core can declare native image preprocessing.
Not a new alias, and more than one checkpoint. Gemma 4 is already a shipped family: docs/model-preparation.md:321 (e2b/e4b/12b/26b-a4b/31b + NVFP4), docs/api.md:749 (not opened), docs/cli-design.md:457 (not opened),486, docs/model-development.md:77-83, history commits 1fd1f917, d367edc5 (#56), bcf7177d (#62). Images are the missing half. Ignition now asserts only consumed fields — model_type: gemma4, vision_config.model_type: gemma4_vision, patch_size 16, pooling 3, processor flags, soft-token allowlist (ignition/preparation/frontend.py:114-141) — so E2B/E4B/26B-A4B/31B pass while gemma4_unified (12B) is rejected (tests/preparation/test_frontend_gemma4.py:129), with three real cached checkpoints at :228-257.
Wire additive and inert. ImagePreparationKind = 11; ImageSettings.profile tag 11; VisionCapacity.patch_features field 6 with #[serde(default)] (helios/src/model.rs:51-53); describe.rs:466-468 omits 0 so legacy describe JSON is byte-identical; round-trip test at protobuf.rs:813 (not opened). Existing cores keep loading: missing patch_features decodes 0 → legacy 1176 (model.rs:72-80).
Decisive argument: it fixes two real main defects
- Every span-declaring
Bracketedimage failed per request onmain.layouts/bracketed.rsemitted nodata.spans, whilemodel.rs:442-465rejects any scoped token outside a span →"image token spans do not match their declared boundaries". Fixed inlayouts/bracketed.rs:57-88: the run is flushed when the feature run ends, the span isstart-1..end+1(coveringstart_token…end_token), bounds-checked at both ends, gated onimage_tokens.span.is_some(). The sharedprompt.rsfallback was deleted, not patched, so the layout that builds the envelope owns the span (matchinglayouts::deepseek). - Every cached MiniMax prepared-image record was discarded.
conditioned.rs:185-193onmainended_ => 588, soPatchMerge's 1176-wide patches never satisfiedvalid_processedand were re-materialized per request. Now viaImageProcessor::patch_features()(mod.rs:459-471,conditioned.rs:187), which also fixesPaddedGrid = 1200.
Both fixed without adding a branch in shared scheduling or cache code.
Cost
- Complexity: one new module
gemma4.rs(~210 lines product code, ~290 tests), ~70 lines infrontend.py, small glue inmod.rs/packing.rs/config.rs. ~1,900 of 2,490 added lines are tests and fixtures — evidence-heavy, which the charter asks for. - Maintenance: the same per-profile surface every profile carries.
packing.rsis simpler than before: a4→1176 / 9→768table replaced byisqrt+ prepared metadata (packing.rs:16-46). Load errors are per-condition and name both values (gemma4.rs:27-71), so an operator can distinguish a mis-exported core from a mis-declared checkpoint. - Performance: no serving-path cost; decode/resize/pack already run on the frontend pool and reuse
resize::resize. Net positive: theconditioned.rsconsolidation removes a per-request cache invalidation. - Risk: low. Inert until a recipe selects it.
validate_loaded_image_processorruns once at bootstrap (server/config.rs:290-298); the envelope/chunk bound isSomeonly for Gemma 4 (mod.rs:473-478), so no other core is affected. Legacy load proven through the realInputs::new:model/tests.rs:1279stripspatch_features, asserts decode → 0, loads and stages 16×1176 floats, and rejects a 768-wide manifest (:1446) and non-squareppf = 3(:1447-1451). The narrowing (Bracketedrequires positive-squarepatches_per_feature) covers only non-square nonzero values; zero is rejected earlier (model.rs:86-88).
Simpler way? Duplication?
No. Ignition is Python and serves nothing at request time, so HF's Gemma4ImageProcessor cannot be reused. Gemma 4's layout (interleaved (y,x,channel), (x,y) positions, 1/255, 3×3 pooling) genuinely differs from patch_merge's channel-planar temporally duplicated 1176-wide patches; parameterising one profile for both is more code and more risk. The PR takes the two real reuse opportunities: patch_merge::Envelope extracted and shared (patch_merge.rs:10-136, MiniMax behaviour unchanged), and resize::resize reused.
Residual, non-blocking
- #74's "serve cleanly" half is unmet at merge time. End-to-end needs the companion recipe in
local-inference-lab/hyperflare-recipesdeclaringvision.patch_features = 768. Correctly tracked (docs/TODO.txt:331-337), honestly stated, inert without a recipe — but this merge must not be read as "Gemma 4 vision works." - Merge-order friction with #229 (Muse Glimmer, open), which touches the same six image files: it adds
Profile::MuseGlimmerand its ownProfile::Glm | PatchMerge(_) | MuseGlimmer(_) => 1176arm atconditioned.rs:191, plus a secondEnvelope-freePatchMergeinpatch_merge.rs. Textual conflict in exactly the files this PR rewrote. Semantically compatible (#229 ispatches_per_feature=4, width 1176,span=None, so it lands on the legacy path), but whoever merges second must rebase ontoImageProcessor::patch_features()and the extractedEnveloperather than resolve toward either side. docs/model-preparation.md:321listsgemma-4-12bwhile the profile rejectsgemma4_unified; text path unaffected, one clarifying line would help.helios/tests/support/contracts/gemma4_frontend.json:16-17,38still has null image fields, so no checked-in contract fixture drives the whole prepare→span→validate path; pieces are covered individually and the core-load path is now synthesized inmodel/tests.rs.pyproject.toml:34(not opened) pinsprotobuf>=7.36.2whilemain's own artifact says 7.36.1 — pre-existing, separate fix.- Verification limits: this pass was read-only — no
cargo test/pytestrun. Claims come from reading code and callers; the author's test counts are their own evidence and nothing here depends on them.
Bottom line
Worth merging. It sits at the sanctioned extension point, keeps the wire additive, ships CI-durable bit-exact parity against Hugging Face across 8 fixture cases at two soft-token budgets, moves three invariants from per-request rejection to load-time failure, and repairs two independent latent main defects — a per-request rejection for any span-declaring Bracketed core, and a per-request cache-invalidation bug for every MiniMax prepared image. Land it, then treat the TODO's end-to-end qualification as the real bar before claiming Gemma 4 vision support.