#1 [high] PR 483 overview + review rules
PR #483 NVIDIA/hyperflare-inference, author rickybrent (NOT a repo member; 0 merged PRs, this + #484 open). Base main 6d6fe0c6, head f2340e42. 13 files +732/−164. No reviews yet, no CI checks.
Changes: proto tag 11 ImageSettings.gemma4 (Gemma4ImageSettings), ImagePreparationKind Gemma4=11, Rust gemma4.rs image profile (new, 416 lines), patch_merge.rs refactor extracting Envelope, packing.rs derives bracketed stride from contract.vision.patches_per_feature (4->(2,1176), 9->(3,768)), model/packing.rs passes patches_per_feature into tensor_layout, model/prompt.rs populates data.spans from conditioned_inputs when image_tokens.span is Some, conditioned.rs Profile::Gemma4 => 768 features, describe.rs + protobuf.rs + ignition frontend.py profile.
Rules: charter line 12 "Keep the runtime small and model-agnostic... shouldn't accumulate per-model branches"; AGENTS.md "Model core compatibility" (protobuf additions must use defaults preserving existing behavior; every engine version must load previous cores), docs/design-review.md principles 3 (shared mechanisms, prepared metadata; reject per-model policy flags), 10 (persist only consumed structural frontend settings in typed protobuf fields), 13 (core compat).
Key rule citations: AGENTS.md lines 431-444 (model core compatibility), docs/design-review.md principles 3/10/13.
#2 [high] Findings inventory (correctness lens)
Key facts gathered so far (files at head f2340e4):
- helios/src/model/prompt.rs:137-151:
prepare_image_inputsfillsprepared.data.spansfromconditioned_inputs[i].token_spanwhenever the layout declares anImageSpanand spans are still empty. Only runs when images are non-empty. Deepseek layout already fills spans earlier (layouts/deepseek.rs:149), so it is unaffected. - helios/src/model.rs:408-457
validate_prompt_datavalidates spans: ordered, non-overlapping,s.len() <= config.limits.prefill_chunk_size, first token == span.start_token, last == span.end_token, and every scoped token must be inside a span. - helios/src/server/runtime.rs:1458-1465 calls
scheduler.set_prefill_spans(handle, &incoming.prompt.data.spans)right after admission (i.e. after prefix-cacheconsumed_tokensis known); an error cancels the request and fails it. scheduler.rs:1913-1936 rejects a span that straddlesconsumedor exceeds prefill capacity. - helios/src/frontend/images/packing.rs:16-22 new
bracketed_patch_geometry: only 4->(2,1176) and 9->(3,768); tensor_layout now takes patches_per_feature (model/packing.rs:92-97). Old cores all bracket at 4, so unchanged behaviour. - helios/src/frontend/images/packing.rs:479-509 bracketed() slices
images.pixel_values.get(start*patch_width..end*patch_width); a wrong derived width silently slices misaligned data when the graph buffer is large enough (only errors once the slab runs past the end). - helios/src/frontend/images/gemma4.rs:15-31
Processor::loadonly rejects patch_size==0/>64 and pooling==0/>16 plus a max_soft_tokens whitelist; it accepts patch_size != 16 or pooling != 3 that the packing path cannot represent. - helios/src/frontend/images/conditioned.rs:192
Profile::Gemma4(_) => 768hardcodes the feature width, while packing derives 768 from patches_per_feature=9: two independent derivations. - helios/src/frontend/images/patch_merge.rs:12-30
Envelopeextracted from the patch-merge Processor; same validation checks, but error text for empty/duplicate envelope tokens changed to "invalid image envelope tokens". - helios/src/frontend/images/mod.rs:537,613,705: EXIF orientation is skipped for Moonvit/DeepseekRowMajor/PaddedGrid, applied for every other profile (Gemma4 included); gemma4.rs parity test feeds synthetic tensors so orientation/alpha handling is untested.
- ignition/preparation/frontend.py:113-137 gemma4 profile writes patch_size=16, pooling=3, max_soft_tokens from the checkpoint and hardcodes "<|image|>", "<|image>", "<image|>".
- ignition/preparation/runtime_core_pb2.py diff also downgrades the generated-file header "Protobuf Python Version: 7.36.2" -> "7.36.1" (unrelated regeneration churn).
#3 [high] Findings A-D with file:line
FINDING A (should fix) — Gemma 4 profile accepts settings the packing path cannot represent.
helios/src/frontend/images/gemma4.rs:23-31 Processor::load validates only patch_size != 0 && <= 64, pooling_kernel_size != 0 && <= 16, and a max_soft_tokens whitelist. It never requires patch_size == 16 and pooling == 3, which are the only values bracketed_patch_geometry (helios/src/frontend/images/packing.rs:16-22) maps to a patch width, and the only values ignition/preparation/frontend.py:116-129 will export. Consequences of any other accepted value (e.g. patch_size=14/pooling=2 from a future or edited core):
tensor_layout(packing.rs:39-42) is called through model/packing.rs:92-97 while loading the core; it now returns Err("unsupported bracketed patches_per_feature") — but the failure is keyed onpatches_per_feature, not on the Gemma profile, so a Gemma 4 core whose contract declares patches_per_feature = pooling^2 (e.g. 4 for pooling 2) loads fine and then packs 31414 = 588 floats per patch into a 1176-float slot.conditioned.rs:192hardcodes 768 floats per patch forProfile::Gemma4(_), sovalid_processed(conditioned.rs:185-225) accepts the processor's own output and the mismatch is never caught there.bracketed()(packing.rs:479-509) then slicesimages.pixel_values.get(start*patch_width..end*patch_width); with the wrong width the slice either errors ("truncated vision pixels") or, when the slab is longer than needed, silently uploads misaligned data into the vision graph. No test covers a Gemma 4 processor whose patch_size/pooling differ from 16/3. Fix: require patch_size == 16 && pooling_kernel_size == 3 inProcessor::load(matching what frontend.py already enforces), and derive the feature width in conditioned.rs from the same bracketed geometry table instead of a second literal 768.
FINDING B (should fix) — Two independent derivations of the Gemma 4 patch width.
helios/src/frontend/images/conditioned.rs:192 (Profile::Gemma4(_) => 768) and helios/src/frontend/images/packing.rs:19 (9 => (3, 768)) each state 768 separately; gemma4.rs:116 computes 3 * patch_size * patch_size a third time. The cached-record validator and the upload staging therefore can disagree without any error. The PR description claims the derived-width design removes model-identity branching while the feature-width check still hardcodes the profile.
FINDING C (nit) — Unrelated regeneration churn in the checked-in Python bindings.
ignition/preparation/runtime_core_pb2.py header changes "Protobuf Python Version: 7.36.2" -> "7.36.1" (and the runtime version check argument 2 -> 1) while adding GEMMA4_IMAGE_PREPARATION and Gemma4ImageSettings. helios/manifest.md:465-472 says to regenerate with protoc --proto_path=helios/proto --python_out=ignition/preparation; the downgraded header shows the file was produced by a different protoc than main. It is cosmetic today but makes the reviewed diff harder and pins the bindings to an older generator than the rest of the tree; regenerate with the documented protoc.
FINDING D (nit / no defect found, note for the report) — prompt.rs span fill behaves, but only for tracks already covered.
helios/src/model/prompt.rs:137-151 fills data.spans from conditioned_inputs only when data.spans.is_empty() and the layout declares an ImageSpan. For Images/Deepseek the layout already wrote spans (layouts/deepseek.rs:149) so nothing changes; for every other layout image_tokens.span is None (see helios/tests/support/contracts/*.json) so the branch is inert. validate_prompt_data (model.rs:420-454) then enforces ordering, s.len() <= prefill_chunk_size, and the declared start/end token ids, and server/runtime.rs:1458-1465 passes them to set_prefill_spans, which fails the request if a span straddles the prefix-cache boundary (scheduler.rs:1913-1936). One consequence worth flagging to the author rather than a defect: a Gemma 4 envelope of an image larger than prefill_chunk_size (up to 1121 tokens) is rejected at admission ("invalid atomic prefill spans or prefix boundary"), so the recipe must keep chunks above the envelope size; no test asserts that message for a Gemma 4-sized envelope.