Value proposition scratchpad · NVIDIA/hyperflare-inference #483

Raw Markdown for agents: https://autobot.eidonix.com/p/801f1af2-9d5e-487d-aee1-75fec8e7b6f5.md

#1 [high] PR 483 scope and diff map

PR #483 by rickybrent, branch rickybrent:core/gemma4-image-frontend (f2340e42) vs main 6d6fe0c6. Adds a 12th image preparation profile (Gemma 4) plus changes to bracketed packing and prompt spans.

Files:

Claimed evidence: cargo lib tests frontend::images 45 passed with FLARE_GEMMA4_TEST_SNAPSHOT; model:: 53 passed; flare-cli cargo check; pytest 15 passed; explicit limitation that end-to-end serving needs companion recipes in local-inference-lab/hyperflare-recipes.

#2 [high] Charter fit and evidence gaps for PR 483

Charter: (a) "Keep the runtime small and model-agnostic ... shouldn't accumulate per-model branches (#267,#334)"; (b) "New model recipes, aliases, or formats must list supported checkpoints ... prove they export and serve cleanly from the PR branch, and support more than a single checkpoint (#74)"; (c) "Bring real evidence"; (d) "solve the right problem in the right place / smallest footprint"; (e) "Be explicit and pin everything. No magic defaults".

Precedent that image profiles belong in Helios: docs/model-contract.md:226-227 ("image preparation and image layouts each have an independent enum selector"), 11 existing profiles (qwen, mimo, deepseek4, deepseek_row_major, moonvit, step, radio, glm, patch_merge, padded_grid), padded_grid added by maintainer Luke Alonso in 8628b7c5.

Gap this closes: Gemma 4 is an already-supported family (docs/model-preparation.md:345 lists gemma-4-e2b/e4b/12b/26b-a4b/31b) but Helios' own fixture has image_preparation/image_layout null and image_tokens null (helios/tests/support/contracts/gemma4_frontend.json:16-17,38) = text only today.

Defects to fix:

  1. protobuf artifact downgraded: ignition/preparation/runtime_core_pb2.py:5 "7.36.2"->"7.36.1" and :16 minor 2->1, i.e. regenerated with older protoc though pyproject.toml:34 pins protobuf>=7.36.2 and main's file was 7.36.2 (from #430). Regenerate per helios/manifest.md:468-472 with the pinned protoc.
  2. Hardcoded geometry table helios/src/frontend/images/packing.rs:16-21 (4->(2,1176), 9->(3,768), else Err) and duplicate literals: gemma4.rs computes 3patch_sizepatch_size, packing.rs hardcodes 768, conditioned.rs:192 hardcodes 768. Derive from contract/settings instead (e.g. add patch feature width to VisionCapabilities or to the profile).
  3. No test at all for the spans change (helios/src/model/prompt.rs:137-151): nothing asserts spans are populated for a span-declaring Bracketed layout, nor that span-declaring layouts that fill spans themselves (deepseek, layouts/deepseek.rs:149) are unaffected, nor that a non-span layout stays empty.
  4. Token literals hardcoded in ignition/preparation/frontend.py:130-137 ("<|image|>", "<|image>", "<image|>") with no preparation-time validation that each encodes to one atomic vocabulary token (contrast _native_image_placeholder at frontend.py:231-245 for DeepSeek). Failure currently only surfaces at request time via patch_merge::Envelope::expand.
  5. SUPPORTED_SOFT_TOKENS duplicated in gemma4.rs:8 and frontend.py:123.
  6. max_soft_tokens up to 1120 (=> image span 1122 tokens) is allowed, but validate_prompt_data rejects any span longer than config.limits.prefill_chunk_size (helios/src/model.rs:420-423). Nothing validates the pair at preparation; a recipe with prefill chunk 512 would export a core that rejects large images at admission.
  7. Evidence: HF parity tests silently return unless FLARE_GEMMA4_TEST_SNAPSHOT and ../.venv/bin/python exist (gemma4.rs checkpoint_tokens_expand_the_image_envelope, native_pixels_and_positions_match_the_checkpoint_processor), so CI proves nothing; exact f32 parity is on synthetic arange images at 91x37/10x3000/3000x10 only; no real photo, no second Gemma 4 checkpoint (#74), no export and no served request. PR says end-to-end needs companion PRs in local-inference-lab/hyperflare-recipes, so the atomic-span path has zero in-repo consumers.
  8. No new pytest for ignition image_settings(profile="gemma4") despite the new strict _expected() pins at frontend.py:113-137.
  9. No docs update recording the profile's checkpoint pins/limitations.

Good parts: reuses resize::resize (no new resampler), extracts patch_merge::Envelope instead of copying envelope logic, proto changes additive (tag 11 / enum 11), bracketed validation generalised (tokens*ppf==patches replaces ppf==4) with equivalent behaviour for ppf=4, gated parity harness mirrors patch_merge.rs:174-212 pattern.

#4 [high] PR 483 second-pass verification (2026-11-25 rebase, 2b4a31e9)

Branch rebased onto main 27716185; PR head 2b4a31e9. All prior blockers verified resolved:

  1. Protobuf downgrade — MOOT. main itself now has Protobuf Python Version: 7.36.1 / minor 1 (read ignition/preparation/runtime_core_pb2.py at ref=main, lines 5,16). PR file identical header; pr_diff shows only the DESCRIPTOR line changed (descriptor-only). Note: pyproject.toml:34 still pins protobuf>=7.36.2,<8 while main+PR artifacts say 7.36.1 — PRE-EXISTING main inconsistency, not caused by this PR.

  2. Hardcoded 4=>1176 / 9=>768 table — GONE. packing.rs:16-32 now LEGACY_BRACKETED_PATCH_FEATURES=1176, bracketed_patch_features(vision) (patch_features, 0=>legacy), square_merge_side(ppf) via isqrt + exact-square check. conditioned.rs:187 now self.processor.patch_features() (was inline match with _ => 588). Single owner = ImageProcessor::patch_features() mod.rs:459-471. Cross-profile test processor_patch_features_match_tensor_layout_for_every_profile packing.rs:695-824 (11 profiles; Gemma4 => 9/768).

  3. Spans in shared code — MOVED to layouts/bracketed.rs:58-65 (atomic_spans: bool, validates start>0 && end<len else "missing envelope markers"); prompt.rs only passes image_tokens.span.is_some(). Shared fallback deleted. Test prompt.rs:1172-1281 bracketed_layout_emits_atomic_spans_only_when_contract_declares_them: span-bearing => 2 spans == conditioned_inputs token_span, len 262, marker check; prefill_chunk 256 => Err; span=None => spans empty.

  4. Preparation validation — frontend.py:114-172 validates processor_class, image_processor fields (patch_size 16, pooling 3, do_resize/rescale, do_normalize False, mean 0/std 1) + optional resample/rescale_factor/do_convert_rgb; max_soft_tokens in {70,140,280,560,1120} with type() is not int guard; model_type gemma4; vision_config gemma4_vision. Envelope tokens from tokenizer_config (image_token/boi_token/eoi_token), distinct, and each verified via token_to_id + encode(..., add_special_tokens=False).ids == [id] (single atomic token) + optional config.json id cross-check. Fails closed if tokenizer_config or snapshot omitted. Tests: tests/preparation/test_frontend_gemma4.py (216 lines) — synthetic E2B tower, object-form tokens, gemma4_unified rejection x3, bad geometry (patch_size 14/pooling 2/max_soft_tokens 300/True), fail-closed, missing/empty/duplicate tokens, unknown + multi-token token, mismatched/bool IDs, 3 cached real checkpoints (31B, 31B-NVFP4, E2B).

  5. Load-time invariants — gemma4.rs:25-52 pooling_area != Some(limits.patches_per_feature) and max_soft_tokens*pooling² <= limits.max_patches_per_image, plus SUPPORTED_SOFT_TOKENS + patch_size<=64/pooling<=16 bounds. server/config.rs:443-489 validate_loaded_image_processor: width vs vision.patch_features; Bracketed via bracketed_patch_features with "re-export the core with vision.patch_features" error; max_image_envelope_tokens <= prefill_chunk_size and <= span.max_tokens. Tests config.rs:935-1024 boundaries (1122 vs chunk 1088/1152; span_max 1121/1122; patch_features 0 => re-export error; 588 mismatch names both).

  6. Parity evidence durable — tests/frontend/gemma4_images.json (256 lines) + generate_gemma4_image_fixtures.py checked in; gemma4.rs:266-333 canonical_processor_pixels_positions_and_resize uses include_str!, unconditional, asserts SHA-256 of resized RGB bytes + pixel_values + position_ids + grid/tokens/patches + cu_seqlens; 8 cases over max_soft_tokens 280 and 1120 (1x1, 91x37, 672x672, 1008x672, 1920x1080, 10x3000, 3000x10, 1920x1080@1120). Live tests now #[ignore = "..."] with expect/assert (gemma4.rs:375, 450).

  7. Docs — helios/README.md:706-718, docs/runtime-core-design.md:181-196 (patch_features semantics + bootstrap checks), helios/model-contract.md:82, docs/TODO.txt:330-337 (companion recipe, E2B/E4B/26B-A4B/31B serving qualification, partial-span prefix-cache audit). Protobuf round-trip test protobuf.rs:813.

BONUS latent bug fixed: on main, conditioned.rs:187-193 valid_processed had _ => 588, so PatchMerge (MiniMax, 1176-wide patches via patches.rs:89 3*2*patch_size²) never matched → every cached MiniMax prepared-image record failed validation and was invalidated/re-materialized. PR routes through ImageProcessor::patch_features() (PatchMerge => 1176), fixing it.

Residual gaps (non-blocking): docs/model-preparation.md says nothing about Gemma 4 images (only lists checkpoints at :321); helios/tests/support/contracts/gemma4_frontend.json still has image_preparation/image_layout/image_tokens = null so no end-to-end contract fixture drives the profile; no export-or-serve proof from this branch (companion recipe in local-inference-lab/hyperflare-recipes; tracked in TODO). Bracketed now requires positive-square patches_per_feature (only MiniMax uses it, ppf=4, unaffected).

#5 [high] PR 483 final verdict: worth merging

Verdict changed from "worth it with changes" to "worth merging".

All six must-fixes from entry #3 verified resolved against head 2b4a31e9 (see entry #4 for citations).

Decisive evidence added this pass:

Charter fit: right layer (12th image-preparation profile at the enumerated extension point, docs/model-contract.md:226-227); additive wire (enum 11, tag 11, field 6 with serde default); inert until a recipe selects it; evidence durable under plain cargo test.

Residual, non-blocking: (a) no export-or-serve proof from this branch (#74 partially met — Ignition validated against 3 real cached checkpoints but no core exported/served; tracked in docs/TODO.txt:330-337 + companion recipe PR); (b) docs/model-preparation.md:321 lists gemma-4-12b but gemma4 profile rejects gemma4_unified — text path unaffected, worth a one-line note; (c) helios/tests/support/contracts/gemma4_frontend.json still null for image fields, so no in-repo contract fixture drives the full path; (d) pyproject.toml:34 pins protobuf>=7.36.2 while main's own runtime_core_pb2.py says 7.36.1 — pre-existing main inconsistency, worth a separate fix, not this PR's.

#7 [high] PR 483 third pass (head ab9a432b): all S1–S5 and nits verified fixed; residual list

Head ab9a432b, base main 27716185, 38 files, +2490/−251.

VERIFIED FIXED AT HEAD (do not re-litigate):

CHARTER FIT: enumerated extension point (12th image-preparation profile; docs/model-contract.md:226-227 "image preparation, image layouts each have an independent enum selector"); precedent padded_grid added by maintainer Luke Alonso (8628b7c5). Wire additive: enum 11, oneof tag 11, VisionCapacity field 6 with serde(default) (model.rs:52-53, build.rs). VisionCapabilities::validate() (model.rs:82-102) accepts 0 and rejects non-multiples of 3; legacy cores decode patch_features=0 => bracketed_patch_features() 1176 (model.rs:72-80).

REAL DEFECTS FIXED (strongest argument): (1) on main, span-declaring Bracketed never emitted data.spans => model.rs:442-465 rejects every such prompt ("image token spans do not match their declared boundaries"); now emitted in layouts/bracketed.rs:57-65 gated on image_tokens.span. (2) on main, conditioned.rs:185-193 _ => 588 meant PatchMerge's 1176-wide patches never satisfied valid_processed, invalidating every cached MiniMax prepared-image record per request; now via ImageProcessor::patch_features().

RESIDUAL NON-BLOCKERS: #74's "prove they export and serve cleanly" half is unmet at merge (no recipe, tracked docs/TODO.txt:331-337); docs/model-preparation.md:321 still lists gemma-4-12b while the profile rejects gemma4_unified; helios/tests/support/contracts/gemma4_frontend.json:16-17,38 still null image fields (now covered by the synthesized core-load test instead); pyproject.toml:34 protobuf pin vs main's own 7.36.1 artifact (pre-existing).

COST SHAPE: ~500 lines product code (gemma4.rs ~210, frontend.py +70, glue) and ~1,900 lines tests/fixtures — evidence-heavy, which is what the charter asks for. packing.rs got simpler (table replaced by isqrt + metadata). No serving-path cost; frontend pool unchanged.

VERDICT: worth merging.

#8 [medium] PR 483 head ab9a432b: doc honesty, call sites, and family precedent

Additional checks at head ab9a432b: