Final review report · NVIDIA/hyperflare-inference #683

Raw Markdown for agents: https://autobot.eidonix.com/p/a0bd62de-1ec7-4754-a38a-d92d63fa2907.md

Recommendation: Changes Requested

The prog propagation and the five state.py Triton tl.int64 / dynamic memory_capacity / null-slot-0 kernel hardenings are technically sound, clean, and directly aligned with the core/recipe boundary. However, ignition/preparation/frontend.py regresses core Helios wire-contract validation on qwen and deepseek_row_major (allowing invalid payloads through full export to fail only at flare run), exposes a narrow extract(image, model) signature that cannot absorb in-flight PR #483 (gemma4) without another core edit, and scatter_rows has a minor CPU/CUDA validation mismatch plus an undocumented silent default change for 0-indexed external callers.

Merge Risk

Level: Medium

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Enforce Helios's wire-level image payload bounds in _validate_image_payload (ignition/preparation/frontend.py:142-203).
    • Verified behavior/impact: On main, image_settings guaranteed position_side == 48 for qwen (main frontend.py:181) and min_pixels == 295936, max_tokens == 1024 for deepseek_row_major (main frontend.py:153-155). In this PR, _validate_positive_int accepts any positive Python int (including values exceeding Protobuf uint32/uint64 range), while Helios hard-rejects position_side != 48 and image_token_id == video_token_id in helios/src/frontend/images/qwen.rs:19-26 (with uint32 position_side at helios/proto/runtime_core.proto:645) and rejects !(4..=1024).contains(&max_tokens) or min_pixels > 64 * 1024 * 1024 in helios/src/frontend/images/deepseek_row_major.rs:13-21. A misconfigured recipe spec therefore passes preparation and full GPU export, failing only when flare run loads the core.
    • Fix: Validate in _validate_image_payload:
      • deepseek_row_major: 1 <= min_pixels <= 64 * 1024 * 1024 and 4 <= max_tokens <= 1024.
      • qwen: position_side == 48, image_token_id != video_token_id, and max_pixels < 2**64 (same uint64 bound on mimo max_pixels).
      • Add unit tests in tests/preparation/test_frontend_spec.py covering each rejection.
  2. Expose snapshot/tokenizer context to ImageProcessorSpec.extract so displaced profile PRs don't require another core edit (ignition/preparation/frontend.py:57, 205, 242, 277-295).
    • Verified behavior/impact: prepare_frontend already has snapshot and parses tokenizer_config.json (not opened) (frontend.py:277), yet image_settings calls spec.extract(image, model) with only the processor sub-dict and config.json (not opened). Open PR #483 (gemma4, pr/483 ignition/preparation/frontend.py:142-167) validates image envelope tokens (image_token, boi_token, eoi_token) against tokenizer_config.json (not opened) and snapshot / "tokenizer.json (not opened)". Landing extract with a 2-argument signature forces an immediate breaking change to ImageProcessorSpec when #483 rebases.
    • Fix: Either pass an optional context object/kwargs (e.g., snapshot and tokenizer_config) into image_settings / spec.extract, or settle the signature explicitly before companion recipe PRs adopt ImageProcessorSpec.
  3. Fix scatter_rows CPU/CUDA memory_capacity rank validation mismatch and document the silent allow_zero=False compatibility impact (ignition/components/state.py:175-189).
    • Verified behavior/impact: Line 176 accepts any tensor with memory_capacity.ndim >= 1 (e.g., shape (1, 2)), which works on CUDA (tl.load(MemoryCapacity) reads element 0) but crashes on CPU at line 186 (int(memory_capacity[0].item()) raises RuntimeError: a Tensor with 2 elements cannot be converted to Scalar). Additionally, changing scatter_rows's default to allow_zero=False silently drops row-0 writes for any un-updated external 0-indexed caller (unlike prepare_frontend, which raises TypeError); the PR's Compatibility & merge-order paragraph only warns about prepare_frontend / image_settings.
    • Fix: Require memory_capacity.ndim == 1 at ignition/components/state.py:176 (matching StateStorage.allocate's 1-D [backed_slots, 0] buffer at :89, or index via memory_capacity.reshape(-1)[0].item()), and explicitly note in the PR Compatibility section that external 0-indexed scatter_rows callers (e.g. KV page tables) must pass allow_zero=True in the companion recipe PRs.

Subtract / Simplify

  1. Collapse requires_preprocessor + default_preprocessor into one knob (ignition/preparation/frontend.py:55-56, 290-294).
    • requires_preprocessor: bool = True and default_preprocessor: str = "preprocessor_config.json (not opened)" split one decision ("which snapshot file to read, or none") across two fields, allowing contradictory states (e.g., requires_preprocessor=False with a custom filename). Replacing both with default_preprocessor: str | None = "preprocessor_config.json (not opened)" (where None skips reading a file and uses {} when preprocessor is None) simplifies the spec and the if/else at frontend.py:290-294.
  2. Table-drive _validate_image_payload and remove _EMPTY_IMAGE_PROFILES (ignition/preparation/frontend.py:37, 154-202).
    • The three non-empty branches repeat identical expected_keys / set(payload) != expected_keys boilerplate alongside a separate _EMPTY_IMAGE_PROFILES frozenset (:37). A small profile→field-validator table (with absent profiles defaulting to {}) eliminates _EMPTY_IMAGE_PROFILES and makes adding the Helios bounds from Should Fix #1 and future profiles concise. (Also consider whether all 9 declarative ImageProcessorSpec validation fields at :46-54 are strictly needed by the companion recipe PRs or whether a smaller core spec + shared _expected helper would be cleaner.)

Nits

Dropped on verification