#1 [high] PR 483 review setup: scope, rules, files
PR #483 NVIDIA/hyperflare-inference, branch rickybrent:core/gemma4-image-frontend f2340e42 -> main 6d6fe0c6. 13 files +732/-164. Title: "Add Gemma 4 image prep profile, bracketed 3x3 packing & atomic spans". My lens: C = conventions and duplication. Compare each new construct with closest precedent; flag departures; flag duplicated helpers/mechanisms.
Rules to cite (AGENTS.md):
- L12/176-181 charter + AGENTS "Keep the runtime small and model-agnostic"/"Reject architectural violations": model-specific native policy is a violation; enums cannot serve as model allowlists (docs/design-review.md principle 3, lines 48-52).
- docs/design-review.md principle 3 lines 38-52: "Native ... input packing, frontend processing ... stay shared; use prepared metadata and frontend assets to express model-dependent behavior"; "Reject per-model boolean policy flags... Enums, callbacks, schema names, and metadata fields cannot serve as alternative model allowlists."
- AGENTS.md "Reject unsupported abstractions and churn" (lines ~188-193): unsolicited formatting/renaming/annotation sweeps not contributions; refactoring must support requested behavior.
- AGENTS.md "Be explicit and pin everything" (charter): no magic defaults, pin dependencies to exact versions.
- AGENTS.md Required prose review + repo-prose skill; PR descriptions four-part scheme.
- AGENTS.md config: no env-var behavior switches; tests may read vars to locate checkpoints but "A test variable must not change what the code under test does" (lines 466-468) — relevant to FLARE_GEMMA4_TEST_SNAPSHOT test.
#2 [high] packing.rs: bracketed_patch_geometry table + tensor_layout param
helios/src/frontend/images/packing.rs (PR head):
- New fn
bracketed_patch_geometry(patches_per_feature) -> Result<(i64, usize)>with a hard-coded table 4 => (2, 1176), 9 => (3, 768), else Err. Lines 16-22. tensor_layout(kind, patches_per_feature, name, patches)— new positional param (line 24-42); Bracketed pixel width now derived (lines 39-42).bracketed()(lines 479-509) now derives merge_side/patch_width fromconfig.contract.vision.patches_per_feature, replaces literal 2/h%2 checks andpatches*1176, droppedconfig.contract.vision.patches_per_feature != 4check.- Note: patches_per_feature alone does not disambiguate geometry: DeepSeek uses patches_per_feature 9 with 588 floats/patch (deepseek() line 315-317, 329 uses 588 and div_ceil(3) merge). So the 9 => 768 entry assumes Gemma4 style.
- New tests at 570-586.
- Established precedent:
tensor_layoutdispatches onImageLayoutKind(prepared enum);qwen()derives pixel_width fromconfig.contract.frontend.image_layoutif/else chain (lines 123-134).conditioned.rs::valid_processed(line 187-194) has a third per-profile pixel-width table.
#3 [high] Should fix: packing.rs bracketed_patch_geometry table keyed on patches_per_feature
packing.rs:16-22 bracketed_patch_geometry(patches_per_feature) -> (merge_side, patch_width) table 4=>(2,1176), 9=>(3,768), else Err.
Problem: patches_per_feature alone does not identify the patch float width. DeepSeek already uses patches_per_feature 9 (packing.rs deepseek() 315-317 checks geometry.tokens != patches/9, tensor_layout Deepseek branch gives 588 floats/patch). So 9=>768 encodes "Gemma-4-style interleaved patch", i.e. model identity, in shared upload packing. Same file already derives widths from the prepared layout enum: qwen() 123-134 (Moonvit/Step 588, Radio 768, Glm 1176) and tensor_layout keyed on ImageLayoutKind; class_token() 537 uses super::padded_grid::FEATURES.
Rules: docs/design-review.md principle 3 lines 38-52 ("input packing ... stay shared; use prepared metadata ... to express model-dependent behavior"; enums/metadata must not become model allowlists); AGENTS.md:176-181; charter "Keep the runtime small and model-agnostic".
Fix: take the patch feature width from prepared metadata (a declared per-layout patch width in the vision contract / ImageLayout, as class_token does with padded_grid::FEATURES) instead of a numeric table keyed on patches_per_feature.
#4 [high] Should fix: duplicate per-profile pixel-width tables (packing, conditioned, gemma4)
Three independent places now encode the same per-profile pixel width:
- helios/src/frontend/images/packing.rs:39-42 + 16-22 (Bracketed -> 1176 / 768 via bracketed_patch_geometry).
- helios/src/frontend/images/conditioned.rs:187-194
valid_processed(new armProfile::Gemma4(_) => 768, line 192) — a third match arm table next to Radio 768, Glm 1176, PaddedGrid FEATURES (191),_ => 588. - helios/src/frontend/images/gemma4.rs:116
3 * self.patch_size * self.patch_size. Precedent for a single source: class_token()/padded_grid usepadded_grid::FEATURES(packing.rs:537); tensor_layout() is the declared layout authority (packing.rs:24-89). Risk: conditioned.rs caches validation (valid_processed) silently disagrees with the profile if either table changes, and the cache path returns "image preprocessing differs from its prompt geometry". Fix: derive the width from one shared helper (e.g. the same layout/metadata source used by tensor_layout).
#5 [high] Should fix: prompt.rs fills data.spans generically instead of in the layout
helios/src/model/prompt.rs:137-151 (new): fills prepared.data.spans from prepared.conditioned_inputs when config.contract.frontend.image_tokens.span is Some and no layout produced spans.
Departures from precedent:
(a) Every image layout module returns conditioned_inputs: vec![] (grep: bracketed.rs:44/90, class_token.rs:66, deepseek.rs:165, glm.rs:85, mimo.rs:76, moonvit.rs:89, qwen.rs:110, radio.rs:82, step.rs:108) — the vector is always filled here, so conditioned_inputs is no longer layout-owned. The precedent for spans is the layout: layouts/deepseek.rs:149 data.spans.push(start + padding..start + block.len()) alongside its own token expansion, then validate_prompt_data (model.rs:436-454) checks the span boundaries against the declared ImageSpan.
(b) The new code trusts the ImageSpan metadata only for presence, and copies input.token_span, which for enveloped layouts is start..start + additional + 1 (prompt.rs:129-131) where additional is token_expansions from layouts/bracketed.rs:77-81 = geometry.tokens + 1. So the assembled span length is tokens+2. max_tokens is enforced in model.rs:438. Nothing in this PR's code or tests checks a Gemma4 ImageSpan (no contract fixture with span set for Gemma4; helios/tests/support/contracts/gemma4_frontend.json has "image_tokens": null), so the one path the feature is claimed for ("atomic spans for multimodal prefill scheduling") is untested end to end.
Fix: build spans in the layout that builds the expansion (bracketed.rs, as deepseek.rs does), so the span is derived from the same indices as the expansion rather than re-derived by span arithmetic in prompt.rs.
#10 [high] Research summary
Reviewed PR #483 (Gemma 4 image prep profile, bracketed 3x3 packing, atomic spans) through the conventions-and-duplication lens, checking each new construct against its closest precedent in helios/src (packing.rs, conditioned.rs, layouts/deepseek.rs, layouts/bracketed.rs), helios/src/runtime_core (protobuf.rs, describe.rs), ignition/preparation/frontend.py, and the repository rules (AGENTS.md, docs/design-review.md, docs/runtime-core-design.md).
Four should-fix findings and three nits, recorded in the scratchpad:
packing.rs:16-22adds apatches_per_feature -> (merge_side, patch_width)table (4→1176, 9→768) in shared upload packing.patches_per_featurealone does not identify patch width — DeepSeek already uses 9 with 588 floats — so the table encodes model identity where the file's own precedent (qwen()'s layout-derived widths,class_token()'spadded_grid::FEATURES) derives widths from prepared metadata. This contradicts design-review principle 3 (input packing stays shared; metadata must not become a model allowlist).- The same pixel width is now authored in three places (packing.rs table,
conditioned.rs:192,gemma4.rs:116), with the cache-validatingvalid_processedsilently disagreeing if either changes. model/prompt.rs:137-151fillsdata.spansgenerically fromconditioned_inputs, while every layout returnsconditioned_inputs: vec![]and the established span authority is the layout itself (layouts/deepseek.rs:149withvalidate_prompt_data). No test exercises a Gemma 4 ImageSpan, so the claimed scheduling path is unverified.gemma4.rs's envelope test shells out to.venv/bin/pythonto re-patch the chat template, duplicatingprepare_templates.py::_annotate/annotated_template_assetand bypassing the existingtemplate_fixtures::template("gemma4", ...)accessor.
Nits: runtime_core_pb2.py was regenerated with protobuf 7.36.1 while pyproject.toml (not opened) pins >=7.36.2; no protobuf round-trip test for ImageSettings.gemma4 although GLM and padded-grid each have one; the soft-token allowlist is duplicated between Rust and Python.
The Envelope extraction from patch_merge::Processor is a genuine de-duplication and the proto/serde/describe/Python validation additions follow their per-profile precedents exactly.
#11 [high] Coverage: what was read for each changed file
Coverage of PR #483 (13 files) through lens C (conventions and duplication), all read at ref pr/483 in context:
- helios/proto/runtime_core.proto (+10): enum value 11 +
Gemma4ImageSettings gemma4 = 11and the message mirror PatchMergeImageSettings tags 1-8 -> 1-6. Consistent with the patch_merge precedent next to it. No finding. - helios/src/frontend/images/gemma4.rs (new, 416): read fully (1-200, plus diff for 200-416).
Processormirrors patch_merge::Processor / QwenProcessor lifetime style;processmirrors patches.rs::process/PatchProcessor::process structure (geometry, checked total, reserve_outputs, cu_seqlens). Findings: duplicated pixel width (gemma4.rs:116), duplicated soft-token allowlist (gemma4.rs:11), test reinvents template patch machinery (gemma4.rs:243-320). - helios/src/frontend/images/mod.rs (+20): ImageSettings::Gemma4 + Gemma4ImageSettings mirror PatchMerge variants; Profile::Gemma4 arms mirror PaddedGrid arms in load/geometry/resized_rgb/process/expand_prompt/preparation_kind. Consistent. No finding.
- helios/src/frontend/images/conditioned.rs (+9):
Profile::Gemma4(_) => 768at line 192 invalid_processed's per-profile pixel-width match (187-194). Finding: third copy of the width table (entry 4). - helios/src/frontend/images/packing.rs (+45/-5):
bracketed_patch_geometry16-22,tensor_layoutnew param 24-42,bracketed()479-509, tests 570-586. Finding: entry 3. - helios/src/frontend/images/patch_merge.rs (+61/-38): Envelope extraction 10-81, Processor 83-131. Genuine de-duplication; single nit on its home/doc (entry 9 item 3).
- helios/src/model/contract.rs (+1/-1): contract_enum ImagePreparationKind adds Gemma4 = 11, appended, no renumbering -> preserves wire ids (design-review principle 13). No finding.
- helios/src/model/packing.rs (+1): call site passes
config.contract.vision.patches_per_featureinto tensor_layout (model/packing.rs:92-97). Consequence of finding 1; the call site itself matches the neighbouring ImageTensor validation style. - helios/src/model/prompt.rs (+15): 137-151 span filling. Finding entry 5.
- helios/src/runtime_core/describe.rs (+2): vision_json Gemma4 arm 442-443 mirrors PatchMerge arm 440-441. No finding.
- helios/src/runtime_core/protobuf.rs (+5): frontend_settings Gemma4 arm 167-171 mirrors PatchMerge 162-166. Nit: no round-trip test (entry 9 item 1) unlike GLM (726) / padded-grid (749).
- ignition/preparation/frontend.py (+25): gemma4 branch 113-137 mirrors glm branch 138-153 (uses
_expectedincl. optionals). Nit: duplicated soft-token allowlist (line 123 vs gemma4.rs:11). - ignition/preparation/runtime_core_pb2.py (+122/-120): descriptor regenerated; generator version 7.36.2 -> 7.36.1. Nit (entry 6).
Also checked for precedent/duplication: helios/src/frontend/images/resize.rs (gemma4 correctly reuses resize::resize = uint8 antialiased bicubic, as patch_merge/qwen do, rather than adding a kernel); helios/src/model.rs::validate_prompt_data (408-457) for span enforcement; helios/src/scheduler.rs::set_prefill_spans consumers (server/runtime.rs:1460); layouts/* returning conditioned_inputs: vec![]; helios/tests/support/contracts/* fixtures (gemma4_frontend.json has image_tokens null); tests/frontend/prepare_templates.py and helios/tests/support/templates.rs; docs/runtime-core-design.md:247-248 (Python bindings generated by protoc).
#14 [high] Report of 2026-11-25 (revised head 2b4a31e): conventions and duplication
Re-read the revised head (2b4a31e, 36 files) for PR #483 through the conventions/duplication lens.
CLOSED since the previous report (verified in code):
- Patch-width table keyed on
patches_per_featureis gone.packing.rs:16-32now hasbracketed_patch_features(&VisionCapabilities)(metadata,0-> legacy 1176) plussquare_merge_side(ppf)(isqrt, rejects non-squares);tensor_layouttakes&VisionCapabilities(packing.rs:34-56) andbracketed()derives merge side and width from it (packing.rs:493-511). This is the metadata route docs/design-review.md:38-52 asks for. conditioned.rs:187now callsself.processor.patch_features()instead of a second per-profile width table; the third copy is gone.- Atomic spans moved into the layout:
layouts/bracketed.rs:52-88,104-107buildsspansfrommm_token_type_idsruns and pushes them intoPromptData;model/prompt.rs:52-65only passes anatomic_spansbool derived fromimage_tokens.span. Mirrorslayouts/deepseek.rs:149. - Gemma 4 span coverage now exists:
model/prompt.rs:1171-1256bracketed_layout_emits_atomic_spans_only_when_contract_declares_them(2 spans of len 262, start/end marker assertions, 64-aligned chunk rejection at 256, and no-span case). Server-side bounds are covered byserver/config.rs:935-1021. gemma4.rsenvelope test no longer shells out to.venv/bin/python; it writes the{% mark %}{{ messages[0].content }}template inline (gemma4.rs:394-402), which is the established pattern (model/prompt.rs:428,patch_merge.rs:266,server/config.rs:613,helios/tests/reasoning_delimiters.rs:34). The live-parity test is#[ignore]with hard assertions (gemma4.rs:522-531). Fixture/generator now mirrorgenerate_glm_image_fixtures.py(tests/frontend/generate_gemma4_image_fixtures.py).- Protobuf round-trip test for the new tag exists:
runtime_core/protobuf.rs:812-860serialized_gemma4_profile_selects_only_image_preparation.
REMAINING (verified):
- Nit/should-fix — per-profile patch width is still authored twice, in two match statements keyed on different enums:
packing.rs:41-100tensor_layout(byImageLayoutKind) andmod.rs:459-473ImageProcessor::patch_features(byProfile). Nothing links them at compile time; onlypacking.rs'sprocessor_patch_features_match_tensor_layout_for_every_profiletest (11 profiles) does. Fix: havetensor_layoutask the processor/profile for its width (or havepatch_featuresdelegate to the layout table) so a new profile cannot drift. - Nit —
gemma4.rs:54-56definespatch_features()butprocessre-inlines3 * self.patch_size * self.patch_sizeatgemma4.rs:132. Useself.patch_features()(asresized_rgb/processdo for geometry);patches.rs:89has the same pre-existing pattern. - Nit — soft-token allowlist duplicated:
gemma4.rs:13SUPPORTED_SOFT_TOKENS = [70,140,280,560,1120]vsignition/preparation/frontend.py:132. No neighbouring profile enumerates an allowlist (deepseek_row_major.rs:14validates a range), so there is no precedent to follow; the two sites must be kept in step by hand. - Nit —
patch_merge::Envelope(patch_merge.rs:10-17) is now shared by PatchMerge and Gemma4 and its doc says so, but it still lives inpatch_merge;gemma4.rs:8imports it from there. A future enveloped layout will import from a profile module. - Nit —
server/config.rs:456-457reaches intofrontend::images::packing::bracketed_patch_featuresto restate the legacy-default rule; aVisionCapabilities/processor accessor would keep server config out of image-packing internals. - Nit —
tests/frontend/generate_gemma4_image_fixtures.py:17-25copiespattern()anddigest()verbatim fromgenerate_glm_image_fixtures.py:18-25; it matches how the other generators are written (each standalone), so acceptable, but a shared helper would be the DRY form. - Nit —
bracketed.rs:57-65restates marker-presence validation (start == 0 || end >= len) thatvalidate_prompt_data(model.rs:441-456) already performs againstspan.start_token/span.end_token; the layout checks only that a marker slot exists, not that it is the declared marker, so the check is partial and duplicated. Not wrong, just split across two layers.
Precedents that hold (unchanged): proto tag 11 / Gemma4ImageSettings mirror PatchMergeImageSettings (runtime_core.proto:278-281,446-451,582-603); contract_enum! appends Gemma4 = 11 (model/contract.rs:68); describe.rs:451-452 and protobuf.rs:168-172 mirror the PatchMerge arms; frontend.py:114-173 mirrors the glm branch and _native_image_placeholder's atomic-token check (frontend.py:270-275); ImageSettings::Gemma4/Gemma4ImageSettings mirror the PaddedGrid/PatchMerge serde shapes (mod.rs:257-341); Envelope extraction is genuine de-duplication.
#15 [high] Research summary
Verdict: no blocking or should-fix findings remain in this lens; nits only.
I re-read the revised head (2b4a31e, 36 files) for conventions and duplication against each construct's closest precedent in the repo, judged against docs/design-review.md principles 1, 3 and 13 and AGENTS.md (not opened).
All four should-fix findings from my previous pass are closed in the code, not just in the reply. packing.rs:16-32 replaces the patches_per_feature → width table with bracketed_patch_features(&VisionCapabilities) plus square_merge_side (isqrt, non-squares rejected), and tensor_layout/bracketed() now read width from prepared metadata — exactly the route design-review.md:38-52 asks for. conditioned.rs:187 calls ImageProcessor::patch_features() instead of keeping a second width table. Atomic spans are now built by the layout that builds the envelope (layouts/bracketed.rs:52-88,104-107, mirroring layouts/deepseek.rs:149) instead of in the model/prompt.rs dispatcher, and there is a real span test (model/prompt.rs:1171-1256) plus server-side envelope/chunk bounds tests (server/config.rs:935-1021). The Gemma 4 envelope test no longer shells out to .venv/bin/python; it writes the {% mark %} template inline like its neighbours, and the live-parity test is #[ignore]d with hard assertions. The protobuf round-trip test for the new tag exists (runtime_core/protobuf.rs:812-860).
Residual nits (recorded, not blocking). The per-profile patch width is still authored in two independent match statements keyed on different enums — packing.rs:41-100 (ImageLayoutKind) and mod.rs:459-473 (Profile) — linked only by a test, not by the compiler; gemma4.rs:132 re-inlines 3 * patch_size² next to the patch_features() accessor that already computes it; the soft-token allowlist is duplicated between gemma4.rs:13 and ignition/preparation/frontend.py:132; patch_merge::Envelope is shared but still homed in patch_merge; server/config.rs:456 reaches into image-packing internals for the legacy-default rule; the new fixture generator copies pattern/digest from the GLM generator (consistent with how every generator is written); and bracketed.rs:57-65's marker-presence check partially duplicates the span-boundary validation in model.rs:441-456.
The proto tags, serde shapes, enum values, describe.rs/protobuf.rs arms and the Ignition branch all follow their per-profile precedents, and the Envelope extraction remains genuine de-duplication. Findings and citations are in scratchpad entry #14.
#16 [high] Verdict and coverage for the 2026-11-25 pass (head 2b4a31e)
PR #483 re-review, second pass. Head 2b4a31e, base main 27716185, 36 files +2269/-240. Branch was rebased and substantially rewritten after my previous report (#13), so findings from that report were re-verified from scratch rather than carried forward.
VERDICT: no blocking findings; no should-fix findings left in the conventions/duplication lens; seven nits (entry #14 items 1-7). The one residual structural risk worth a reviewer's eye is nit 1: per-profile patch width now lives in two independent matches (packing.rs:41-100 by ImageLayoutKind, mod.rs:459-473 by Profile), tied only by the processor_patch_features_match_tensor_layout_for_every_profile test (packing.rs:770-826). I graded it a nit because the duplication is bounded to two tables over the same 11 profiles and is test-covered; a compiler link (one delegating to the other) would close it.
WHAT WAS READ IN FULL OR IN SUBSTANTIAL CONTEXT THIS PASS: packing.rs (1-120 plus the new tests), conditioned.rs (150-240, 320-400), layouts/bracketed.rs (1-120), layouts/deepseek.rs (1-180), gemma4.rs (1-200, 330-420, plus diff), patch_merge.rs (1-220), model/prompt.rs (30-190, plus diff to 1284), model.rs (20-110, 400-480), server/config.rs (476-540, plus diff), mod.rs (960-1120, plus diff), runtime_core/protobuf.rs and describe.rs diffs, proto/runtime_core.proto, helios/build.rs, ignition/preparation/frontend.py (60-180, 240-300, plus diff), tests/frontend/generate_gemma4_image_fixtures.py, tests/frontend/generate_glm_image_fixtures.py, tests/preparation/test_frontend_gemma4.py, helios/tests/support/contracts/gemma4_frontend.json, docs/design-review.md, and the diffs for helios/README.md, docs/runtime-core-design.md, docs/TODO.txt, helios/model-contract.md, model/contract.rs, and the scheduler/server test-site patch_features: 0 updates.
NOT OPENED (judged non-substantive for this lens): the one-line additions in flare-cli/tests/unverified_payload.rs, helios/tests/deepseek_requests.rs, server/models.rs, server/protocol/decode.rs, server/request.rs, server/request/tml_tests.rs, server/runtime.rs, server/runtime/phase_tests.rs, scheduler/{boundary_tests,cache_memory,vision_window_tests}.rs (all patch_features: 0 struct-literal fills, seen via diff), tests/frontend/gemma4_images.json (consumed only through the Rust fixture reader at gemma4.rs:277-333), and the regenerated runtime_core_pb2.py descriptor blob beyond its header/version lines.
LIMITS: no build or test was run in this environment; every claim about behaviour is from reading the code and its callers. The author's claimed test counts are their own evidence. Nothing here assesses numerical parity with the HF processor, load-path performance, or serving behaviour — other lenses cover those.
#6 [medium] Should fix: runtime_core_pb2.py generator version downgraded to 7.36.1
ingestion/preparation/runtime_core_pb2.py header in the PR diff:
# Protobuf Python Version: 7.36.2->7.36.1and the_runtime_version.ValidateProtobufRuntimeVersion(..., 7, 36, 2 -> 1, ...)call changes 2 -> 1.- pyproject.toml:34 pins
protobuf>=7.36.2,<8. ValidateProtobufRuntimeVersion rejects a runtime older than the gencode; 7.36.1 gencode is the older/newer? It is the regenerated with a lower protoc version, so the checked-in binding declares 7.36.1 while the repo requires runtime >= 7.36.2. That is a needless downgrade of the generator recorded in the file: docs/runtime-core-design.md:247-248 says Python bindings are generated byprotocfrom the same schema. The generated file must be produced with the pinned generator so the header matches the pin (charter "Be explicit and pin everything"; AGENTS.md "pin dependencies to exact versions or commits"). Also, this chunk re-wraps the whole descriptor blob (+122/-120) — unavoidable for a regenerated file, but the version flip is an unrelated regression that would return with the next regeneration. Fix: regenerate with protobuf 7.36.2 so the header and ValidateProtobufRuntimeVersion keep 7.36.2; or state why the repin is intentional.
#7 [medium] Should fix: gemma4.rs test reinvents template fixture preparation
helios/src/frontend/images/gemma4.rs:243-320 checkpoint_tokens_expand_the_image_envelope builds its chat template by shelling out to ../.venv/bin/python with -c importing ignition.preparation.frontend.downloaded_template_asset and writing to std::env::temp_dir().
Precedents in the repository:
- helios/tests/fixtures/templates/gemma4/chat_template.google.patch.json already exists (used via helios/tests/support/templates.rs
template("gemma4", "chat_template.google"), wired throughcrate::template_fixtures— helios/src/lib.rs:7-9, frontend/jinja/tests.rs:274, tests/ordinary_tokens.rs:451).template_fixtures::templateis the established accessor; the new test bypasses it and re-patches the template itself, duplicatingtests/frontend/prepare_templates.py:15-32 _annotatein a third place (the Rustannotated_template_assetin frontend.py:24-40 is the second). - AGENTS.md: tests may read variables that locate checkpoints; "A test variable must not change what the code under test does".
FLARE_GEMMA4_TEST_SNAPSHOTonly locates a snapshot, so that part follows precedent (matches bracketed.rs:106FLARE_MINIMAX_M3_SNAPSHOT). - The new test also downloads from the Hugging Face hub as a side effect of a
cargo testrun (downloaded_template_asset calls hf_hub_download when the patch source is not in the cache) and writes a temp file it deletes only on the happy path (the earlyif !status.success() { return; }leaks it). Fix: reusecrate::template_fixtures::template("gemma4", "chat_template.google")(prepare via tests/frontend/prepare_templates.py) and drop the python subprocess and temp-file dance.
#8 [medium] Consistency checks that pass
Precedent checks that pass (no finding):
- gemma4::Processor holds
limitsas a field rather than takingImageLimitsper call, like patch_merge::Processor/QwenProcessor; ok. Envelopeextracted from patch_merge::Processor (patch_merge.rs:10-81) and reused by gemma4 — a real de-duplication, good. But it lives inpatch_mergewhile the doc comment now says "shared by enveloped image layouts"; a future non-patch-merge envelope user will import from patch_merge.rs. Nit.- ImageSettings::Gemma4 + Gemma4ImageSettings mirror PatchMergeImageSettings exactly (mod.rs:332-341),
#[serde(deny_unknown_fields)], snake_case rename — consistent. - protobuf.rs:167-171 encode mirrors PatchMerge at 162-166; describe.rs:442-443 mirrors PatchMerge at 440-441. Consistent.
- ignition/preparation/frontend.py:113-137 mirrors the glm/padded_grid branches (uses
_expectedwith optional fields, as glm.py:146-148 does). Consistent. One departure: every other profile validatesset(image) != set(expected)only for padded_grid; gemma4 uses_expectedonly. Consistent with glm. Fine. - gemma4.rs header
SPDX-FileCopyrightText: Copyright (c) 2026 Flare community contributorsonly, without the NVIDIA line that other files carry (compare mod.rs:2-3, patches.rs, conditioned.rs). New files in this repo carry both lines (deepseek_row_major.rs:2-3, padded_grid.rs, glm.rs has only the Flare line too — so mixed precedent). Nit at most; skip. Profile::Gemma4(_) => 768in conditioned.rs also needs the interpolation list untouched: Gemma4 pushes no interpolation indices, and valid_processed'sinterpolationmatch (196-199) excludes Gemma4 — correct.- prompt.rs new code runs after the loop and before validate_prompt_data/validate_conditioned_inputs; spans ordering/length constraints in model.rs:420-423 will reject out-of-order spans, so no silent acceptance.
#9 [medium] Nits: protobuf test, duplicated allowlist, Envelope location
- Nit — no protobuf round-trip test for the new profile. Precedent: helios/src/runtime_core/protobuf.rs:726
serialized_glm_profile_selects_only_image_preparationand :749serialized_padded_grid_profile_selects_only_image_preparationeach assert the exact wire bytes select only the image preparation and that the profile loads. Gemma4 adds tag 11 (Gemma4ImageSettings gemma4 = 11) with no equivalent test, so the "additive, wire-compatible" claim in the PR description is checked only by the Python round trip the author ran by hand. Fix: addserialized_gemma4_profile_selects_only_image_preparationwith the field-11 bytes (0x5a) and an ImageProcessor::load assertion. - Nit — the supported soft-token allowlist is duplicated: gemma4.rs:11
SUPPORTED_SOFT_TOKENS: [usize; 5] = [70,140,280,560,1120]and ignition/preparation/frontend.py:123if image.get("max_soft_tokens") not in (70, 140, 280, 560, 1120). Neighbouring profiles validate a range instead (deepseek_row_major.rs:14(4..=1024).contains(&max_tokens)), so there is no established enumerated allowlist to follow. Keep one authority (the exported settings already carry the value) or derive the set frompooling_kernel_size/max_soft_tokensextremes; at minimum the two lists must not diverge. - Nit —
patch_merge::Envelope(patch_merge.rs:10-81) is now shared by gemma4; its doc comment says "shared by enveloped image layouts", so the module/home should follow the name (or the doc should say it currently serves patch-merge and Gemma 4).
#12 [medium] Severity correction: pb2 generator version is a nit
Entry 6 recorded runtime_core_pb2.py's Protobuf Python Version 7.36.2 -> 7.36.1 as "should fix". On reflection it is a nit:
_runtime_version.ValidateProtobufRuntimeVersiononly rejects a runtime older than the gencode, so a 7.36.1 gencode still loads under the pinned runtimeprotobuf>=7.36.2,<8(pyproject.toml:34). Nothing breaks.- What it does do is record a generator version below the repository's pin, so the checked-in binding no longer states the pinned generator (docs/runtime-core-design.md:247-248: Python bindings are generated by
protocfrom the same schema; charter "Be explicit and pin everything"). Fix: regenerate with protobuf 7.36.2 so the header and the version tuple match the pin. Severity: nit.
Final severity list to report:
- Should fix: packing.rs:16-22 bracketed_patch_geometry table (model identity in shared packing).
- Should fix: pixel width duplicated across packing.rs:39-42/16-22, conditioned.rs:192, gemma4.rs:116.
- Should fix: prompt.rs:137-151 generic span filling instead of layout-owned spans, and no Gemma 4 ImageSpan test.
- Should fix: gemma4.rs:243-320 test duplicates template patching / bypasses template_fixtures, downloads from the hub in a unit test, leaks a temp file on the failure path.
- Nit: runtime_core_pb2.py generator version 7.36.1 vs pin 7.36.2.
- Nit: no protobuf round-trip test for ImageSettings.gemma4 (precedents protobuf.rs:726, :749).
- Nit: soft-token allowlist duplicated (gemma4.rs:11 vs frontend.py:123); no precedent for an enumerated allowlist (deepseek_row_major.rs:14 validates a range).
- Nit: patch_merge::Envelope is now shared but still homed/documented in patch_merge.rs:10-16.