Correctness report · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/6a639b71-5021-4bda-bdd2-c5bb4359a616.md

Correctness review — PR #483 "Add Gemma 4 image preparation, Bracketed patch-width metadata, and atomic spans"

Head ab9a432b (rickybrent:core/gemma4-image-frontend), base main 27716185. 38 files, +2490/−251. Read-only review: I read the changed files in context and followed the callers, but did not execute cargo test or pytest, so every claim below is from code, not from a run.

Rules the change is judged against: charter line 12 ("Keep the runtime small and model-agnostic … shouldn't accumulate per-model branches"), charter line 42 ("verify that existing data, artifacts, and exported cores still load"), AGENTS.md (not opened) model core compatibility (protobuf additions must default so every engine still loads previous cores), and docs/design-review.md (not opened) principles 3 (shared mechanisms over per-model flags) and 10 (persist only consumed structural frontend settings in typed protobuf fields).

Key findings

Should fix

S1. Only 2 of the 5 allowlisted soft-token budgets are ever loaded (test coverage)

Why it matters: max_soft_tokens drives the geometry directly — max_patches() (gemma4.rs:98-100), the target pixel budget (gemma4.rs:106), the aspect-clamp branches (gemma4.rs:113-124), and max_envelope_tokens() (gemma4.rs:90-92), which in turn feeds the new load-time bound against prefill_chunk_size and span.max_tokens (helios/src/server/config.rs:464-487). The clamp branches at :118-123 (one dimension rounding to zero) are exactly the kind of edge that behaves differently at a small budget. A checkpoint declaring max_soft_tokens = 70 (the value its own video_processor uses in the fixture's provenance block) prepares successfully through Ignition and would exercise an untested path in Helios, so a parity or arithmetic defect is only visible in serving.

Fix: add (91, 37, 70), (10, 3000, 140) and one 560 case to the specs list in tests/frontend/generate_gemma4_image_fixtures.py:31-40 and regenerate, or add a load-only table test that constructs a processor for each SUPPORTED_SOFT_TOKENS entry and asserts geometry for one fixed shape. Either closes this and nit N2 together.

Nits

N1. patch_features % 3 is enforced on cores that never consume the field. helios/src/model.rs:89 rejects any vision core where patch_features is not a multiple of three, but the value is only read through bracketed_patch_features() (model.rs:74-80), used from frontend/images/packing.rs:41 and :486. A non-Bracketed core declaring a width such as 1024 fails at load with the generic "invalid prepared vision capabilities" (model.rs:99) instead of a message naming the field. Fix: scope the rule to ImageLayoutKind::Bracketed, or name the field and both values in the error.

N2. The soft-token allowlist exists twice, in two languages. helios/src/frontend/images/gemma4.rs:13 and ignition/preparation/frontend.py:132 must stay identical, and no test ties them. S1's fix (a table test over the Rust constant, plus the fixture cases) is the cheapest way to make drift visible.

N3. Unchecked arithmetic that is safe only because of the load caps. helios/src/frontend/images/gemma4.rs:99 (self.max_soft_tokens * self.pooling * self.pooling) and :139 (patches / (self.pooling * self.pooling)) are unchecked multiplies/divides; they cannot overflow only because load caps max_soft_tokens <= 1120 (:41-47) and pooling_kernel_size <= 16 (:34-40). Worth a one-line comment, since adding a larger budget to SUPPORTED_SOFT_TOKENS would silently move the bound. (The new allocation and budget paths themselves are guarded: :48-51 checked_mul, :157-170 try_fold/checked_mul, :164-171 checked_mul for the reserve.)

N4. Sub-envelope prefill capacity is truncated to zero with no test. helios/src/scheduler/policy.rs:337-351 — prefill_work_through truncates end back to span.start when the computed end falls strictly inside a span, so any captured prefill capacity smaller than the envelope length contributes no work for a span-bearing image request. The new bootstrap bound (helios/src/server/config.rs:464-479, max_envelope > prefill_chunk_size is rejected) makes this unreachable when the captured capacity equals prefill_chunk_size, but nothing pins that relationship with a test. A one-case test with a capacity just below the envelope would document the invariant.

Verified clean (recorded so the report is honest about what was checked)

Resolved since the previous revision

Open questions / could not settle