Correctness report · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/80f34036-5098-4a18-824e-783865c5c89f.md

Review of PR #483 — Gemma 4 image prep profile, bracketed 3×3 packing, atomic spans

Lens A (correctness and consequences): every caller, every supported configuration, resource lifetimes, inactive and edge-case paths, state/graph transitions, and whether existing cores and artifacts still load.

Rules applied: charter line 12 ("Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches"), AGENTS.md 431-444 (protobuf additions must preserve existing behaviour; every engine version must load previous cores), docs/design-review.md principles 3 (shared mechanisms, no per-model policy flags), 10 (persist only consumed structural frontend settings in typed fields), 13 (core compatibility).

Key findings

  1. Bracketed packing now hard-errors at core load for a patches_per_feature it never used before. helios/src/frontend/images/packing.rs:16-22 (bracketed_patch_geometry) accepts only 4 → (2, 1176) and 9 → (3, 768) and returns Err otherwise; helios/src/model/packing.rs:92-97 calls it from Packing::new while the core is loading. Before this PR Bracketed used a fixed 2 × 1176 geometry, so a core that declares ImageLayoutKind::Bracketed with any other patches_per_feature loaded and packed fine on main and now fails to start. The PR description says "Existing cores … remain wire-compatible and unaffected"; that is true of the wire format, not of this load path. Needs a sweep of the shipped/exercised cores (the vision contract field is set per recipe in ignition/preparation/contract.py:112; e.g. helios/tests/tools/test_step_images.rs:82 (not opened) sets patches_per_feature = 16) before the check is trusted.
  2. The Gemma 4 profile accepts settings the packing path cannot represent. helios/src/frontend/images/gemma4.rs:23-31 validates only patch_size != 0 && <= 64, pooling_kernel_size != 0 && <= 16, and a max_soft_tokens whitelist (SUPPORTED_SOFT_TOKENS, gemma4.rs:11). It never requires the 16/3 pair that bracketed_patch_geometry maps and that ignition/preparation/frontend.py:116-129 actually exports. A Gemma 4 core declaring, say, patch_size = 14, pooling = 2 loads (its patches_per_feature = 4 satisfies the table), the processor emits 3·14·14 = 588 floats per patch (gemma4.rs:116), and bracketed() (packing.rs:479-508) slices with the 1176-wide stride — either "truncated vision pixels" or, when the slab is large enough, silently misaligned pixels into the vision graph. The cached-record check cannot catch it either (see finding 3).
  3. Three independent derivations of the 768-float Gemma 4 patch width. helios/src/frontend/images/conditioned.rs:192 (Profile::Gemma4(_) => 768) validates cached processed images, helios/src/frontend/images/packing.rs:19 (9 => (3, 768)) computes the upload stride, and helios/src/frontend/images/gemma4.rs:116 computes 3 * patch_size * patch_size when producing the data. The PR argues the derived-width design removes model-identity branching, but the validator still keys on the profile with a literal. If any two of the three disagree, valid_processed (conditioned.rs:185-225) passes data the upload stage slices at a different width, with no error unless the slice runs past the end.
  4. The new atomic-span path adds failure modes that the PR does not mention. helios/src/model/prompt.rs:137-151 copies every conditioned_inputs token span into data.spans when the layout declares an ImageSpan. validate_prompt_data (helios/src/model.rs:420-424) rejects any span whose len() exceeds config.limits.prefill_chunk_size; a Gemma 4 envelope is max_soft_tokens + 1, i.e. up to 1,121 tokens with the 1,120-token setting (gemma4.rs:11, patch_merge.rs:60-69). So any deployment with a prefill chunk below the envelope size now fails prompt validation for a maximum-size image, and Scheduler::set_prefill_spans (helios/src/scheduler.rs:1923-1933) additionally fails a request whose prefix-cache match ends inside an envelope; helios/src/server/runtime.rs:1458-1465 turns that error into a failed request. Neither case has a test.
  5. The claimed Hugging Face parity is not exercised by CI. Both reference tests bail out silently when the environment is absent: gemma4.rs:238-244 (FLARE_GEMMA4_TEST_SNAPSHOT) and gemma4.rs:336-339 (../.venv/bin/python). With no CI on the head commit, the "exact f32 pixel and (x, y) position parity" claim rests entirely on a local run, so a regression in resize::resize or the patch loop would pass the suite.

Callers and configurations

Resource lifetimes and edge-case paths

Existing cores, artifacts and state transitions

Nits

Open questions / not settled from the code