Prose review — PR #483, "Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans"
Head 2b4a31e against main 27716185; 36 files, +2269/−240. Judged against AGENTS.md:43-70 (required prose review), AGENTS.md:72-140 (required PR description), and .agents/skills/repo-prose/SKILL.md:26-46 (not opened).
Key findings
The description now satisfies the four mandatory parts in order (why / what changed / claimed result / evidence) and the earlier round's blocking defects are genuinely fixed: the Hugging Face comparison tests are #[ignore]d with hard assertions instead of silently returning, an unconditional checked-in fixture test backs the bit-exactness claim, atomic-span emission moved into the layout with span-bearing/too-small-chunk/no-span coverage, the load-path narrowings are disclosed, and the docs gained the Gemma 4 paragraph, patch_features documentation, and the docs/TODO.txt qualification entry.
What remains is documentation drift and precision, not incorrect claims:
helios/README.md:721-728contradicts the Gemma 4 paragraph immediately above it (should fix).docs/runtime-core-design.md:233-240still omits Gemma 4 from the per-profile image-settings enumeration (should fix).- The new Gemma 4 fixtures are undocumented in the fixture-provenance section that documents the Qwen equivalents (should fix).
- The description's reproduction command uses a placeholder path and omits required inputs (should fix,
AGENTS.md:110-112). - Five nits on code prose, error text, and description wording.
Nothing here claims a result the code does not support; the code-prose findings are about messages and comments that under-explain or mis-describe their checks.
1. Documentation (should fix)
1.1 helios/README.md:721-728 contradicts the Gemma 4 paragraph above it
:713-719 correctly documents the new profile:
The Gemma 4 processor uses area-bounded RGB8 bicubic-antialias resize to multiples of
patch_size * pooling_kernel_size(48 px for 16×16 patches and 3×3 pooling), packs interleaved(y, x, channel)float32 patch vectors of width3 * patch_size²(768) scaled by1/255, emits[x, y]patch coordinates, and reuses the bracketed start/feature/end token envelope; when the prepared contract declaresimage_tokens.span, the bracketed layout emits atomic spans covering each envelope.
The next paragraph then states, with no qualification:
processproduces packedpixel_values[N,1536]float32 ... Patch features are ordered by channel, temporal copy, pixel row, and pixel column; patches are ordered by 2×2 spatial merge blocks. (:721-725)
Three of those clauses are false for the profile documented three lines earlier: 768 not 1536 floats per patch, no temporal copy, and 3×3 not 2×2 merge. A reader of the "Native image preparation" section (which now opens at :703-709 with "Profiles cover Qwen, MiMo, patch-merge, DeepSeek, DeepSeek row-major, Moonvit, Step, RADIO, GLM, padded-grid, and Gemma 4 inputs") will take :721-728 as the shared process contract. AGENTS.md:52-56 requires documents to state support as present qualification; SKILL.md:26-29 requires documentation to be a present-state specification rather than layered history.
Fix: scope the paragraph — "For the Qwen and MiMo profiles, process produces ..." — and state the per-profile width through ImageProcessor::patch_features() rather than only the Qwen number.
1.2 docs/runtime-core-design.md:233-240 omits the new preparation kind
FrontendSettingscontains EOS token IDs, the special-token strings used by the chat template, and optional image settings. Qwen image settings contain resize area limits, learned-position geometry, and image/video token IDs. MiMo image settings contain resize limits and channel normalization. DeepSeek's image profile has fixed geometry validated by Ignition.
This is the one place that tells a reader what each preparation kind consumes from ImageSettings. The PR adds a new oneof variant (ImageSettings.profile = 11, helios/proto/runtime_core.proto) and a new ImagePreparationKind tag, and the enumeration does not mention Gemma 4's patch_size, pooling_kernel_size, max_soft_tokens, or image/start/end envelope tokens, nor that Bracketed now derives its patch width from VisionCapacity.patch_features. The patch_features field itself is documented at :181-197, so the omission is local to this enumeration. Not documenting a served profile reads as "unsupported", which the docs/TODO.txt:331-338 entry contradicts.
Fix: add one clause to the enumeration naming the Gemma 4 settings and the pooling-derives-merge-stride relationship. (Padded-grid and PatchMerge are similarly absent, but that gap predates this PR; the new kind belongs here.)
1.3 The new fixtures have no provenance record (helios/README.md:772-789)
The fixture section explains exactly how image fixtures are produced and trusted:
Image fixtures in
tests/frontend/qwen38_images.json(not opened) pin Transformers4cc2aa84301c9aa210b5513dab9fefae03981f6e, PyTorch2.13.0+cu130, Torchvision0.28.0+cu130, Pillow12.3.0, and all checkpoint asset hashes. ... SHA256 checks compare every resized RGB byte and every little-endian float/integer tensor byte, with no numerical tolerance. ....venv/bin/python tests/frontend/generate_image_fixtures.py (not opened) "$SNAPSHOT" tests/frontend/qwen38_images.json (not opened) ...
It names only the Qwen fixtures and generator. This PR's headline parity claim rests on tests/frontend/gemma4_images.json (8 cases, max_soft_tokens 280 and 1120) generated by tests/frontend/generate_gemma4_image_fixtures.py and consumed unconditionally by canonical_processor_pixels_positions_and_resize at helios/src/frontend/images/gemma4.rs:266-333. gemma4_images.json and generate_gemma4_image_fixtures.py appear in no document — the only reference anywhere in the tree is the include_str! at gemma4.rs:270. The generator depends on a snapshot's processor_config.json (not opened) and config.json (not opened) (generate_gemma4_image_fixtures.py:27-29) and on a Transformers version that ships Gemma4ImageProcessor (:14), none of which is pinned anywhere a reader can find.
AGENTS.md:54-57 and SKILL.md:30-34 require qualification to state the conditions it holds under; an unpinned fixture generator means the qualification cannot be reproduced or re-verified after a Transformers upgrade.
Fix: extend helios/README.md:772-789 with the Gemma 4 fixture set, its pinned Transformers/Torch/Torchvision versions, the snapshot used to generate the hashes, and the regeneration command.
2. Description evidence (should fix)
2.1 The --ignored reproduction command cannot be run as written
FLARE_GEMMA4_TEST_SNAPSHOT=<gemma-4-31B-it@842da379> cargo test --locked --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server,test-tools --lib -- --ignored --exact frontend::images::gemma4::tests::checkpoint_tokens_expand_the_image_envelope frontend::images::gemma4::tests::native_pixels_and_positions_match_the_checkpoint_processor: 2 passed, 0 failed.
<gemma-4-31B-it@842da379> is a placeholder where the code requires a filesystem path (gemma4.rs:377-380, PathBuf::from(std::env::var_os(...))). The environment var must point at a directory containing tokenizer.json (not opened) (gemma4.rs:381-385, hard assert), and the envelope test also exports a Jinja chat template and reads further assets from that same directory (gemma4.rs:386-412). The second test requires <repo>/.venv/bin/python with transformers and torch importable (gemma4.rs:452-457, :458-472). None of this is stated.
AGENTS.md:110-112: "Reproduction commands must identify the required inputs and configuration directly or through a precise reference; placeholder arguments alone do not explain a measurement."
Fix: give the snapshot path (or a precise reference to how to obtain it), and state the required tokenizer.json (not opened)/tokenizer_config.json (not opened) contents and the .venv requirement.
3. Nits (5)
helios/src/frontend/images/gemma4.rs:30-38— seven distinct conditions collapse into"invalid Gemma 4 image settings": zero/oversizedpatch_size, zero/oversizedpooling_kernel_size, an unsupportedmax_soft_tokens,pooling² != limits.patches_per_feature, and patch-budget overflow. A load failure gives the operator no field name, unlike the neighbouringEnvelope::load(:40-44) whose errors name the offending token. The bounds at:32-33(patch_size > 64,pooling_kernel_size > 16) are still unexplained while:11-13now explains only the soft-token list.SKILL.md:38-39("Comments explain invariants, intent, and non-obvious constraints"). Suggest splitting the message by condition and adding one comment naming the source of the bounds.helios/src/frontend/images/layouts/bracketed.rs:57-65— the error"bracketed image span is missing envelope markers"fires onstart == 0 || end >= expanded.token_ids.len(), a bounds test; the closure never inspects marker identity. Marker equality is enforced later athelios/src/model.rs:441-446(tokens[s.start] != span.start_token || tokens[s.end - 1] != span.end_token). The message claims a check the code does not make. Suggest"bracketed image span run is outside the expanded prompt".ignition/preparation/frontend.py:132—max_soft_tokens not in (70, 140, 280, 560, 1120)silently mirrorshelios/src/frontend/images/gemma4.rs:11-13SUPPORTED_SOFT_TOKENS. The Rust side now names Hugging Face as the source; the Python copy names nothing and can drift. One comment naming the source and the mirror fixes it.- Description wording — "Regenerated
ignition/preparation/runtime_core_pb2.pywithlibprotoc 36.1matchingorigin/main" does not match the artifact's own header,# Protobuf Python Version: 7.36.1(runtime_core_pb2.py:5,ValidateProtobufRuntimeVersion(..., 7, 36, 1, ...)at:12-19). That header is byte-identical onmain(read atref=main), so no regression exists — the description just names a compiler version the file does not record. Say whichprotoc/grpcio-toolsrelease produced the descriptor, or drop the version. - Commit message — the single commit
2b4a31e"Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans" names the three behaviours and matches the diff but carries no compatibility impact or validation (SKILL.md:40-43). Acceptable because the PR description holds that detail; noting it as the last item only.
4. Verified as fixed since the previous round (previously blocking)
- HF comparison tests no longer silently pass.
checkpoint_tokens_expand_the_image_envelope(gemma4.rs:374-375) andnative_pixels_and_positions_match_the_checkpoint_processor(gemma4.rs:449-450) are#[ignore = "requires ..."]with hard asserts on the snapshot,tokenizer.json(not opened), and the Python interpreter. The headline parity claim is backed unconditionally bycanonical_processor_pixels_positions_and_resize(gemma4.rs:266-333) overtests/frontend/gemma4_images.json. - Atomic spans moved to the owning layout. Emission is in
layouts/bracketed.rs:52-88,106, gated onatomic_spansthreaded fromhelios/src/model/prompt.rs:52-65; the shared fallback inmodel/prompt.rsis gone, andbracketed_layout_emits_atomic_spans_only_when_contract_declares_them(prompt.rs:1172-1282) covers span-bearing, 64-aligned-too-small-chunk, and no-span (MiniMax) cases. The description's "Layout-owned atomic spans" bullet matches the code. - Load-path narrowings are disclosed and match the code: positive-square
patches_per_feature(packing.rs:26-32),patch_features == 0only as the legacy1176default (packing.rs:16-24), and the re-export error for pre-change Gemma 4 cores (helios/src/server/config.rs:443-470). - Docs the previous round asked for exist:
helios/README.md:709and:713-719(Gemma 4 in the profile list and its processor paragraph),docs/runtime-core-design.md:181-197(patch_features,0 → 1176),helios/model-contract.md:82(vision row),docs/TODO.txt:331-338(recipe dependency, E2B/E4B/26B-A4B/31B qualification, partial-span cache audit,gemma4_unifiedexclusion). - Code prose generally good:
gemma4.rs:6module doc names the three behaviours;gemma4.rs:11-13names Hugging Face as the source of the soft-token set;gemma4.rs:134("Gemma 4 patch vectors interleave RGB per pixel: (y, x, channel)") states a real invariant;patch_merge.rs:11-12names the sharing profiles;packing.rs:20,29,498name the failing field;ignition/preparation/frontend.py:115-117now explains what the gemma4 branch validates and where the encoder dimensions belong.
Open questions / what I could not verify from the code
- Whether the two
#[ignore]d tests were actually run for the reported "2 passed": they now fail rather than skip, so a wrong path would surface — but the description's placeholder path means a reader cannot reproduce the reported run (finding 2.1). - Which release of
protoc/grpcio-toolsregeneratedruntime_core_pb2.py; the file records only a runtime-version header, identical tomain. - Whether a previously exported non-Gemma core still loads and serves: the description asserts it ("MiniMax ... and all non-
Bracketedupstream cores remain loadable and unchanged") and no evidence bullet exercises a load.AGENTS.md:129-132asks for the actual checks; a core-loading test would settle it. I state this as an open question because the claim is plausible frompacking.rs:16-24but unverified by any cited run. - Whether the fixture hashes in
gemma4_images.jsonwere produced from the checkpoint named in the description; nothing in the tree records the generator's inputs (finding 1.3).
Out of lens and left to other reviewers: patch-merge arithmetic and the 3×3 pool, span semantics in the scheduler and prefix cache, protobuf oneof wire compatibility, and the prefill_chunk_size / span.max_tokens enforcement behaviour (now covered by server/config.rs:935-1024).