Pre-test report — PR #483 "Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans"
Head 2b4a31e (2026-11-22, rebased onto main 27716185) · 36 files · +2269 / −240 · no CI checks visible on the head
Verdict: DO NOT REFER TO HARDWARE TESTING. Merge-readiness is close, but hardware is still the wrong instrument.
This supersedes my 2026-11-24 report (which was written against the pre-rebase head f2340e42). All three blocking findings from that report are fixed and verified in code at the new head. What remains is one small should-fix on the Python authoring surface plus nits and doc drift — none of which a GPU run can inform, and none of which changes the fact that nothing on either host can exercise this change end to end.
Grounds, in order of weight:
- No reachable test target. cn5 (4× RTX PRO 6000 Blackwell) hosts
facebook/dinov2-base,timm/vit_base_patch14_dinov2.lvd142m, and GLM-5.3-Flash-NVFP4 variants; cn7 (1× GB10) hosts Qwen3.8 variants. No Gemma 4 checkpoint on either host. The companion Gemma 4 recipe lives in the split-outlocal-inference-lab/hyperflare-recipesand does not exist yet (docs/TODO.txt:331-337is this PR's own tracking entry). No in-tree contract fixture usesImageLayoutKind::Bracketed(9) at all — fixtures use layouts 1, 2, 3, 5, 6, 10 — andhelios/tests/support/contracts/gemma4_frontend.json:16-17,38still declaresimage_preparation,image_layout,image_tokens=null. A GPU run today would exercise nothing this PR adds. - Nothing GPU-side is modified. No kernel, graph, numerics, or precision path changes. Every changed computation is CPU/deterministic: decode → area-bounded resize → RGB-interleaved patch pack →
(x,y)positions → token envelope expansion → upload-buffer extent arithmetic → prompt/span validation. The PR makes no performance claim and there is no benchmark expectation attached, so the "#210 benchmarks" rule is not engaged. A throughput A/B would be pure waste. - Zero blast radius on the models the hosts can serve. The one behaviour change reaching existing vision cores is
conditioned.rs:187invalid_processed, which now callsImageProcessor::patch_features()instead of the old_ => 588fallback (verified atmain:187-193). Per profile the resulting width is Qwen/MiMo 1536, Radio 768, Glm 1176 (unchanged), PaddedGrid 1200 (was 588), PatchMerge 1176 (was 588), others 588. The only profiles whose width actually changed — PatchMerge (MiniMax) and PaddedGrid (Inkling 2) — are not hosted on either machine, and both changes are bug fixes. The new load-time narrowings don't bite hosted cores either:square_merge_siderequires a positive squarepatches_per_featureforBracketedonly (MiniMax is 4, fine),server/config.rs:465-488envelope bounds apply only toProfile::Gemma4, andmodel.rs:79(patch_featuresdivisible by 3) only fires when the field is nonzero, which no existing core sets.
Expected value of a hardware run as the PR stands: ≈ 0, and strictly negative if it displaces a run of real work. The valuable evidence here is CPU-only and cheap — cargo test, the checked-in fixture test, pytest tests/preparation — which belongs in CI, at no hardware cost.
What changed since my last report — all three blockers verified fixed
B1 (was F1): regenerated runtime_core_pb2.py no longer regresses #479 — FIXED
I re-read the descriptor at ignition/preparation/runtime_core_pb2.py:27 on pr/483 and confirmed it now contains both GEMMA4_IMAGE_PREPARATION (value 11) and TERMINAL_PREFILL (value 14), plus main's PreparationManifest / PreparationParameter / PreparationParameterScope messages — i.e. it was regenerated from a schema that includes #479 and #426. The helios/proto/runtime_core.proto hunks remain strictly additive and disjoint (+:281-282 field 6, +:449 enum value 11, +:585 oneof tag 11, +:598-605 Gemma4ImageSettings).
The gencode header is still Protobuf Python Version: 7.36.1 (pb2:5, ValidateProtobufRuntimeVersion(..., 7, 36, 1, ...) at :12-19), but I read the same two lines at ref=main and they are identical — no drift against the base. The residual pyproject.toml:34 (not opened) (protobuf>=7.36.2,<8) versus main's own 7.36.1 artifact is a pre-existing main inconsistency, not this PR's. My prior report's blocker is fully withdrawn.
B2 (was F2): count-keyed patch-width table is gone — FIXED
packing.rs:16-32 is now LEGACY_BRACKETED_PATCH_FEATURES = 1176, bracketed_patch_features(&VisionCapabilities) (nonzero wins, 0 → legacy), and square_merge_side via isqrt with an exact-square check. tensor_layout takes &VisionCapabilities (packing.rs:34-56), its load-time caller model/packing.rs:92-97 and the upload path packing.rs:493-518 agree, and the width comes from the new additive VisionCapacity.patch_features = 6 (runtime_core.proto:281-282, #[serde(default)] at helios/build.rs:53-56, Rust field model.rs:51-53). The MiniMax counter-argument the author raised is legitimate: PatchMerge::patch_features() is 3*2*patch_size² = 1176 (patch_merge.rs:124-126), so width genuinely is not derivable from 3*patch_size² for temporal merges — carrying it as prepared metadata is the right call, and is exactly what design-review principle 3 asks for. Non-square Bracketed values are rejected at load (packing.rs:26-32) and covered by packing.rs:671-680; the legacy 0 → 1176 path is covered at packing.rs:660-670.
B3 (was F3): atomic spans are emitted by the layout, with tests — FIXED
layouts/bracketed.rs:52-111 now builds spans from mm_token_type_ids runs, gated on atomic_spans and rejecting a run without an envelope marker at either end; the shared fallback in model/prompt.rs is deleted (prompt.rs:52-65 now only derives the bool). Coverage that runs under plain cargo test: model/prompt.rs:1171-1282 asserts two spans equal to the conditioned-input spans, length 262, correct start/end marker tokens, all-interior-token identity, a 64-aligned 256-token chunk correctly rejected, and a MiniMax-style no-span contract staying empty.
Also fixed since the last report
- Single per-profile width authority:
ImageProcessor::patch_features()(mod.rs:459-471) over 11 profiles;conditioned.rs:187uses it; cross-profile consistency test atpacking.rs:695-824. - Load-time validation the PR was missing:
gemma4::Processor::loadenforcespooling² == limits.patches_per_featureandmax_soft_tokens·pooling² ≤ max_patches_per_imagewithchecked_mul/Option(gemma4.rs:25-52), andserver::config::validate_loaded_image_processor(config.rs:443-490) checks width againstvision.patch_features(with the actionable "re-export the core withvision.patch_features" error), plusmax_image_envelope_tokens ≤ prefill_chunk_sizeand≤ span.max_tokens. Boundary tests atconfig.rs:936-1023(1122 fits 1152, fails 1088;span.max_tokens1121 fails, 1122 passes; legacy 0 → re-export error; explicit mismatch names both widths). - Parity evidence is now CI-runnable:
tests/frontend/gemma4_images.json+ generator, consumed unconditionally bycanonical_processor_pixels_positions_and_resize(gemma4.rs:266-333) with SHA-256 over resized RGB,pixel_valuesandposition_idsacross 8 cases atmax_soft_tokens280 and 1120. The two live-checkpoint tests are#[ignore]d with hard assertions instead of silentreturns (gemma4.rs:374-447,:449+). - Ignition no longer pins one vision tower:
ignition/preparation/frontend.py:114-173asserts onlymodel_type,vision_config.model_type,patch_size,pooling_kernel_size, the processor flags,max_soft_tokens, and now validates all three envelope tokens as single vocabulary tokens againsttokenizer.json(not opened), cross-checked against optionalconfig.json(not opened) IDs, failing closed withouttokenizer_config/snapshot.tests/preparation/test_frontend_gemma4.py(216 lines) covers synthetic variants, the negative cases, and three cached checkpoints. - Docs updated:
helios/README.md:705-719,docs/runtime-core-design.md:181-197,helios/model-contract.md:82(not opened),docs/TODO.txt:331-337. Proto round-trip test added atruntime_core/protobuf.rs:813(not opened).
Residual findings — and whether any should gate a hardware run
| # | Finding | Severity | Gates testing? |
|---|---|---|---|
| A | ignition/preparation/contract.py:112 cannot author the new field. The default vision dict is dict(features_per_request=0, max_images=0, patches_per_feature=0, patch_capacities=[]) with no patch_features; patch_features appears nowhere else in ignition/ except the generated descriptor. A recipe that fills in the four historical keys exports 0 → legacy 1176, and a Gemma 4 (768) core is then rejected at flare run by config.rs:456-464. **vision still accepts an explicit key, so this is a default/ergonomics defect with a serve-time symptom, not a functional break. One-line fix, plus a docstring note that Bracketed vision cores must set it. |
should-fix | No — Python-side, CPU, unreachable from hardware |
| B | server/config.rs:449-455 duplicates :456-464: for the only layout that defines patch_features, bracketed_patch_features returns vision.patch_features verbatim, so the first check produces a second, vaguer error for the same mismatch. Fold into the Bracketed check. |
nit | No |
| C | gemma4.rs:30-38 collapses six distinct rejections into "invalid Gemma 4 image settings", including the new settings-vs-capacity check an operator is most likely to hit (max_soft_tokens·pooling² > limits.max_patches_per_image, where the limit comes from how the core was exported). Name the failing field/limit. |
nit (diagnostics) | No |
| D | gemma4.rs:132 re-inlines 3 * self.patch_size * self.patch_size next to the patch_features() accessor at :54; one-sided edit risk. Use the accessor. |
nit | No |
| E | Per-profile width is still authored in two matches keyed on different enums — packing.rs:41-100 (ImageLayoutKind) and mod.rs:459-471 (Profile) — linked only by the 11-row test at packing.rs:695-824, not the compiler. |
nit (test-covered) | No |
| F | patch_size/pooling_kernel_size are configurable on the wire and in serde, but frontend.py:124-127,140-141 pin 16/3 and :168-173 writes them literally, so no exporter can emit another pair; three validation arms (gemma4.rs:32-33) are unreachable. Profile constants (the glm.rs (not opened) const FACTOR precedent) would be smaller. Keep only if a future Gemma 4 size needs them. |
nit / design choice | No |
| G | Docs still drift: helios/README.md:721-728 presents Qwen's "1536 / temporal copy / 2×2 merge" as the shared process contract immediately under the new Gemma 4 paragraph (768 floats, no temporal copy, 3×3 pooling); docs/runtime-core-design.md:233-240 still omits Gemma 4 from the per-profile ImageSettings enumeration; the image-fixture provenance section (helios/README.md:772-789) names only the Qwen fixtures, so the new Gemma 4 generator/fixture and their pinned Transformers version are undocumented. |
should-fix (docs) | No |
| H | tests/frontend/gemma4_images.json:2-125 carries processor/model blocks the generator writes but the only consumer never reads (gemma4.rs:273 reads cases only), so envelope/token parity rests on the two #[ignore]d tests plus pytest checkpoint cases that pytest.skip without HF_HOME. Either consume the ids in Rust or trim the blocks. |
nit | No |
Nothing in this table is a substantive architecture or code-quality defect that would be invalidated by hardware testing. Finding A is the only pre-merge must, and it is one line in a Python helper.
The "Subtractive" lens recommends deferring the entire Gemma 4 profile (~1,200 lines) until the recipe PR exists. I do not treat that as a defect: the profile sits at the sanctioned enumerated extension point, is inert until a recipe selects it, and is the only way to unblock the recipe work. It is a scope/sequencing judgement for the maintainers, not a reason to test or not test.
Reliability of the supplied review summaries
The lenses converged and I re-verified their load-bearing claims directly. Corrections worth recording:
- My previous report's decisive finding (pb2 drop of
TERMINAL_PREFILL) is now moot — the head regenerated the descriptor against currentmain. Several summaries describe the 7.36.1 header as a defect; I confirmed by readingref=mainthat main's own artifact says 7.36.1, so there is no drift, and the "downgrade" framing is wrong (one summary, "Simplicity", made exactly that point). - Envelope length is
tokens + 2, not+1(gemma4.rs:58-59max_envelope_tokens = max_soft_tokens + 2; test assertsstart + 261for 260 features,config.rs:991-1002asserts 1122 atmax_soft_tokens = 1120). Summaries quoting 1121 are off by one. - The
correctness/architecturesummaries' "undisclosed load narrowing" is real but narrow:square_merge_sidefails at core load for a non-square (or zero)Bracketedpatches_per_feature, whereasmainhad a fixed 2×1176. No in-repo fixture usesBracketed, so the blast radius can only be settled againstlocal-inference-lab/hyperflare-recipes; MiniMax (4) is fine and the0 → 1176legacy path is preserved and tested. - Two summaries still describe code that no longer exists (the
4 => 1176, 9 => 768table; theprompt.rs:137-151span fill; theconditioned.rs:192literal). Those are stale against2b4a31eand should not be acted on. - Screening: both malicious-content screens returned all-clear; I re-read the changed hand-written surfaces and found no instruction-shaped or agent-directed text. The
#autobot:ignorefooter in the PR discussion is the repository bot's standard opt-out addressed to humans, not an instruction to this review. No injection attempt to report.
Recommended path (no hardware)
- Author fixes finding A (
patch_features=0incontract.py:112+ docstring note) and the four doc items in G. Both are cheap and land with the code. - CI proves the change, not a GPU:
cargo test(must includecanonical_processor_pixels_positions_and_resize,bracketed_layout_emits_atomic_spans_only_when_contract_declares_them,bracketed_packs_3x3_metadata_widths_and_rejects_invalid_extents,processor_patch_features_match_tensor_layout_for_every_profile,loaded_gemma4_image_processor_validates_patch_width_and_envelope_chunk_bounds,serialized_gemma4_profile_selects_only_image_preparation) pluspytest tests/preparation tests/direct— the direct-scheduler test attests/direct/test_scheduler.py:720(not opened) (TERMINAL_PREFILL == 14) is the guard that the regenerated gencode did not regress #479. No CI status is visible on the head, so the author's counts remain unverified; asking for them is far cheaper than a GPU job. - Refer to hardware only when a Gemma 4 vision recipe and a hosted checkpoint exist — that is the point at which this PR becomes testable at all, and the plan below applies.
Minimal test plan — only if referred (i.e. only after a Gemma 4 core can be prepared and served)
Deliberately small: 2 jobs total, no sweeps, no statistics.
Stage 0 — gate before any GPU time. p.GraphOperation.Value("terminal_prefill") == 14 and p.ImagePreparationKind.Value("GEMMA4_IMAGE_PREPARATION") == 11 both resolve from the checked-in runtime_core_pb2.py; cargo test and pytest tests/preparation tests/direct green; the two #[ignore]d tests reported as unrun, not as passes.
Stage 1 — CPU correctness, one cn5 job, no GPU needed (~5 min).
cargo test -p helios frontend::images model:: server::config— the six tests named above.- Misspecification regression (the key invariant this PR introduces): with a
patch_size = 16Gemma 4 profile, build two contracts differing only inpatches_per_feature(4 vs 9) and one servingBracketedcore withpatch_features = 768; prepare a 91×37 and a 1008×672 image and assert the packedvision_pixel_valueslength ispatches × 768in every case and the pixel bytes are byte-identical between merge factors — the width must not depend on the merge stride. Then assert apatch_features = 588core is rejected at bootstrap, and a core withpatch_features = 0gets the "re-export" error rather than a mis-strided upload. - Legacy compatibility: load one already-exported core per hosted vision layout (GLM-5.3 on cn5, Qwen3.8 on cn7) and confirm it loads and reports the same
patch_features/describe JSON as onmain(patch_featuresmust be omitted from describe when 0,describe.rs:466-468). - Span boundary: a
Bracketedcontract withimage_tokens.spanandmax_soft_tokens = 1120againstprefill_chunk_size = 1088must fail at bootstrap with a message namingprefill_chunk_size(not mid-request).
Stage 2 — single serving check, one cn5 job (4× RTX PRO 6000), only once a recipe + checkpoint exist.
Prepare the Gemma 4 core from the companion recipe (vision.patch_features = 768, ImageLayoutKind::Bracketed, ImagePreparationKind::Gemma4); serve TP=1 or TP=2, then two requests: one text-only (must be unchanged versus main) and one with a single image, asserting HTTP 200 and plausible image-grounded output. Repeat the image request once at max_soft_tokens = 280 and once at 1120. Fail-fast signals to watch: conditioned input spans or features violate prompt geometry, invalid bracketed patch-merge image extent, bracketed image span is missing envelope markers, image token spans do not match their declared boundaries, and any prefill-split rejection. One image size at or below the chunk and one above it is enough — do not sweep resolutions.
Explicitly not to be tested (would waste hardware):
- Any throughput/latency A/B on cn5 or cn7 — no kernel or scheduling hot-path change, no perf claim.
- A cn7 GB10 arm64 pass — nothing in the diff is arch-specific, and cn7 hosts no relevant core.
- Alphanumeric/EXIF/alpha edge cases for Gemma 4 — untested for every other profile, out of scope, not a regression.
- The synthetic ultra-wide 10×3000 / 3000×10 geometry cases on hardware — already pinned by the CPU fixture and the geometry table.
- Second-checkpoint variants (E2B/E4B/26B-A4B) — the Ignition gate is now generic, but serving variants is a post-recipe qualification tracked in
docs/TODO.txt:331-337, not a reason to spend a GPU job here. - Multi-GPU / TP>1 sweeps — the PR touches no collective or sharding path.