Correctness report · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/4a4cf842-49c6-4eee-9815-14104ebb00d8.md

Review of PR #483 — Gemma 4 image preparation, Bracketed patch-width metadata, atomic spans

Lens: correctness and consequences — every caller, configuration, platform and persisted state the change touches; existing cores and artifacts must still load.

Rules applied:

Reviewed at head 2b4a31e (base main 27716185), 36 files, +2269/−240.

Key findings

  1. Should fix — opaque Gemma 4 load error (helios/src/frontend/images/gemma4.rs:30-38). One condition with one message covers six distinct rejections: patch_size == 0/> 64, pooling_kernel_size == 0/> 16, the SUPPORTED_SOFT_TOKENS allowlist, pooling² != limits.patches_per_feature, and the new max_soft_tokens · pooling² > limits.max_patches_per_image. The last two are the interesting ones because they compare settings against captured capacity: a core whose captured patch capacity is below its declared soft-token budget (e.g. capacities taken at 280 while the checkpoint declares 1120) fails at ImageProcessor::load with invalid Gemma 4 image settings and no way to tell whether the settings or the capacity is wrong. helios/src/server/config.rs:449-484 shows the actionable style this file should follow (it names both values). Fix: split into named errors naming the failing field/limit.

  2. Should fix — Bracketed gains a load-time narrowing the description does not disclose (helios/src/frontend/images/packing.rs:26-32, used from packing.rs:49-51 and helios/src/model/packing.rs:92-97). square_merge_side returns Err("bracketed patches_per_feature must be a positive square") for isqrt failures, and tensor_layout is called from Packing::new while the core is loading, so any ImageLayoutKind::Bracketed core declaring a non-square (or zero) patches_per_feature now fails to start. On main, tensor_layout never consulted patches_per_feature for Bracketed (fixed 2 × 1176 geometry) and such a core loaded and failed, if at all, per request in bracketed(). The PR body claims "existing cores … remain loadable and unchanged"; that is true of the wire format but not of this load path, which is exactly the check the charter (line 42) and AGENTS.md:431-444 (not opened) require to be proven. Fix: disclose the narrowing in the description and add a mounting test for a square-but-unusual value (e.g. 16, which now loads and packs at the legacy 1176 width), or accept any square ratio only after a sweep of shipped cores.

Detail by finding

1. Gemma 4 load-time validation (should fix, diagnostics)

gemma4.rs:25-39 also runs Envelope::load (patch_merge.rs:20-31) for the marker checks, which does produce specific messages; only the settings-vs-capacity block is opaque. The capacity clause is new in this revision and is the one an operator is most likely to hit, because limits.max_patches_per_image comes from the prepared vision.patch_capacities (helios/src/server/config.rs:492-500), i.e. from how the core was exported, not from the checkpoint. Nothing in docs/runtime-core-design.md (not opened) or helios/model-contract.md (not opened) tells an exporter what max_patches_per_image must be for a given max_soft_tokens; an explicit error is the only feedback available.

2. Bracketed compatibility (should fix, description/coverage)

3. Former "profile accepts settings packing cannot represent" — resolved, recorded for completeness

gemma4.rs:54-56 derives the per-patch width as 3 · patch_size²; conditioned.rs:187 now uses self.processor.patch_features() instead of a per-profile literal; mod.rs:459-471 covers all 11 profiles; config.rs:449 forces the prepared vision.patch_features to equal it. Consequently a hypothetical patch_size = 14, pooling = 2 Gemma 4 core is now internally consistent (588 floats per patch everywhere) rather than silently misaligned, and the 16/3 geometry is pinned where it should be — in the exporter (ignition/preparation/frontend.py). The collapse also fixes a pre-existing main bug: the old _ => 588 arm matched Profile::PatchMerge, so MiniMax's 1176-float patches failed valid_processed (conditioned.rs:213) and materialize (conditioned.rs:249).

4. Atomic spans — correct scoping, one untested interaction

Nits

  1. helios/src/frontend/images/gemma4.rs:13 — SUPPORTED_SOFT_TOKENS = [70, 140, 280, 560, 1120] duplicates the allowlist in ignition/preparation/frontend.py:132. Two copies of a value that must stay in lockstep; a drift turns an export into a load rejection with error #1 above as the only clue.
  2. helios/src/scheduler/policy.rs:337-351 with helios/src/scheduler.rs:805-817 — prefill_work_through truncates end to span.start whenever a span straddles the computed cut, so end.saturating_sub(start) == 0; planning drops those candidates (policy.rs:479-482 and 911-923). Because the load check forces envelope <= prefill_chunk_size and prefill_graphs requires the catalog to contain prefill_chunk_size (scheduler.rs:807), a request is still served by the largest graph, so I could not show starvation; but every captured non-terminal capacity below the envelope length is silently unusable for span-bearing image requests, and no test covers a catalog with such an entry. A scheduler test advertising a sub-envelope capacity would settle it.
  3. helios/src/scheduler.rs:2036-2037 vs docs/TODO.txt:331-336 — a prefix-cache endpoint restored strictly inside a span fails the whole request. scheduler/checkpoints.rs keeps published endpoints span-aligned, so the in-process path is safe, but a host-store record restored with a mid-span endpoint still fails admission and nothing asserts the intended behaviour.

Verified as no longer a problem

Open questions / not settled from the code