#1 [high] PR 483 scope and diff map
PR #483 by rickybrent, branch rickybrent:core/gemma4-image-frontend (f2340e42) vs main 6d6fe0c6. Adds a 12th image preparation profile (Gemma 4) plus changes to bracketed packing and prompt spans.
Files:
- helios/proto/runtime_core.proto: ImagePreparationKind GEMMA4_IMAGE_PREPARATION = 11; ImageSettings oneof
gemma4 = 11with Gemma4ImageSettings{patch_size, pooling_kernel_size, max_soft_tokens, image_token, start_token, end_token}. - helios/src/frontend/images/gemma4.rs (new, 416 lines): Processor{limits, patch_size, pooling, max_soft_tokens, envelope}; SUPPORTED_SOFT_TOKENS [70,140,280,560,1120]; geometry() = HF area-bounded aspect-preserving resize floored to patch*pooling multiples with clamp branches; process() packs interleaved RGB (y,x,channel) patches,
(x,y)position_ids, values scaled 1/255; expand_prompt delegates to shared patch_merge::Envelope. Unit tests include HF Gemma4ImageProcessor parity for (91x37), (10x3000), (3000x10) exact f32 compare, gated behind .venv/bin/python. - helios/src/frontend/images/patch_merge.rs: extracts Envelope (token validation + expand) out of Processor so Gemma 4 can reuse it; behavior of PatchMerge unchanged.
- helios/src/frontend/images/packing.rs: new
bracketed_patch_geometry(patches_per_feature) -> (merge_side, patch_width)with hardcoded 4->(2,1176), 9->(3,768), anything else Err; tensor_layout gains a patches_per_feature arg; bracketed() validates h%merge_side, tokens*ppf==patches instead of tokens==patches/4 and ppf==4. - helios/src/model/packing.rs: passes config.contract.vision.patches_per_feature into tensor_layout.
- helios/src/model/prompt.rs: prepare_image_inputs now fills prepared.data.spans from conditioned_inputs token_spans when empty and the contract's ImageTokenLayout declares a span (generic, applies to any layout).
- helios/src/model/contract.rs: ImagePreparationKind::Gemma4 = 11.
- helios/src/runtime_core/{describe,protobuf}.rs: describe/protobuf JSON for the new profile.
- ignition/preparation/frontend.py: image_settings(profile="gemma4") with _expected() pins on preprocessor_config (patch_size 16, pooling 3, do_resize/rescale, do_normalize False, mean 0/1, max_soft_tokens in the five allowed) and config vision_config (27 layers, hidden 1152, heads 16, head_dim 72, ffn 4304); hardcodes "<|image|>", "<|image>", "<image|>".
- ignition/preparation/runtime_core_pb2.py: regenerated, but the header regresses "Protobuf Python Version: 7.36.2" -> "7.36.1" and ValidateProtobufRuntimeVersion minor 2 -> 1, i.e. regenerated with an older protoc than the one that produced main's file.
Claimed evidence: cargo lib tests frontend::images 45 passed with FLARE_GEMMA4_TEST_SNAPSHOT; model:: 53 passed; flare-cli cargo check; pytest 15 passed; explicit limitation that end-to-end serving needs companion recipes in local-inference-lab/hyperflare-recipes.
#2 [high] Charter fit and evidence gaps for PR 483
Charter: (a) "Keep the runtime small and model-agnostic ... shouldn't accumulate per-model branches (#267,#334)"; (b) "New model recipes, aliases, or formats must list supported checkpoints ... prove they export and serve cleanly from the PR branch, and support more than a single checkpoint (#74)"; (c) "Bring real evidence"; (d) "solve the right problem in the right place / smallest footprint"; (e) "Be explicit and pin everything. No magic defaults".
Precedent that image profiles belong in Helios: docs/model-contract.md:226-227 ("image preparation and image layouts each have an independent enum selector"), 11 existing profiles (qwen, mimo, deepseek4, deepseek_row_major, moonvit, step, radio, glm, patch_merge, padded_grid), padded_grid added by maintainer Luke Alonso in 8628b7c5.
Gap this closes: Gemma 4 is an already-supported family (docs/model-preparation.md:345 lists gemma-4-e2b/e4b/12b/26b-a4b/31b) but Helios' own fixture has image_preparation/image_layout null and image_tokens null (helios/tests/support/contracts/gemma4_frontend.json:16-17,38) = text only today.
Defects to fix:
- protobuf artifact downgraded: ignition/preparation/runtime_core_pb2.py:5 "7.36.2"->"7.36.1" and :16 minor 2->1, i.e. regenerated with older protoc though pyproject.toml:34 pins protobuf>=7.36.2 and main's file was 7.36.2 (from #430). Regenerate per helios/manifest.md:468-472 with the pinned protoc.
- Hardcoded geometry table helios/src/frontend/images/packing.rs:16-21 (4->(2,1176), 9->(3,768), else Err) and duplicate literals: gemma4.rs computes 3patch_sizepatch_size, packing.rs hardcodes 768, conditioned.rs:192 hardcodes 768. Derive from contract/settings instead (e.g. add patch feature width to VisionCapabilities or to the profile).
- No test at all for the spans change (helios/src/model/prompt.rs:137-151): nothing asserts spans are populated for a span-declaring Bracketed layout, nor that span-declaring layouts that fill spans themselves (deepseek, layouts/deepseek.rs:149) are unaffected, nor that a non-span layout stays empty.
- Token literals hardcoded in ignition/preparation/frontend.py:130-137 ("<|image|>", "<|image>", "<image|>") with no preparation-time validation that each encodes to one atomic vocabulary token (contrast _native_image_placeholder at frontend.py:231-245 for DeepSeek). Failure currently only surfaces at request time via patch_merge::Envelope::expand.
- SUPPORTED_SOFT_TOKENS duplicated in gemma4.rs:8 and frontend.py:123.
- max_soft_tokens up to 1120 (=> image span 1122 tokens) is allowed, but validate_prompt_data rejects any span longer than config.limits.prefill_chunk_size (helios/src/model.rs:420-423). Nothing validates the pair at preparation; a recipe with prefill chunk 512 would export a core that rejects large images at admission.
- Evidence: HF parity tests silently return unless FLARE_GEMMA4_TEST_SNAPSHOT and ../.venv/bin/python exist (gemma4.rs checkpoint_tokens_expand_the_image_envelope, native_pixels_and_positions_match_the_checkpoint_processor), so CI proves nothing; exact f32 parity is on synthetic arange images at 91x37/10x3000/3000x10 only; no real photo, no second Gemma 4 checkpoint (#74), no export and no served request. PR says end-to-end needs companion PRs in local-inference-lab/hyperflare-recipes, so the atomic-span path has zero in-repo consumers.
- No new pytest for ignition image_settings(profile="gemma4") despite the new strict _expected() pins at frontend.py:113-137.
- No docs update recording the profile's checkpoint pins/limitations.
Good parts: reuses resize::resize (no new resampler), extracts patch_merge::Envelope instead of copying envelope logic, proto changes additive (tag 11 / enum 11), bracketed validation generalised (tokens*ppf==patches replaces ppf==4) with equivalent behaviour for ppf=4, gated parity harness mirrors patch_merge.rs:174-212 pattern.