Prose review — PR #483, "Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans"
Head ab9a432b (rickybrent:core/gemma4-image-frontend), base main 27716185, 38 files, +2490/−251.
Reviewed at https://github.com/NVIDIA/hyperflare-inference/pull/483
Key findings
Verdict: clean — no blocking, no should-fix, five nits.
The description satisfies the four mandatory questions in AGENTS.md:72-112 in the required order (why → what exactly changed → claimed result → evidence + limitations), keeps limitations visible, and its causal claims about the pre-existing defects check out against main. The docs it touches are present-state specification with pinned versions and reproduction commands, and they now document the new profile in the three places that enumerate profiles. Every should-fix item from the two previous rounds of this review is verified fixed at this head. What remains is five nits, none of which misleads a reviewer about behavior or evidence.
Rules applied: charter lines 12, 21, 35, 42; AGENTS.md:43-70, :72-140, :188-199, :431-444; .agents/skills/repo-prose/SKILL.md:13-46 (not opened).
Description accuracy — verified against code
"Why" (AGENTS.md:82-87) — accurate
- "a span-declaring
Bracketedimage fails per-request atvalidate_prompt_data": onmain,helios/src/model.rs:436-454errors with "image token spans do not match their declared boundaries" becausemain'slayouts/bracketed.rsnever pusheddata.spans. The PR fixes it in the layout:helios/src/frontend/images/layouts/bracketed.rs:57-65,86-88, and deletes the fallback inmodel/prompt.rs. Currentmodel.rs:451-469. - "per-request chunk-size rejections rather than failing at load":
mainhelios/src/model.rs:421-423(s.len() > prefill_chunk_size). Now load-time athelios/src/server/config.rs:473-486, alongsidespan.max_tokens. - "
Bracketedlayouts did not emit atomic image spans when declared byImageTokenLayout.span": matchesmain's bracketed layout, which is what the newimage_tokens.span.is_some()gate inlayouts/bracketed.rsadds.
"What changed" (AGENTS.md:88-94) — accurate, before/after explicit
- "
Bracketednow requires a positive-squarepatches_per_feature":helios/src/model/packing.rs:16-24(not opened) (square_merge_side). - "Gemma 4 core prepared before this change (with
patch_features == 0) is rejected at load with an actionable error (bracketed image layout patch width (1176) differs from image processor (768); re-export the core with vision.patch_features)":helios/src/server/config.rs:449-455. - Wire tags as described:
ImagePreparationKind::Gemma4andImageSettingstag 11,VisionCapacity.patch_featurestag 6 with#[serde(default)](helios/build.rs:53-56(not opened)); the zero-fallback semantics are documented athelios/src/model.rs:51,:72-73,:89(is_multiple_of(3)) andhelios/src/model-contract.md:82(not opened). - Numerical behavior is stated precisely where it matters:
geometry.tokens * 9 == patches(gemma4.rs:400),max_soft_tokensallowlist mirrored in both languages (gemma4.rs:11-13,ignition/preparation/frontend.py:131-133), 8 fixture cases at 280 and 1120.
Evidence (AGENTS.md:103-112) — limits disclosed
- The
--ignoredlive-checkpoint run is labeled "not part of CI" and now names the required inputs directly: a local snapshot directory containingtokenizer.json(not opened) andtokenizer_config.json(not opened) fromgoogle/gemma-4-31B-itat842da3794eaa0b77d5f08bae87a17459d91ff475, passed asFLARE_GEMMA4_TEST_SNAPSHOT=/path/to/gemma-4-31B-it-snapshot— a real path form, satisfyingAGENTS.md:110-112. Matches the test athelios/src/frontend/images/gemma4.rs:422-468. - Cached-checkpoint pytest cases are explicitly excluded from CI, and "no serving-path timing or memory was measured" is stated. Per
AGENTS.md:108-109and SKILL.md:35-37, the tested contract is described rather than only counts. - The prototype regeneration note now reads "(Protobuf Python Version: 7.36.1, pure descriptor-only diff)", matching
ignition/preparation/runtime_core_pb2.py:5. - The stacked-dependency obligation (
AGENTS.md:126-128) is met: the description nameslocal-inference-lab/hyperflare-recipes, says the companion recipe PR declaresvision.patch_features = 768, gives merge order, and records the dependency indocs/TODO.txt:331-337.
Process-assurance rule (AGENTS.md:129-132) — satisfied
No "reviewed", "ready to merge", or chronology; the branch-logistics section is last, allowed by AGENTS.md:120-121.
Should-fix items from the previous round — all verified resolved
helios/README.md:721-724now reads: "For Qwen,processproduces packedpixel_values[N,1536]float32, image grids[1,H,W], vision positions[N,2]int64, interpolation indices[N,4]int64 and weights[N,4]float32, and per-image cumulative patch offsets int32 (other profiles report their own per-patch width viaImageProcessor::patch_features())." The Gemma 4 paragraph at:713-719is no longer contradicted, and "For Qwen" is the accurate scope (interpolation tensors are Qwen/Moonvit/Step/Radio/PaddedGrid only —helios/src/frontend/images/conditioned.rs:189-192).docs/runtime-core-design.md:237-239now enumerates the new settings: "Gemma 4 image settings contain patch and pooling geometry, the soft-token budget, and the validated envelope token strings (image_token,start_token,end_token)."patch_featuresis documented at:184-190and the bootstrap checks at:191-194, matchingserver/config.rs:443-489.- Fixture provenance at
helios/README.md:798-807: pinned Transformers5.23.0, PyTorch2.14.1+cu132, Torchvision0.29.1+cu132,google/gemma-4-31B-itat842da379..., 8 bit-exact cases, plus the regeneration command.venv/bin/python tests/frontend/generate_gemma4_image_fixtures.py "$SNAPSHOT" tests/frontend/gemma4_images.json. Versions agree withpyproject.toml:22-24(not opened); the fixture is consumed bygemma4.rs:315-381andtests/preparation/test_frontend_gemma4.py:187-225. - Description evidence: the
--ignoredruns are labeled non-CI with explicit inputs (above); the second,.venv-dependent Python-IPC test was deleted so no unreproducible command remains.
Also gone: the gemma4.rs load-error nit (:26-71 now splits by condition and names the failing field and both compared values, with :26 explaining the 1..=64 / 1..=16 wire caps) and the bracketed.rs message nit (:59-60, "bracketed image feature run is outside the expanded prompt", matching the bounds test at the same site).
Remaining findings — five nits
N1 — description "Claimed result" says "normalizes"; the profile only rescales.
AGENTS.md:88-94 requires material numerical behavior to be identified precisely; SKILL.md:35-37 requires evidence stated as measured behavior. The description says "Helios natively decodes, resizes, normalizes, packs, and validates Gemma 4 images", but ignition/preparation/frontend.py:124-127 requires do_normalize: False, image_mean: [0.0]*3, image_std: [1.0]*3, and helios/src/frontend/images/gemma4.rs:192-196 applies only pixels[offset + channel] as f32 * (1.0 / 255.0). helios/README.md:716 states it correctly: "scaled by 1/255". Fix: "decodes, resizes, rescales by 1/255, packs, and validates". Low risk (a reader could assume mean/std normalization is applied), hence nit.
N2 — helios/README.md:804-807 reuses $SNAPSHOT for a different checkpoint with no local referent.
The Gemma 4 regeneration command uses "$SNAPSHOT", but the only prior definition of that name in the document is the Qwen3.8 command at :786-787 (--bin test_images -- "$SNAPSHOT" tests/frontend/qwen38_images.json), which points at a different checkpoint — a false definite reference (SKILL.md:17-19). Fix: use GEMMA4_SNAPSHOT, or name the directory in the sentence at :798-802.
N3 — ignition/preparation/frontend.py:131-133 mirrors the Rust soft-token allowlist without saying so.
The Python gate is if type(max_soft_tokens) is not int or max_soft_tokens not in (70, 140, 280, 560, 1120):, while the Rust copy at helios/src/frontend/images/gemma4.rs:11-13 carries a comment naming its source ("Discrete budgets from Hugging Face's image_processor.max_soft_tokens"). The pair can drift silently and the reader cannot tell they are intentionally the same set. Fix: one comment naming the source and the mirror.
N4 — two gemma4.rs tests restate the bit-exact fixture instead of exercising the contract (AGENTS.md:188-193 and :194-199).
helios/src/frontend/images/gemma4.rs:383-402 (geometry_matches_the_hugging_face_processor) lists nine shapes, of which seven — (1,1), (672,672), (1008,672)/(91,37), (1920,1080), (10,3000), (3000,10) — are fixture rows already pinned in tests/frontend/gemma4_images.json:126-238; only (100,3000) = [1,273,9]/273 and (3000,100) = [1,9,273]/273 are unique. gemma4.rs:404-420 (pixels_interleave_rgb_and_positions_are_xy) restates the 91×37 case whose pixels and positions hashes are already pinned at gemma4_images.json:155-156. Fix: keep the two unique geometries and the positional-ordering assertions, and let the SHA-256 fixture cover the rest. Nit because duplicate coverage is cheap and the fixture could be regenerated away later.
N5 — commit ab9a432b carries only its subject line.
SKILL.md:40-43 asks commits to state problem, resulting behavior, technical reason, compatibility impact, and validation. The commit is "Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans" with no body, although the change narrows the load path (positive-square patches_per_feature; patch_features re-export) and adds wire tags. Acceptable only because the PR description carries the compatibility statement and validation; noting as the last, lowest-priority item.
Prose checked and found sound (recorded so this review is honest about coverage)
helios/src/frontend/images/gemma4.rs:6module doc;:11-13source comment;:26wire-cap rationale;:27-71errors naming field and both values;:115,:127geometry errors naming the budget;:161,:168overflow errors;:182interleave invariant comment;:422-424the#[ignore]reason names its required input.helios/src/frontend/images/patch_merge.rs:10-12(not opened)Envelopedoc names both profiles that use it;helios/src/model/packing.rs:16-24(not opened);helios/src/model.rs:51,:72-73,:89;helios/src/model-contract.md:82(not opened);helios/src/frontend/images/conditioned.rs:189-192.ignition/preparation/contract.py:111-115documentspatch_featuresauthoring for authors ofBracketedvision recipes.docs/runtime-core-design.md:184-194,:237-239;helios/README.md:703-719,:721-730,:774-807.docs/TODO.txt:331-337records the recipe dependency, E2B/E4B/26B-A4B/31B serving qualification, and the partial-span prefix-cache audit — the correct place perAGENTS.md:56-60(unresolved items belong in TODO, not design docs).
Open questions / what I could not verify
- Runtime behavior of the load-path narrowings. I verified the described error and bound checks exist at the cited lines (
server/config.rs:443-489) and that the zero default decodes as legacy 1176; I did not run the suites. Whether the claimed pass counts (47 / 55 / 28 / 3 / 23 / 3) reproduce is a matter for CI or a local run — only a test run settles it. hyperflare-recipescompanion PR is outside this repository; I could not verify that it declaresvision.patch_features = 768as the description states, nor its merge order.docs/TODO.txt:331-337is the in-repo record of that dependency.- Whether an external reviewer would accept "Gemma 4" as a present-state identity (charter line 12 asks the runtime not to accumulate per-model branches). This is an architectural question outside the prose lens; the prose itself is consistent with the in-tree profile naming convention (Qwen, MiMo, Moonvit, Step, RADIO, GLM), and the new profile is wired through declared contract metadata rather than a hardcoded branch.