Pre-test report — PR #483 "Gemma 4 image prep profile, bracketed 3×3 packing, atomic spans"
Head f2340e42 (2026-11-22) · base 6d6fe0c6 · 13 files · +732/−164 · no CI checks on head
Verdict: DO NOT REFER TO HARDWARE TESTING YET. Return to author.
Three independent grounds, any one of which is sufficient:
- The checked-in generated artifact would regress a feature merged after the branch point (verified two ways, see F1). That is wrong code, not untested code.
- A substantive architecture problem sits in the shared upload path (F2) and a second one in shared prompt/scheduling code (F3) — exactly the "will need to be changed" category that must never consume hardware time.
- There is nothing on cn5 or cn7 to test it against. No Gemma 4 checkpoint is present on either host, and no in-tree recipe selects the
gemma4image profile (recipes were split intolocal-inference-lab/hyperflare-recipesby17bb3c4a). A GPU run today cannot exercise this change end to end at all.
Expected value of a hardware run as the PR stands: near zero. Everything the diff actually changes is CPU-side and deterministic (decode → resize → patch interleave → positions → envelope expansion → upload-layout arithmetic → prompt/span validation). No kernel, no graph, no numeric-precision path is modified. Details and the conditional plan follow.
Findings — blocking (do not test; must be fixed first)
F1. The regenerated Python bindings overwrite main and drop TERMINAL_PREFILL (regression of #479)
Mechanism, verified by reading both refs:
- The branch predates #479 (
e091689b, Nov 23, "optional TerminalPrefill"). Onpr/483,helios/proto/runtime_core.proto:325-339runs… SCORED_PREFILL = 12;then closes the enum — noTERMINAL_PREFILL.mainhas:338 TERMINAL_PREFILL = 14;. A repo-wide search forTERMINAL_PREFILLatpr/483returns no matches (nothing inignition/,tests/, orhelios/src/either). - The
.protois not the problem on its own: the PR's proto hunks are+10/−0in disjoint regions (enum value 11 at:386, oneof tag 11 at:522, new message:535-542), so git combines them with main's and the merged schema keepsTERMINAL_PREFILL = 14. - The regression is
ignition/preparation/runtime_core_pb2.py:+122/−120replaces the entire serialized descriptor, generated from the stale schema. On merge, main's descriptor (withTERMINAL_PREFILL) is overwritten by one without it, while consumers are untouched by this PR:ignition/preparation/contract.py:29accepts"terminal_prefill"and:82callsp.GraphOperation.Value(kind.upper());tests/direct/test_scheduler.py:720assertsp.TERMINAL_PREFILL == 14. Result:AttributeError/ValueErrorat preparation and a failing direct scheduler test. - Compounding: the gencode header goes
Protobuf Python Version: 7.36.2 → 7.36.1(pb2:5) andValidateProtobufRuntimeVersion(..., 2 → 1, ...)(pb2:16), againstpyproject.toml:34 "protobuf>=7.36.2,<8". Regeneration command ishelios/manifest.md:468-471.
Fix: rebase onto main, regenerate with the pinned protoc so the artifact carries both GEMMA4_IMAGE_PREPARATION = 11 and TERMINAL_PREFILL = 14 at 7.36.2, and show tests/direct/ passing. This is the same class of issue that was treated as a merge blocker on #426.
Review-summary accuracy note: the "explore", "Prose", "Value Proposition" and "Architecture (lens B)" summaries all flagged the pb2 downgrade; only "explore" and "Prose" connected it to #479 specifically. The "Conventions", "Simplicity" and "Correctness" summaries called it a mere nit ("still loads", "not a functional defect") — that understates it, because the failure is not the version tuple but the missing enum in the overwritten descriptor. None of the summaries identified the TERMINAL_PREFILL drop as the decisive defect; I verified it directly.
F2. bracketed_patch_geometry is a model allowlist in shared packing, and changes core-load behaviour
helios/src/frontend/images/packing.rs:16-22:
fn bracketed_patch_geometry(patches_per_feature: usize) -> Result<(i64, usize)> {
match patches_per_feature { 4 => Ok((2, 1176)), 9 => Ok((3, 768)), _ => Err("unsupported …".into()) }
}
- Patch vector width is
3·patch_size²(16 → 768), a vision-tower property.patches_per_featureis a merge factor. The key is demonstrably not a width in this repo: DeepSeek runspatches_per_feature = 9with 588 floats per patch (packing.rs:32-34;helios/tests/support/contracts/deepseek4.json:9(not opened)). So9 → 768encodes model identity behind a geometry name — the pattern the charter's "keep the runtime small and model-agnostic … shouldn't accumulate per-model branches" forbids, and the opposite of the PR description's "no model-identity branching in upload packing" claim. - Behaviour change at core load:
helios/src/model/packing.rs:92-97now callstensor_layoutfromPacking::newwithconfig.contract.vision.patches_per_feature. PreviouslyBracketedwas a fixed2 × 1176. Any core declaringBracketedwith a merge factor outside {4, 9} now fails to start, and one with9paired to a 588-wide layout would be silently mis-strided. The description's "existing cores … unaffected" is unproven — nothing in the PR sweeps prepared cores. - Profile and contract can disagree:
gemma4.rs:23-44accepts anypatch_size ≤ 64/pooling ≤ 16. A core withpatch_size = 14, pooling = 2loads (merge factor 4 satisfies the table), produces 588 floats/patch (gemma4.rs:116), and is then sliced at the 1176-wide stride bybracketed()— "truncated vision pixels" at best, misaligned pixels into the vision graph at worst. - The 768 is authored three times:
packing.rs:19,conditioned.rs:192(Profile::Gemma4(_) => 768, the cache-validation predicate),gemma4.rs:116(the only one that derives it). A divergence surfaces as "image preprocessing differs from its prompt geometry" — pointing at the wrong layer.
Fix: carry the patch feature width in the prepared contract (e.g. next to patches_per_feature in VisionCapabilities, validated at model.rs:68-87), derive merge_side = patches_per_feature.isqrt() and width = 3·patch_size², and have conditioned.rs, bracketed() and gemma4::process read that one source. Add the load-time cross-check pooling² == patches_per_feature and 3·patch_size² == width.
Review-summary accuracy note: all five lenses independently found this; the most precise framing is the "Conventions" and "Architecture (lens B)" ones (count-keyed allowlist + the DeepSeek 588 counter-example). The "Correctness" summary's claim that this is a load-time break is correct and is the strongest argument for blocking, and no summary pressed it to a blocker.
F3. prompt.rs:137-151 changes scheduling behaviour for every span-declaring layout, with zero tests
if prepared.data.spans.is_empty() && config.contract.frontend.image_tokens.as_ref()
.and_then(|layout| layout.span.as_ref()).is_some() {
prepared.data.spans = prepared.conditioned_inputs.iter().map(|i| i.token_span.clone()).collect();
}
- This is profile-independent shared code.
data.spansdrivesvalidate_prompt_data(model.rs:420-454: per-span boundaries, coverage,len() ≤ prefill_chunk_size) andScheduler::set_prefill_spans— i.e. it decides which prefill submissions are unsplittable. The description scopes this to Gemma 4; the condition does not. - Precedent is the layout owning its spans (
frontend/images/layouts/deepseek.rs:149(not opened) pushes beside the expansion it builds).layouts/bracketed.rs:82-91returns empty spans andconditioned_inputs: vec![], so this is a second span producer in shared code, admitted by anis_empty()preference rather than an assertion that two producers agree. - Coverage is zero.
helios/tests/support/contracts/gemma4_frontend.json:16-17,38hasimage_preparation,image_layoutandimage_tokensallnull. The only span-bearing fixture isdeepseek4.json:56(not opened), and the only span declarations inprompt.rstests areDeepseek/DeepseekRowMajor(prompt.rs:481-487,699) — both already fill spans, sois_empty()is false and the new branch never runs under test. The "atomic spans" half of the headline result has no automated evidence anywhere in the repo. - Secondary, lower confidence: envelope span length is
tokens + 2(verified fromgemma4.rs:315-325: 260 features,eoiasserted atstart + 261,boiatstart). Withmax_soft_tokens = 1120that is 1122 > anyprefill_chunk_sizebelow that; the server default is 4096 (server/config.rs:149(not opened)) so the default deployment is safe, but nothing rejects the combination at load. (Several summaries state "+1/1121"; the test arithmetic says +2/1122.)
Fix: produce the span in layouts/bracketed.rs beside the envelope it computes, make overlap or absence a defect instead of an is_empty() preference, add a Bracketed contract fixture with image_tokens.span set, and add a test that a 1,120-soft-token envelope either fits or is rejected with a named error.
Findings — should-fix before any test run
| # | Finding | Evidence |
|---|---|---|
| F4 | Parity evidence cannot be reproduced or trusted. Both HF comparison tests return silently (counted as passes) without FLARE_GEMMA4_TEST_SNAPSHOT + ../.venv/bin/python: gemma4.rs:238-244, 253-256, 281-283, 336-339. No CI ran on f2340e4. The description's "45 passed … including Hugging Face checkpoint pixel/position parity" is consistent with the comparison never executing. Inputs are synthetic (x % 256) u8 rasters at 91×37, 10×3000, 3000×10 (gemma4.rs:355, 378-383); geometry_matches_the_hugging_face_processor (:197-216) is a hardcoded table, not a comparison. |
gemma4.rs:197-216, 236-334, 334-415 |
| F5 | Preparation pins one vision tower and hardcodes three tokens without validating them. frontend.py:126-129 pins 27 layers / 1152 hidden / 16 heads / head_dim 72 / 4304 FFN, and :130-137 hardcodes "<|image|>", "<|image>", <image|> with no check that each encodes to one added token — unlike _native_image_placeholder (frontend.py:231-245) which does exactly that for DeepSeek. Repo docs list five Gemma 4 variants (docs/model-preparation.md:345 (not opened), incl. gemma-4-26b-a4b, -31b). Charter's "more than one checkpoint (#74)" is unmet. No pytest for image_settings(profile="gemma4") exists (gemma4 has no match under tests/). |
frontend.py:113-137, 231-245 |
| F6 | Envelope test is scaffolding that proves nothing and leaks a temp file. gemma4.rs:257-299 shells out to Python to build a chat template it never renders, then remove_file only on the success path (:281-283 leaks). FrontendAssets.chat_template is Option (frontend/mod.rs:96-100 (not opened)), and the envelope expansion itself is already covered by layouts/bracketed.rs:104-180. The existing accessor is crate::template_fixtures::template("gemma4", "chat_template.google"). |
gemma4.rs:236-334 |
| F7 | Docs not updated for a new preparation kind / ImageSettings tag / the derived Bracketed stride, though helios/README.md:702-704 (not opened), docs/runtime-core-design.md:226-233 (not opened) and helios/model-contract.md:224-254 (not opened) each enumerate every other profile. Doc-only — does not gate hardware testing, but should land with the code. |
— |
| F8 | No protobuf round-trip test for tag 11, unlike its precedents (protobuf.rs:726 (not opened), :749). The "additive and wire-compatible" claim currently rests on a hand-run script. |
protobuf.rs:167-171 (not opened) |
Findings — nits (do not block, do not test)
packing.rs:494-502 unsolicited reformatting around a one-token change; redundant h % merge_side check (packing.rs:486) given gemma4.rs:46-48 guarantees the multiple; SUPPORTED_SOFT_TOKENS duplicated (gemma4.rs:11 vs frontend.py:123); self-referential Envelope doc comment (patch_merge.rs:10); layout-name drift in an error string (packing.rs:491).
Verified clean (no action)
- Wire additions are genuinely additive:
GEMMA4_IMAGE_PREPARATION = 11appended (runtime_core.proto:386),ImageSettings.gemma4 = 11(:522),Gemma4ImageSettings(:535-542);ImageLayoutKinduntouched; decode/describe arms mirror their neighbours (protobuf.rs:167-171(not opened),describe.rs:442-444(not opened),contract.rs:68(not opened)). Nothing renumbered. (The compatibility problem is the artifact, F1, not the schema.) - The
Envelopeextraction is real de-duplication, not churn:patch_merge.rs:10-81keeps the empty/duplicate-marker and single-token checks verbatim (only the message text changed to "invalid image envelope tokens"), and the thinProcessorwrapper (:83-129) leaves callers untouched. - Geometry arithmetic is sound:
checked_mul/try_foldoverflow guards (gemma4.rs:109-122),check_batchbefore and after, named error for degenerate sides (:65-76),tokens = patches/pooling²by construction, area bound at:77-81.resize::resizeis reused rather than a new kernel.
Expected value if a hardware test were performed
Low, and currently zero in practice.
- Nothing GPU-side is modified. No kernel, graph, numerics or precision path changes. The preprocessor runs on the frontend pool; the changed arithmetic is integer/CPU. There is no performance claim and no benchmark expectation attached (#210 does not apply), so a throughput A/B test would be pure waste — do not run one.
- What hardware could uniquely answer is narrow: (a) does a prepared Gemma 4 core actually load, and (b) does a vision request survive admission and atomic-span prefill chunking without the errors F2/F3 predict. Both are single-run correctness checks, not sweeps.
- Both are unreachable today: no Gemma 4 checkpoint on cn5 (
dinov2-base,timm/vit_base_patch14_dinov2, GLM-5.3-Flash variants) or cn7 (Qwen3.8 variants), and no in-tree recipe selectsimage_profile="gemma4"— the repos were split out, andgemma4_frontend.jsonstill hasimage_tokens: null. Serving needs a companion recipe PR plus a multi-GB checkpoint pull that is not on either host. - The valuable evidence is CPU-only and cheap:
cargo testwith parity made visible, a checked-in reference fixture, and the direct-scheduler suite. That should all happen on the author's machine and in CI, at no hardware cost.
Minimal test plan — only if F1–F4 are fixed and the PR is re-referred
Stage 0 is required to make Stage 1 meaningful; skip Stages 2–3 if the author's CI already proves them.
Stage 0 — gate on the author (no hardware).
Rebase onto main; regenerate runtime_core_pb2.py at protobuf 7.36.2 and confirm GEMMA4_IMAGE_PREPARATION and TERMINAL_PREFILL are both present (p.GraphOperation.Value("terminal_prefill") == 14); cargo test + pytest tests/preparation tests/direct green; report parity tests with skips made visible (or replaced by a checked-in fixture), not as a bare count.
Stage 1 — CPU correctness (cn5 job, no GPU needed; ~5 min).
cargo test -p helios frontend::images model::— must include the new Bracketed span test and the load-timepooling² == patches_per_featurerejection.- Misspecification regression (the key new test): build two
ImageLimits/contracts, one withpatches_per_feature = 4, one= 9, both against apatch_size = 16Gemma 4 profile; prepare a 91×37 and a 1008×672 image; assert the packedvision_pixel_valueslength ispatches × 768in both and that the pixel bytes are byte-identical between the two (the width must not depend on the merge factor). Then assert apatch_size = 14profile is rejected at load, not mis-strided at upload. - Span/scheduling test: a Bracketed contract with
image_tokens.spanset →data.spansequals the conditioned-input spans, boundaries are the declared start/end tokens; the same contract withmax_soft_tokens = 1120andprefill_chunk_size = 512→ rejected with a nameable error at load or admission, not a generic geometry message; a core already filling spans (DeepSeek fixture) → byte-identical prompt data tomain. - Backward compatibility: load one pre-existing prepared core per image layout (DeepSeek, MiMo, Qwen, Step, RADIO, GLM, padded-grid, patch-merge) and confirm each loads and packs exactly as on
main— this is the claim the description asserts and nothing currently checks.
Stage 2 — single serving check (cn5, one job, only if a recipe + checkpoint land).
One Gemma 4-31B-it run: prepare the core, then two requests — one text-only (regression: must be unchanged) and one with a single image — asserting a 200, that the response mentions plausible image content, and that max_soft_tokens at both a small and the 1,120 setting both admit. Watch specifically for "conditioned input spans or features violate prompt geometry", "invalid bracketed patch-merge image extent", and any prefill-split rejection. One image size larger than the prefill chunk is enough; do not sweep resolutions.
Stage 3 — regression sweep, intentionally minimal (cn5, one job).
Serve one non-Gemma vision model (Qwen3.8-27B-NVFP4 on cn7 is the better fit; GLM-5.3-Flash-NVFP4 on cn5 also works) with one image request, to prove the generalized bracketed/tensor_layout path and the pb2 change did not disturb existing vision cores. A single request each — no throughput comparison, no multi-run statistics, no cn7 GB10 arm64 pass unless Stage 1 or CI surfaces an arch-specific failure.
Explicitly not to be tested: throughput/latency A/B on any GPU; alphanumeric carving, 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 cases on hardware (already covered by the CPU geometry table); second-checkpoint variants until the vision-tower pin in F5 is relaxed.
Summary of review-summary reliability
The five summaries agreed on the substance and were mostly accurate. Corrections and emphasis I applied after direct verification: (1) F1 is a blocking regression of #479 via the overwritten descriptor — three summaries graded it a nit, and no summary named the TERMINAL_PREFILL loss; (2) F2's load-time break for patches_per_feature ∉ {4,9} is the strongest reason to block and appears only in the Correctness lens; (3) the envelope span is tokens + 2 (1122 at the max setting), not +1; (4) the hardware hosts carry no Gemma 4 checkpoint and no recipe selects the profile, which no summary stated and which makes the "worth testing?" question moot regardless of code quality; (5) I found no evidence that the PR discussion or any reviewed text attempted to direct the review — the single bot comment is a case-file notice.