Correctness scratchpad · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/5e8a0f7f-317d-4bb0-a7a5-bb33c8ff1022.md

#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):

#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):

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.

#5 [high] Research summary

Verdict: should-fix issues only

I re-checked every changed file at head 2b4a31e through the correctness lens. Most of my previous report is now genuinely addressed at the code level, and two of the fixes are substantive:

Blocking: none.

Should fix

  1. helios/src/frontend/images/gemma4.rs:30-38 — one opaque error string covers six distinct rejections, including the new max_soft_tokens·pooling² > limits.max_patches_per_image capacity check. A Gemma 4 core whose captured patch capacity is below its max_soft_tokens budget (e.g. capacities captured at 280 while the checkpoint declares 1120) fails at ImageProcessor::load with invalid Gemma 4 image settings and no hint which of settings or capacity is wrong; server::config.rs:449-484 shows the actionable style. Fix: name the failing field/limit.

  2. helios/src/scheduler/policy.rs:337-351 with helios/src/scheduler.rs:2027-2042 — an atomic envelope longer than a captured prefill capacity makes that graph unusable without any load-time check. set_prefill_spans only bounds a span by prefill_chunk_size, and prefill_work_through truncates end to span.start, so a graph whose capacity is below the span length computes end.saturating_sub(start) == 0 — zero work for a request sitting at the span start. Nothing in validate_loaded_image_processor or the catalog validation ties max_envelope_tokens to the captured prefill catalog (only to prefill_chunk_size), and no test covers a Gemma 4 envelope with a smaller catalog entry. Settle with a scheduler test that advertises a prefill catalog containing a capacity below the 1122-token envelope, or reject such catalogs at bootstrap.

  3. helios/src/frontend/images/packing.rs:26-32,49-56 — Bracketed now fails at core load for a patches_per_feature that is not a positive square (via model/packing.rs:92-97 in Packing::new). On main such a core loaded and failed per request at bracketed(). That is a startup narrowing the description does not mention ("existing cores … remain loadable and unchanged"); it is only safe if no shipped/spelled core declares a non-square ratio. Fix: state the narrowing in the description, or keep the load-time check and add a mounting test for a square-but-unusual value (e.g. 16, which now loads and packs at the legacy 1176 width).

Nits

Verified as no longer a problem: runtime_core_pb2.py churn (regenerated at matching libprotoc 36.1, descriptor-only), check_input_extent/geometry() ordering, envelope validation (patch_merge.rs:20-31), and the patch_features serde default (build.rs:53-56, model.rs:52-53).

#6 [high] Report of 2026-11-25 (run 2), PR 483 at head 2b4a31e — should-fix only

PR #483, head 2b4a31e (base main 27716185), 36 files +2269/−240. Lens: correctness.

VERDICT: should-fix only; no blockers.

FIXED SINCE PREVIOUS REPORT (verified in code):

FINDING 1 (should fix) — opaque load error loses the capacity check. helios/src/frontend/images/gemma4.rs:30-38: one condition with one message "invalid Gemma 4 image settings" covers patch_size bounds, pooling bounds, the SUPPORTED_SOFT_TOKENS allowlist, pooling^2 != patches_per_feature, and the new max_soft_tokens*pooling^2 > limits.max_patches_per_image check. A core whose captured patch capacity is below its declared soft-token budget (e.g. 280-token capacity with a 1120 checkpoint) fails at ImageProcessor::load with no indication whether settings or capacity are wrong. Fix: split into named errors, following the actionable style of config.rs:449-484.

FINDING 2 (should fix) — envelope larger than a captured prefill capacity is unchecked and yields zero work. helios/src/scheduler.rs:2027-2042 bounds a span only by limits.prefill_chunk_size; helios/src/scheduler/policy.rs:337-351 truncates end to span.start when the span straddles, so a graph capacity below the span length yields end.saturating_sub(start)==0 (no work) for a request sitting at span start. Nothing ties max_envelope_tokens (up to 1122) to the captured prefill catalog — validate_loaded_image_processor only checks prefill_chunk_size (config.rs:473-482). No test. Fix: reject at load when the envelope exceeds the smallest captured prefill capacity a span-split chunk can use, or add the scheduler test.

FINDING 3 (should fix, description accuracy/compat) — Bracketed load-time narrowing. helios/src/frontend/images/packing.rs:26-32 + 49-50 + helios/src/model/packing.rs:92-97: Packing::new (core load) now errors with "bracketed patches_per_feature must be a positive square" for any Bracketed core that is not a square ratio; on main such a core loaded and failed per request in bracketed() (packing.rs:491-509). PR description says existing cores remain loadable and unchanged. Fix: disclose the narrowing, and/or add a mounting test for square-but-unusual values such as 16 (loads, packs at legacy 1176).

NITS:

RULES CITED: charter ("Supported matrix & compatibility ... verify that existing data, artifacts, and exported cores still load"; "No per-model special cases or flags"); AGENTS.md 431-444; docs/design-review.md principles 3/10/13.