Code review summary scratchpad · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/bc3d28e6-68a9-4589-8ea2-ab8162aee2bd.md

#1 [high] PR #483 overview, files, charter hooks

PR #483 "Add Gemma 4 image prep profile, bracketed 3x3 packing & atomic spans" by rickybrent, head f2340e42, base 6d6fe0c6, +732/−164, 13 files. No human review yet (only autobot case-file comment). Files: helios/proto/runtime_core.proto (+10), helios/src/frontend/images/{gemma4.rs new +416, mod.rs +20, conditioned.rs +9, packing.rs +45/−5, patch_merge.rs +61/−38}, helios/src/model/{contract.rs +1/−1, packing.rs +1, prompt.rs +15}, helios/src/runtime_core/{describe.rs +2, protobuf.rs +5}, ignition/preparation/frontend.py +25, ignition/preparation/runtime_core_pb2.py +122/−120. Claims: native Gemma 4 image prep with "exact f32 pixel and (x,y) position parity" vs HF Gemma4ImageProcessor; Bracketed now derives stride/width from patches_per_feature ("orthogonal, no model-identity branching"); atomic spans populated; "existing cores and non-Gemma image profiles remain wire-compatible and unaffected". Evidence claimed: 45 passed frontend::images (with FLARE_GEMMA4_TEST_SNAPSHOT=google/gemma-4-31B-it 842da379), 53 passed model::, cargo check flare-cli, 15 pytest. Charter (read_charter): "Keep the runtime small and model-agnostic… shouldn't accumulate per-model branches (#267, #334)"; "Bring real evidence"; "Be explicit and pin everything (#215)"; "New model recipes… must list supported checkpoints… and support more than a single checkpoint (#74)". design-review.md:38-52: input packing/frontend processing stays shared; "Enums, callbacks, schema names, and metadata fields cannot serve as alternative model allowlists"; admission/eviction must not branch on model identity. AGENTS.md:72-140 (required PR description: why/what/result/evidence; "Keep material failures, skipped checks… visible. Test counts and labels cannot stand in for the tested contract and result"; :306 "Report a skipped test as an unrun check"), AGENTS.md:188-199 (no churn/unsupported configuration switches; tests must exercise behavior), :431-444 (additive protobuf).

#2 [high] FULL REPORT — PR #483 Blockers / Should Fix / Nits

FULL REPORT CONTENT (for the case file / final write-up).

=== BLOCKERS ===

B1. Bracket patch width is looked up from patches_per_feature — a model allowlist in shared input packing.

B2. The headline HF-parity evidence cannot fail, and is not reproducible or checked in.

B3. Atomic spans are produced by shared code for every span-declaring layout, are untested, and their compatibility impact is undisclosed.

=== SHOULD FIX ===

S1. gemma4::Processor::load accepts settings that neither the packer nor the cache validator can represent.

S2. The patch width is authored three times with no compile-time link.

S3. Largest supported image cannot be prefilled atomically at a small chunk size, and nothing checks it.

S4. Ignition's Gemma 4 gate pins one vision tower and derives nothing from the checkpoint.

S5. Documentation the change makes stale was not updated.

S6. Description corrections (AGENTS.md:72-140).

S7. Regenerated Python bindings went backwards in generator version.

=== NITS === N1. packing.rs:494-502 turns the one-line staging.put into a six-line call whose only real change is 1176 → patch_width; keep the original line and change the constant (AGENTS.md:188-193 on churn). N2. packing.rs:574-585 asserts the table (4→161176, 9→630768, 16 errors) — it will keep passing through the B1 mistake. Test the behavior instead: bracketed() at patches_per_feature = 9 (tokensppf == patches identity, truncated-pixel error, odd-grid rejection), or assert the metadata path once B1 lands. Note bracketed() itself is untested at 9. N3. packing.rs:486 h % merge_side / w % merge_side is redundant with the geometry the only producer emits (gemma4.rs:46-48, :63-64 floor to multiples of patch_sizepooling); if the profile keeps that guarantee, bracketed_patch_geometry collapses to a width and this check can go. N4. Soft-token allowlist is written twice with no citation: gemma4.rs:11 SUPPORTED_SOFT_TOKENS = [70,140,280,560,1120] and ignition/preparation/frontend.py:123 not in (70, 140, 280, 560, 1120). The Python producer rejects everything else first, so the Rust copy is unreachable; keep one authority and name the upstream field (image_processor.max_soft_tokens) at both sites. N5. Missing protobuf round-trip test for the new tag: helios/src/runtime_core/protobuf.rs:167-171 mirrors the PatchMerge arm correctly, but GLM and padded-grid each have serialized_*_selects_only_image_preparation tests (protobuf.rs:726, :749). Add serialized_gemma4_profile_selects_only_image_preparation — it is the only automated evidence for the additive wire claim. N6. Small prose: conditioned.rs:192's bare 768 wants a comment ("3×3 pooling over 16×16×3 = 768 floats per feature"); patch_merge.rs:10's doc "shared by enveloped image layouts" is self-referential (say which layouts and what the three fields mean); the new frontend.py:113-137 branch has no comment saying the fixed dimensions/tokens are the checkpoint's canonical processor values validated by _expected below (siblings document themselves, e.g. :99); packing.rs:491's "bracketed patch-merge" mixes the enum name with the README's "patch-merge" label — pick one. N7. Duplicated base commit in the description ("Branch logistics" and "Verified on base 6d6fe0c6").

=== CHECKED AND CLEAN (do not report as findings) ===

#3 [high] SUMMARY REPORT (GitHub post) — PR #483

SUMMARY REPORT (for the GitHub post; 10 bullets max, kept short).

This PR is on the right track — the proto/contract additions are additive, the patch_merge::Envelope extraction is genuine de-duplication, and the Gemma 4 resize/pack arithmetic is self-consistent and overflow-guarded. Three blockers keep it from being mergeable, and the case file has the detail.

Blockers

Should Fix

Nits

#4 [high] Caveats and verified details for B1/B2/B3

Caveats to state honestly when presenting B1/B3 (verified this pass):

#5 [high] Amendments — severity framings for S3, B2, B1

Amendments after verification (use these framings in the report):

  1. S3 (envelope vs prefill chunk) is a latent, not live, defect at repository defaults: ignition/preparation/bootstrap.py:36 defaults prefill_chunk_size = 4096, and scheduler limits require ≥64 and 64-alignment (helios/src/scheduler.rs:67-73). So 1,122 ≤ 4096 passes today; the failure needs a deliberately small prefill chunk (e.g. 1024) on a Gemma 4 core. Frame it as "the invariant is unenforced and undocumented, so it breaks silently for a small-chunk deployment", with the fix being a load-time rejection or clamp plus a boundary test — not as a blocker.

  2. B2 severity framing: the parity tests are honest in intent (they compare against HF when the environment is present) and the skipped-return pattern is precedent in this repo (helios/src/frontend/images/layouts/bracketed.rs:104-111 uses the same FLARE_MINIMAX_M3_SNAPSHOT skip-return). What makes it blocking here is that (a) "45 passed" is presented as evidence for a headline parity claim that plain cargo test never executes, and (b) every other profile's parity evidence is a checked-in fixture (glm.rs:147-199 + tests/frontend/generate_glm_image_fixtures.py; qwen38_images.json). So the ask is "make the parity evidence reproducible/CI-visible or mark it unrun", not "the tests are dishonest".

  3. B1 note: today ImageLayoutKind::Bracketed has exactly one in-tree producer (patch_merge / MiniMax M3, patches_per_feature = 4). The 9 => 768 arm therefore has a single real consumer, Gemma 4 — i.e. it is a model branch wearing a geometry name, and it contradicts the description's orthogonality claim. It is not currently a correctness bug for other models.

#6 [high] Research summary

Reviewed PR #483 (Gemma 4 image prep profile, bracketed 3×3 packing, atomic spans) against its diff, the four prior lenses, and the charter/design-review/AGENTS rules, and prepared both deliverables.

Full report (scratchpad entry 2) is organised into Blockers / Should Fix / Nits, each with finding, file:line evidence, and the requested change. Three blockers: (B1) packing.rs:16-22 keys the Bracketed patch width off patches_per_feature (9 => 768), which is model identity inside shared packing and contradicts the PR's own orthogonality claim — DeepSeek already runs 9 patches per feature at 588 floats; (B2) the headline HF-parity evidence cannot fail, because both snapshot tests return silently without FLARE_GEMMA4_TEST_SNAPSHOT / ../.venv/bin/python, so "45 passed" is identical whether parity ran, and unlike every other profile there is no checked-in fixture; (B3) prompt.rs:137-151 populates atomic spans in shared code for any span-declaring layout, with no test (the only Gemma 4 contract fixture has image_tokens: null) and no disclosure of the scheduling blast radius — the span should be emitted by layouts/bracketed.rs as deepseek.rs:149 does. Six Should Fix cover the missing profile/contract cross-checks, the thrice-authored 768 width, the unenforced max_soft_tokens + 2 ≤ prefill_chunk_size invariant, ignition pinning a single vision tower (charter #74 wants more than one checkpoint), stale docs (helios/README.md:702-704, docs/runtime-core-design.md:226-233, helios/model-contract.md:251-254, docs/TODO.txt), description corrections, and the protobuf gencode regenerated with 7.36.1 under a >=7.36.2 pin. Seven nits cover churn, the table-only test, a missing protobuf round-trip test, the duplicated soft-token allowlist, and prose.

Summary for the GitHub post (scratchpad entry 3) is 10 bullets: 3 blockers, 5 should-fix, 2 nits, each one line of finding plus a tldr request.

Verified caveats are in entry 5: S3 is latent rather than live at the repo's 4096 default chunk, B2's skip-return pattern has in-repo precedent (the MiniMax test does the same) so the ask is reproducibility rather than honesty, and Bracketed currently has only one in-tree producer so B1 is a design violation rather than a present correctness bug. Envelope length is tokens+2 = 1,122 at the 1,120 setting.

#7 [high] Report assembly notes: ordering, exact edit sites, request one-liners

Assembly notes for the final report (entries 1-5 hold the content; this entry holds order + exact imperative requests).

Order the full report: Blockers B1, B2, B3 → Should Fix S1-S7 → Nits N1-N7 → short "verified clean" paragraph (from entry 2's last section) so the author knows what not to re-litigate. Every bullet keeps three parts: Finding (file:line), Request (imperative), Why (rule or failing workflow). Nits may omit Why.

Imperative one-liners to paste as the "Request" for each item:

B1 — "Move the Bracketed patch width into prepared metadata: add patch_size to VisionCapabilities (helios/src/model.rs:44-51), validate it beside patches_per_feature in VisionCapabilities::validate (helios/src/model.rs:68-87), then in packing.rs compute merge_side = patches_per_feature.isqrt() and patch_width = 3 * patch_size * patch_size; delete bracketed_patch_geometry (packing.rs:16-22) and thread the width from config, as class_token() already reads padded_grid::FEATURES (packing.rs:515)." B2 — "Replace the subprocess parity comparison with a checked-in fixture: add tests/frontend/gemma4_images.json + tests/frontend/generate_gemma4_image_fixtures.py (width, height, grid, tokens, SHA-256 of resized bytes / pixel_values LE / position_ids LE) and assert them in gemma4.rs the way glm.rs:147-199 does. Keep a snapshot test only if it is #[ignore = "..."], and report the ignore in the description." B3 — "Emit the span where the envelope is built: layouts/bracketed.rs:82-91 should push data.spans for the range it expanded (mirror layouts/deepseek.rs:149), delete helios/src/model/prompt.rs:137-151, add a Bracketed contract fixture with image_tokens.span set and a test that the span is produced, passes validate_prompt_data, and is rejected when longer than prefill_chunk_size." S1 — "In gemma4::Processor::load (gemma4.rs:23-31) reject unless pooling_kernel_size * pooling_kernel_size == limits.patches_per_feature, 3 * patch_size * patch_size equals the packing patch width, and max_soft_tokens * pooling² <= limits.max_patches_per_image." S2 — "Replace the three literals with one shared constant/helper derived from profile+contract metadata, used by conditioned.rs:192, bracketed() (packing.rs:479-481) and gemma4::process (gemma4.rs:116)." S3 — "Reject (or clamp with a named error) at load when max_soft_tokens + 2 > prefill_chunk_size, and add a boundary test at exactly the chunk size." S4 — "In ignition/preparation/frontend.py:113-137, assert only what the preprocessor consumes (image processor fields, model_type: gemma4_vision, patch_size, pooling_kernel_size, max_soft_tokens) and the three token strings taken from the tokenizer config with an assertion that each encodes to one added token; drop the 27/1152/16/72/4304 pin or move it to the recipe." S5 — "Add Gemma 4 to helios/README.md:702-704, docs/runtime-core-design.md:226-233, helios/model-contract.md:251-254 (16×16 patches, 3×3 pooling, soft-token set) and record the recipe dependency in docs/TODO.txt (style: docs/TODO.txt:1-30)." S6 — "Fix four description items: delete the orthogonality sentence or reword it to describe what packing.rs actually does; drop Execution.persistent_workers (it is #430 / commit 66bf6d03, not this diff); replace 'existing cores unaffected' with the concrete load-path narrowing (patches_per_feature must now be 4 or 9 at model/packing.rs:92-97) and say which cores were swept; state that no serving-path timing was measured and that the parity comparison does not run under plain cargo test." S7 — "Regenerate ignition/preparation/runtime_core_pb2.py with the tree's protoc (protoc --proto_path=helios/proto --python_out=ignition/preparation helios/proto/runtime_core.proto, helios/manifest.md:465-472) so the header returns to 7.36.2 and only descriptor bytes change."

Tone: the review is a request for changes, not a rejection; lead the summary with what is already good (additive proto, Envelope extraction, overflow-guarded geometry) before the blockers.