#1 [high] should fix: patch_size/pooling_kernel_size are dead knobs; patch width duplicated 3x
Gemma4ImageSettings carries patch_size and pooling_kernel_size through proto (helios/proto/runtime_core.proto:535-542), Rust struct (helios/src/frontend/images/mod.rs:332-341), Python producer (ignition/preparation/frontend.py:113-137, which hard-codes 16/3 after _expected rejects anything else), and a validation in helios/src/frontend/images/gemma4.rs:23-44 (patch_size>0,<=64; pooling>0,<=16; SUPPORTED_SOFT_TOKENS allowlist).
Nothing else derives from them consistently:
- helios/src/frontend/images/conditioned.rs:192 hard-codes
Profile::Gemma4(_) => 768for the cached-image validity check, while gemma4.rs:116 computespatch_features = 3 * self.patch_size * self.patch_size. With patch_size != 16 (which load() accepts) valid_processed is always false -> every cached Gemma4 image is recomputed/invalidated silently. - helios/src/frontend/images/packing.rs:16-22 maps patches_per_feature 9 -> patch width 768 for the graph binding; a third copy of the same number.
Glm/padded-grid precedent: profile constants live in the module (glm.rs:13 const FACTOR: usize = 28). Fix: drop patch_size/pooling_kernel_size from the protobuf message, the settings struct, serde, and the Python producer; keep profile constants in gemma4.rs and one const FEATURES: usize = 3 * 16 * 16 used by conditioned.rs and packing.rs. Smaller diff, one source of truth, and removes the unreachable validation.
#2 [high] should fix: gemma4 envelope test shells out to Python for a chat template it never uses
helios/src/frontend/images/gemma4.rs:236-332 checkpoint_tokens_expand_the_image_envelope:
- requires FLARE_GEMMA4_TEST_SNAPSHOT, then bails silently if ../.venv/bin/python is missing;
- writes a temp jinja file (temp_dir + process id), spawns Python to call ignition.preparation.frontend.downloaded_template_asset on helios/tests/fixtures/templates/gemma4/chat_template.google.patch.json, hashes it, builds a Frontend with it, and removes the temp file only on the success path (early
returnat line 281-283 leaks it).
The assertions (lines 311-331) only exercise Envelope::expand with a prompt encoded by frontend.encode(...); chat-template rendering is never called. FrontendAssets.chat_template is an Option, so the whole subprocess block can go: load the tokenizer/tokenizer_config assets only, then encode "Look <|image|> now" and assert the envelope. Envelope::expand itself is already covered end to end by helios/src/frontend/images/layouts/bracketed.rs:104-180 (real rendered prompt, two images, feature order, start/end tokens, error on empty images) after this PR made both profiles share Envelope — so this test can shrink to a few lines or be dropped.
#3 [medium] should fix: gemma4 parity test needs an unpinned local venv; use a checked-in fixture like glm
helios/src/frontend/images/gemma4.rs:334-415 spawns ../.venv/bin/python and from transformers.models.gemma4.image_processing_gemma4 import Gemma4ImageProcessor inside the test, returning silently when the venv is absent — so on CI it proves nothing and locally it depends on an unpinned installed transformers version. Every other profile's parity evidence is a checked-in fixture (tests/frontend/glm53_images.json used by glm.rs:147-199; qwen38_images.json for decoding_tests.rs:60-92; tests/frontend/generate_glm_image_fixtures.py as the generator). Fix: add tests/frontend/gemma4_images.json plus a generator script and compare hashes as glm.rs does; that drops the struct-packing stdout protocol (lines 340-354, 365-404, all the offset arithmetic) and keeps parity evidence available without a network/venv. Note the same file also duplicates geometry expectations between geometry_matches_the_hugging_face_processor (lines 197-216) and the parity test, and (10,3000)/(3000,10) cases are claimed in the PR as unit-only.
#4 [medium] should fix: prompt.rs spans back-fill duplicates what layouts already do
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(|i| i.token_span.clone()).collect();
}
This runs for every image layout with a declared span, not just Gemma4. Only two layouts declare one today: Deepseek (helios/src/frontend/images/layouts/deepseek.rs:149 already pushes spans, so is_empty() is false and this is dead for it) and Gemma4 (Bracketed + PatchMerge profile). So the condition can be simply "the layout declares a span" and the is_empty() guard — which silently prefers the layout's own spans over the conditioned inputs rather than validating that they agree — disappears. Better: assert prepared.data.spans.len() == prepared.conditioned_inputs.len() and return an error if both produced spans, so an overlap is a defect rather than a silent preference. Both are then checked by validate_prompt_data (helios/src/model.rs:436-451) anyway.
Simpler still: have the two layout producers that know about the span (bracketed.rs prepare_input, which already computes token_expansions/conditioning per image) fill data.spans there, exactly as deepseek.rs:149 does, and delete the whole post-hoc block in prompt.rs. That also puts Gemma4's span production next to the expansion that produces it instead of in shared code with a model-shaped condition.
#5 [medium] nits: redundant merge_side check, unrelated reformatting, weak packing test, duplicated soft-token allowlist
-
helios/src/frontend/images/packing.rs:16-22
bracketed_patch_geometry(patches_per_feature) -> (merge_side, patch_width)maps 4->(2,1176), 9->(3,768), else error. It is called fromtensor_layout(line 39-42, uses only the width) and frombracketed(line 480-481, uses both). Two things to trim:merge_sideis redundant:bracketedline 486 requiresh % merge_side == 0 && w % merge_side == 0where merge_side comes from the same patches_per_feature. That check is implied by the neighbouringh*w == geometry.patchesplustokens * patches_per_feature == patches(line 488) only for the merge grid, but the essential invariant (grid divisible by the pooling side) is the frontend's job: gemma4.rs:46-47side_multiple()already guarantees every resize target is a multiple of patch_size*pooling, and the profile's own geometry is the only producer. Keeping the shape check inside the Gemma4 profile (it already errors there) is the smaller version; the packing side can keep just thetokens * patches_per_feature == patchesidentity it had before.
-
packing.rs:494-502: the reformatting of the
staging.put("vision_pixel_values", ...)call from one long line to six is unrelated churn in an otherwise mechanical change (AGENTS.md "Reject unsupported … churn. Unsolicited formatting … are not contributions by themselves"). Same for thestaging.put(...)/flat_mapreshape; it obscures that the only real change is1176 -> patch_width. -
packing.rs:570-586: the new test asserts only that tensor_layout returns patches768 for patches_per_feature=9 and errors for 16. It does not exercise
bracketed()'s validation (theh % merge_sidepath, the tokensppf identity, the truncated-pixel error) even though the PR's headline claim is that Bracketed now supports 9. Since helios/src/frontend/images/packing.rs tests are#[cfg(test)]in-crate and ProcessedImages is constructible there, a bracketed(...) test with a 48x48 patch grid (grid_thw [1,48,48], patches 2304, tokens 256) and a rejected 47-row grid would prove the behaviour; the current one only proves a table lookup. -
helios/src/frontend/images/gemma4.rs:11
SUPPORTED_SOFT_TOKENS: [usize;5] = [70,140,280,560,1120]is duplicated in ignition/preparation/frontend.py:123if image.get("max_soft_tokens") not in (70, 140, 280, 560, 1120). Two allowlists in two languages where nothing else in the profile varies with the value (geometry derives everything from max_soft_tokens via max_patches()). Either keep the Python check and let Rust accept any positive value, or drop both and let geometry's own budget check be the guard; the duplicated list is the piece to delete. The Rust-side check cannot be exercised anyway once patch_size/pooling are constants (see entry 1) because the Python producer rejects other values first.
#6 [low] checked and fine: Envelope extraction, pb2 regeneration noise
No finding, for honesty in the report:
Envelopeextraction in helios/src/frontend/images/patch_merge.rs:10-81 is a real de-duplication (patch_merge.rs:123-131 and gemma4.rs:160-167 now share one expand). KeepingProcessoras a thin wrapper delegating toEnvelope(patch_merge.rs:83-131) is also right: callers in mod.rs:900-918 stay untouched.Profile::Gemma4(_) => 768in conditioned.rs, the describe.rs/protobuf.rs one-line arms, theImagePreparationKind::Gemma4 = 11enum addition are the minimum needed for wire compatibility (AGENTS.md model-core-compatibility section requires additive tags with preserved defaults).- ignition/preparation/runtime_core_pb2.py:1-30 is generated; the diff includes a Protobuf Python Version 7.36.1 vs 7.36.2 revert plus regenerated descriptor. Worth flagging as review noise only: the header now claims a compiler version older than main's, so whoever regenerates next will flip it back. Not a functional defect (ValidateProtobufRuntimeVersion accepts it).
- The Rust raster loop in gemma4.rs:135-152 (y/x/channel) and the f32 1/255 scaling are required by the checkpoint layout; no simpler form without a lookup table, which would be churn.
- gemma4.rs:95-101
resized_rgbhas no in-tree caller for this profile (only tests/tools/test_images.rs uses the generic path for qwen fixtures), but every other profile implements it and mod.rs dispatches on it sym.flag; keeping it is consistent, not bloat worth blocking.