Review of PR #483 — Gemma 4 image preparation, Bracketed patch-width metadata, atomic spans
Lens: architecture and scope. Head: ab9a432, base: main 27716185, 36 files +2269/−240.
Verdict: should-fix issues only. No blocking findings.
Key findings
- Every blocker and should-fix from my previous round is fixed at this head and verified in code (see "Prior findings: verified fixed").
- S1 No Gemma 4 core exists in the tree. The only Gemma 4-named contract fixture declares
image_preparation: null,image_layout: null,image_tokens: null, and no other fixture usesBracketed(9) or preparation 11. The profile is never mounted from a prepared contract, so nothing exercisesBootstrap::load → validate_loaded_image_processor → served image request.AGENTS.md:155-169asks a new format to prove it exports and serves. - S2 The Gemma 4 processor file is not where
prepare_frontend's default looks: it readspreprocessor_config.json(not opened), Gemma 4 snapshots shipprocessor_config.json(not opened), and every test passes the path explicitly, so the default is untested. - S3 Two wire knobs (
patch_size,pooling_kernel_size) are unreachable from the only producer, and the soft-token allowlist is duplicated Rust/Python with no test tying them (AGENTS.md:188-193). - The scope question resolves in favour of the PR: the profile rides the existing
ImageSettingsenum, the proto change is additive and back-compatible, and the load-time envelope bound lives in bootstrap where it belongs. No performance claim is made. - Correction to my own earlier review: my advice to drop
atomic_spansand letmodel.rsgate it was wrong.helios/src/model.rs:467-469rejects non-empty spans when the contract declares noImageSpan, and MiniMaxBracketedcores declare none (helios/src/model/prompt.rs:478-484setsspan: Nonefor every non-Deepseek layout). Unconditional emission would break existing MiniMax cores. The flag is required; only its shape survives as a nit.
Prior findings: verified fixed at ab9a432
- Authoring surface.
ignition/preparation/contract.py:109-119: the defaultvisiondict now carries"patch_features": 0, and the docstring at :111-115 tells aBracketedrecipe with a non-1176 width to set it. The new load-time error is no longer the first a recipe sees. - Existing cores still load.
helios/src/model/tests.rs:1279-1452legacy_bracketed_core_omitting_patch_features_loads_and_stages_1176_wide_pixels: serializes aBracketedcontract, removespatch_featuresfrom the JSON (:1334-1338), asserts decode is0, loads throughInputs::newwith a 1176-wide buffer, stages16 * 1176floats (:1438-1443), and rejects a 768-wide buffer (:1446) and a non-squarepatches_per_feature(:1447-1451). The compatibility half ofAGENTS.md:182-186is now real test evidence rather than a description claim. - Load errors.
helios/src/frontend/images/gemma4.rs:25-84produces per-condition messages naming the field and both values (patch_size :27-33, pooling :34-40, soft tokens :41-47, pooling area vspatches_per_feature:52-60, patch budget :61-71), with the1..=64/1..=16caps commented as defensive wire caps (:26) — the styleserver/config.rs:443-489already uses. - Width plumbing.
gemma4.rs:86-88patch_features()is the single expression, used at :164 for both capacity and reserve; the count→width lookup table is gone frompacking.rs. - Fixture provenance.
tests/preparation/test_frontend_gemma4.py:187-225reads themodelandprocessorblocks oftests/frontend/gemma4_images.json(not opened) and asserts the resolved settings (patch 16 / pooling 3 / 280). Not dead data any more. - Dead test removed and temp file guarded: no
native_pixels_and_positions_match_the_checkpoint_processor; the temp chat template isDrop-guarded (gemma4.rs:443-448, dropped at :469). - Docs:
docs/runtime-core-design.md:180-194and :233-242;helios/model-contract.md:82(not opened);docs/TODO.txt:330-337.
Should fix
S1 — No Gemma 4 core exists in the tree; the served path is unexercised
helios/tests/support/contracts/gemma4_frontend.json is the only Gemma 4-named contract fixture and declares "image_preparation": null (:16), "image_layout": null (:17), "image_tokens": null (:38) — it cannot load an image processor at all. No fixture under helios/tests/support/contracts/ uses Bracketed (9) or preparation 11; the layouts in use are 1, 2, 3, 7, 8, 10. Gemma 4 coverage is Rust-constructed only: helios/src/model/prompt.rs:1171-1284 (two 262-token spans, patch_features: 768, 64-aligned rejection) and helios/src/server/config.rs:935-1023 (bootstrap bounds); the Ignition side is ignition/preparation/frontend.py:114-174 with tests/preparation/test_frontend_gemma4.py.
Nothing takes a Gemma 4 core from Bootstrap::load (server/config.rs:290-298) through validate_loaded_image_processor to a served image request. AGENTS.md:155-169 asks a new format to "prove they export and serve cleanly from the PR branch, and support more than a single checkpoint"; the compatibility half (:182-186) is now tested, the export/serve half is deferred to the unlanded recipe PR and recorded open at docs/TODO.txt:330-337. CI on the head commit reports no checks at all, so even the author's unit evidence has not run in CI.
Fix (cheap): 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 — the limitations paragraph covers missing timing/memory but not that the profile has never been served.
S2 — The Gemma 4 processor file is not where the default path looks
ignition/preparation/frontend.py:310: path = snapshot / "preprocessor_config.json (not opened)" if preprocessor is None else Path(preprocessor). The new gemma4 branch (:114-174) validates a Gemma4Processor dict read from that path, while the padded_grid doc at :100 already records that some families put the processor in processor_config.json (not opened). Gemma 4 snapshots ship processor_config.json (not opened) — the checked-in fixture is a processor dump, and every test passes the path explicitly (tests/preparation/test_frontend_gemma4.py:88 preprocessor=tmp_path/"processor_config.json (not opened)", :246 preprocessor=snapshot/"processor_config.json (not opened)").
So a recipe calling prepare_frontend(snapshot, image_profile="gemma4") — the documented shape used for the other profiles — raises FileNotFoundError; no test covers the default, so CI cannot catch it. Pre-existing for padded_grid, so this is consistency plus a missing test rather than a new defect.
Fix: 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.
S3 — Two unreachable wire knobs and a duplicated allowlist
Gemma4ImageSettings.patch_size / pooling_kernel_size (helios/proto/runtime_core.proto:598-605, helios/src/frontend/images/mod.rs:332-341) travel proto → serde → Python, but the only producer fixes them at ignition/preparation/frontend.py:127-141, which makes the caps at gemma4.rs:27-40 unreachable. Their justification is precedent: PatchMergeImageSettings.patch_size is likewise fixed to 14 (patch_merge.rs:92 (not opened)), so the fields are acceptable if that precedent holds — but then the caps should be documented as belt-and-braces only, which they now are (:26).
The real problem is the duplicated gate: the soft-token allowlist exists twice, in Rust (gemma4.rs:13 SUPPORTED_SOFT_TOKENS) and Python (frontend.py:132), with no test tying them. AGENTS.md:188-193 forbids configuration switches and extension points without a concrete requirement, and a duplicated authority for the same invariant is exactly the kind of drift it aims at. Fix: tie them with a test (feed the Python list through the Rust loader), or reduce to one — preparation is the right home for the checkpoint gate, and Rust can accept any positive budget.
Nits
atomic_spans: bool(helios/src/frontend/images/layouts/bracketed.rs:23, computed athelios/src/model/prompt.rs:52-65) is correct behaviour, but it should passOption<&ImageSpan>— the prepared contract field — so the derivation sits with its use, asclass_tokenreceives its token.Envelopenow lives inpatch_merge.rs:10-17 (not opened), 84-136but is shared by two profiles (gemma4.rs:8imports it); move it tofrontend/images/envelope.rs(not opened). The extraction itself is genuine de-duplication with no MiniMax behaviour change (token-uniqueness validation moved verbatim,expand_promptdelegates).gemma4.rs:384-402repeats seven of nine fixture rows already pinned by SHA-256 at :315-381; only(100,3000)/(3000,100)are unique.pixels_interleave_rgb_and_positions_are_xy(:405-420) restates the 91×37 case.packing.rs:685-815repeatspatch_features: 0ten times where three rows cover every distinct outcome.
Scope: does this belong here?
Yes. helios/src/frontend/images/ already owns ten preparation profiles; Gemma4 goes behind the existing ImageSettings enum (mod.rs:249-261, :287, :355), the established extension point rather than a new mechanism — consistent with the charter's "keep the runtime small and model-agnostic" (charter line 12), since the profile is a frontend profile, not a scheduling branch.
Compatibility surface, read at this head:
VisionCapacity.patch_featuresis additive tag 6 with#[serde(default)](helios/src/model.rs:51-53);0maps to legacy 1176 viabracketed_patch_features()(model.rs:74-80).- Decode is one arm (
runtime_core/protobuf.rs:168-172); describe omits the field when 0 (describe.rs:466-468(not opened)); the round-trip test (protobuf.rs:813-866) confirms tag 11 selects only image preparation. VisionCapabilities::validate()(model.rs:82-102) accepts 0 and rejects non-multiples of 3.- Envelope bounds (
server/config.rs:464-487) are checked at bootstrap against bothprefill_chunk_sizeandspan.max_tokens, so an impossible envelope fails at load instead of per request — the right layer, and the reason the PR's stated motivation holds. - No timing or memory claim is made, so the measured-evidence rule is not engaged.
The one genuine narrowing: square_merge_side (packing.rs:16-22) runs inside tensor_layout, reached from Inputs::new (model/packing.rs:92-97), so a Bracketed core with a non-square nonzero patches_per_feature now fails to load (zero is already rejected at model.rs:88). The new test covers it (helios/src/model/tests.rs:1447-1451). The description already lists this narrowing; it should state that it is load-time for any Bracketed core, not only a MiniMax load-path change.
Checked and found clean
Overflow guards in gemma4.rs (checked_mul :48-51/61-64, try_fold :157-162, check_batch before and after geometry at :152/:163). bracketed() rejects grids not divisible by the derived merge side and any token/patch mismatch (packing.rs:491-497) — divisibility is not implied by tokens * patches_per_feature == patches, and the author is right to check it. layouts/bracketed.rs:89-93 cross-checks image and feature counters against processed geometry; flush_span validates both ends of every run against the expanded prompt (:59-65) rather than trusting the offset. validate_conditioned_inputs (prompt.rs:153-191) still enforces per-span feature ownership, so the new spans cannot smuggle cross-span features.
Open questions / could not establish
- Whether any published
Bracketedcore declares a non-squarepatches_per_featureor omitspatch_features. The manifests live inlocal-inference-lab/hyperflare-recipes; a sweep there settles the narrowing's blast radius. - Whether landing the profile ahead of its companion recipe PR had explicit maintainer sign-off. The author's reasoning (recipes were extracted, so the core profile must land first) is plausible, but only a maintainer can confirm, and
AGENTS.md:165-169makes the approval the gate. - Verification limits: this review is read-only. No
cargo test,cargo checkorpytestwas run, and the head commit reports no CI checks, so every test count above is the author's own evidence. Nothing in my findings depends on those counts.
What to do next
- S1 — add one
Bracketed+Gemma 4 contract fixture, or state in the description that Gemma 4 serving is unqualified. - S2 — resolve the processor file per profile, with a test for the default argument.
- S3 — tie the two soft-token allowlists with a test, or delete one.
- Nits 1-3, batchable in a single pass.