Skip to content

ignition: propagate CLI prog, move image specs to recipes, and harden state.py kernels - #683

Merged
lukealonso merged 1 commit into
mainfrom
unify-ignition-recipe-boundary
Dec 2, 2026
Merged

lukealonso merged 1 commit into
mainfrom
unify-ignition-recipe-boundary

Conversation

@lukealonso

Copy link
Copy Markdown
Collaborator

Why this change is needed

After separating external recipe packs from core ignition, three core/recipe boundary and GPU-safety defects remained in ignition:

  1. ignition.preparation.rebuild_manifest.reproduction_arguments hardcoded 'ignition' as argv[0] even though ignition.cli.main already accepts a caller-supplied prog (for example ignition-jetson in hyperflare-jetson-recipes). External recipe packs therefore recorded unreproducible ignition export ... commands in core manifests.
  2. ignition/preparation/frontend.py hardcoded external recipe model_type strings (inkling2, inkling2_loop, glm5_next, qwen4_exp, mimo_v2), processor class names, and literal token IDs (154854, 154855, 18, 151655). Keeping checkpoint-specific validation tables inside hyperflare-inference couples core ignition to external recipe changes.
  3. All five Triton kernels in ignition/components/state.py (_gather_rows, _gather_rows_three, _scatter_rows, _save_hidden, _request_history) multiplied int32 row/slot indices by row strides without casting to tl.int64, risking signed 32-bit offset overflow on large hybrid continuation pools (115–215 MiB per row). In addition, _scatter_rows baked export-time SLOTS: tl.constexpr instead of reading Helios's dynamic memory_capacity (STATE_ROWS), and allowed writes to reserved null continuation slot 0 (selected >= 0).

This PR keeps core ignition strictly at the 12 Helios-ABI modules in ignition/components/ and introduces no plugin discovery.

What changed

  • CLI prog propagation (ignition/registry.py, ignition/cli/__init__.py, ignition/preparation/rebuild_manifest.py):
    • Before: ignition.cli.main passed prog only to argparse, and reproduction_arguments hardcoded ['ignition', 'export', ...].
    • After: Added active_prog / current_prog ContextVar helpers in ignition/registry.py (defaulting to 'ignition'), bound active_prog(prog) in ignition.cli.main, and updated reproduction_arguments / from_plan to emit [current_prog(), 'export', ...] with an optional prog= override.
  • Recipe-owned ImageProcessorSpec (ignition/preparation/frontend.py):
    • Before: image_settings(config, model, profile, qwen_model_type=...) and prepare_frontend(..., image_profile=..., qwen_model_type=...) branched on hardcoded external recipe profiles and constants.
    • After: Replaced the hardcoded table with a typed ImageProcessorSpec dataclass and core Helios ImageSettings wire-payload validation (_validate_image_payload). image_settings(config, model, spec) and prepare_frontend(..., image_spec=...) validate checkpoint metadata against the recipe-owned spec while preserving the exact Protobuf ImageSettings wire format.
  • state.py kernel hardening (ignition/components/state.py):
    • Before: Pointer arithmetic in _gather_rows, _gather_rows_three, _scatter_rows, _save_hidden, and _request_history did not cast row/slot/column indices to tl.int64, and _scatter_rows checked (selected >= 0) & (selected < SLOTS).
    • After: Cast row, slot, and column indices to tl.int64 across all five Triton kernels. Updated scatter_rows to reject writes to reserved null slot 0 by default (allow_zero=False, with allow_zero=True for 0-indexed non-continuation tables such as KV pages) and to accept an optional memory_capacity int64 device tensor so _scatter_rows enforces Helios's live STATE_ROWS limit dynamically at replay.
  • Tests (tests/components/test_state.py, tests/cli/test_parameters.py, tests/preparation/test_frontend_spec.py):
    • Added unit and CUDA tests covering active_prog manifest emission, ImageProcessorSpec validation and rejection paths, and CPU/CUDA scatter_rows null-slot-0 protection, allow_zero=True, and dynamic memory_capacity.

Claimed benefit and compatibility

  • Expected effect: Eliminates signed 32-bit offset overflow in state.py on large continuation pools, prevents scatter_rows from mutating null slot 0 or dropping writes after Helios dynamically grows STATE_ROWS, records accurate reproduction commands for external recipe CLIs without introducing plugin discovery, and removes external recipe identifiers from core ignition.
  • Compatibility and merge order: Exported Protobuf ImageSettings and model core wire formats are unchanged. Python callers of prepare_frontend / image_settings must pass image_spec: ImageProcessorSpec; merge this PR before the companion PRs in local-inference-lab/hyperflare-recipes and local-inference-lab/hyperflare-jetson-recipes.

Supporting evidence and limitations

  • Ran pytest tests/preparation/test_core_boundary.py tests/preparation/test_frontend_spec.py tests/components/test_state.py tests/components/test_state_gather_fields.py tests/cli with CUDA_VISIBLE_DEVICES=0 FLARE_RUN_CUDA_TESTS=1 on an NVIDIA RTX PRO 6000 Blackwell (SM120): 164 passed, 0 failed, including live CUDA execution of _scatter_rows dynamic memory_capacity, null-slot-0 rejection, allow_zero=True, and _gather_rows.
  • Limitations: Rust crate tests were not run because no Rust files changed. Full model core exports (ignition export + flare run) and multi-GPU TP tests were not run.

Discord: lukealonso

… state.py kernels

After separating external recipe packs from core `ignition`, three core/recipe
boundary and GPU-safety defects remained in `ignition`:
1. `ignition.preparation.rebuild_manifest.reproduction_arguments` hardcoded
   `'ignition'` as argv[0] even though `ignition.cli.main` already accepts a
   caller-supplied `prog` (for example `ignition-jetson` in
   `hyperflare-jetson-recipes`). External recipe packs therefore recorded
   unreproducible `ignition export ...` commands in their core manifests.
2. `ignition/preparation/frontend.py` hardcoded external recipe `model_type`
   strings (`inkling2`, `inkling2_loop`, `glm5_next`, `qwen4_exp`, `mimo_v2`),
   processor class names, and model-specific token IDs (`154854`, `154855`,
   `18`, `151655`). Keeping checkpoint-specific validation tables in core
   forces external recipes to patch `hyperflare-inference` whenever a recipe's
   vision metadata changes.
3. The Triton kernels in `ignition/components/state.py` (`_gather_rows`,
   `_gather_rows_three`, `_scatter_rows`, `_save_hidden`, and
   `_request_history`) multiplied `int32` row/slot indices by row strides
   without casting to `tl.int64`, risking signed 32-bit overflow on large
   hybrid continuation pools (115-215 MiB per row). In addition,
   `_scatter_rows` baked export-time `SLOTS: tl.constexpr` instead of reading
   Helios's dynamic `memory_capacity` (`STATE_ROWS`), and allowed writes to
   reserved null continuation slot `0` (`selected >= 0`).

What changed:
- CLI program-name propagation (`ignition/registry.py`,
  `ignition/cli/__init__.py`, `ignition/preparation/rebuild_manifest.py`):
  - Before: `ignition.cli.main` passed `prog` only to `argparse`, and
    `reproduction_arguments` hardcoded `['ignition', 'export', ...]`.
  - After: Added `active_prog` / `current_prog` `ContextVar` helpers in
    `ignition/registry.py` (defaulting to `'ignition'`), bound `active_prog`
    inside `ignition.cli.main`, and updated `reproduction_arguments` /
    `from_plan` to emit `[current_prog(), 'export', ...]` with an optional
    `prog=` override. No plugin discovery is introduced.
- Recipe-owned image specs (`ignition/preparation/frontend.py`):
  - Before: `image_settings(config, model, profile, qwen_model_type=...)` and
    `prepare_frontend(..., image_profile=..., qwen_model_type=...)` branched
    on hardcoded recipe profiles and model constants.
  - After: Added a typed `ImageProcessorSpec` dataclass and core Helios
    `ImageSettings` wire-payload validation (`_validate_image_payload`).
    `image_settings(config, model, spec)` and
    `prepare_frontend(..., image_spec=...)` now validate checkpoint metadata
    strictly against the recipe-supplied `ImageProcessorSpec` while preserving
    the exact Protobuf `ImageSettings` wire format.
- `state.py` kernel hardening (`ignition/components/state.py`):
  - Before: `_gather_rows`, `_gather_rows_three`, `_scatter_rows`,
    `_save_hidden`, and `_request_history` computed pointer offsets in
    default integer width, and `_scatter_rows` checked
    `(selected >= 0) & (selected < SLOTS)`.
  - After: Cast row, slot, and column indices to `tl.int64` in all five
    Triton kernels. Updated `scatter_rows` to forbid null slot `0` by default
    (`allow_zero=False`, with `allow_zero=True` available for 0-indexed
    non-continuation tables such as KV pages) and to accept an optional
    `memory_capacity` int64 device tensor so `_scatter_rows` reads Helios's
    live `STATE_ROWS` count dynamically at replay time.
- Unit and CUDA tests (`tests/components/test_state.py`,
  `tests/cli/test_parameters.py`, `tests/preparation/test_frontend_spec.py`):
  Added tests covering `active_prog` manifest emission, `ImageProcessorSpec`
  validation and rejection paths, and CPU/CUDA `scatter_rows` null-slot-0
  protection and dynamic `memory_capacity` updates.

Claimed benefit and compatibility:
- Expected to eliminate signed 32-bit offset overflow in `state.py` on large
  continuation pools, prevent `scatter_rows` from corrupting reserved null
  slot `0` or dropping writes after Helios dynamically grows `STATE_ROWS`,
  record accurate reproduction commands for external recipe CLIs without
  introducing plugin discovery, and remove external recipe names and token
  IDs from core `ignition`.
- Wire compatibility: Protobuf `ImageSettings` and exported model core
  formats are unchanged. Python callers of `prepare_frontend` and
  `image_settings` must pass `image_spec: ImageProcessorSpec` (paired updates
  are provided in `hyperflare-recipes` and `hyperflare-jetson-recipes`).

Supporting evidence and limitations:
- Ran `pytest tests/preparation/test_core_boundary.py
  tests/preparation/test_frontend_spec.py tests/components/test_state.py
  tests/components/test_state_gather_fields.py tests/cli` with
  `CUDA_VISIBLE_DEVICES=0 FLARE_RUN_CUDA_TESTS=1` on an NVIDIA RTX PRO 6000
  Blackwell (SM120): 164 passed, 0 failed (including live CUDA execution of
  `_scatter_rows` dynamic `memory_capacity`, null-slot-0 protection,
  `allow_zero=True`, and `_gather_rows`).
- Limitations: Rust crate tests were not run because no Rust files changed.
  Full model core export (`ignition export` + `flare run`) and multi-GPU
  tensor-parallel tests were not run.

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 683.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:kernels GPU kernels and numerical execution. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 2, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The prog propagation and the five state.py Triton kernel hardenings are sound and correctly scoped to the core/recipe boundary, but ignition/preparation/frontend.py regresses Helios wire-contract validation and exposes an extract(image, model) signature that can't absorb in-flight PR #483 without another core edit.

  • Blockers: 0 · Should fix: 3 · Subtract/Simplify: 2 · Nits: 3
Walkthrough
  • CLI prog propagation (ignition/registry.py:27-29, 37-39, 52-61, ignition/cli/__init__.py:364-372, ignition/preparation/rebuild_manifest.py:231, 262-263, 288, 333-336): Adds _ACTIVE_PROG ContextVar (default "ignition"), current_prog(), and active_prog(prog) mirroring active_recipes/source_roots; binds it in ignition.cli.main and emits [program, 'export', ...] in reproduction_arguments/from_plan with an optional prog= override.
  • Recipe-owned ImageProcessorSpec (ignition/preparation/frontend.py:26-68, 138-244, 263-296): Replaces the hardcoded checkpoint/token-ID table (inkling2, glm5_next, qwen4_exp, mimo_v2, etc.) with a frozen dataclass ImageProcessorSpec, prepare_frontend(..., image_spec=...), and core _validate_image_payload covering the 8 IMAGE_PROFILES.
  • Triton state.py kernel hardening (ignition/components/state.py:110-261): Casts row/slot/command/column indices to tl.int64 in _gather_rows, _gather_rows_three, _scatter_rows, _save_hidden, and _request_history; adds scatter_rows(memory_capacity=None) (dynamic device read via HAS_CAPACITY) and allow_zero=False (protects reserved null slot 0).
  • Tests (tests/cli/test_parameters.py:362-368, tests/components/test_state.py:90-152, tests/preparation/test_frontend_spec.py:1-105): Unit coverage for active_prog manifest emission, ImageProcessorSpec validation/rejection and default_preprocessor, plus CPU + gated CUDA tests for null-slot protection, allow_zero=True, and live memory_capacity growth without recompilation.
Merge Risk: Medium · up to 70e84eb
  • Late validation failure on malformed image specs: _validate_image_payload (ignition/preparation/frontend.py:161-183) drops main's Helios-required bounds (position_side == 48 for qwen; 4 <= max_tokens <= 1024 and min_pixels <= 64 MiB for deepseek_row_major), shifting a cheap preparation check into a post-export core-load rejection in Helios.
  • Coordinated external-repo break (loud + silent): Removing image_profile=/qwen_model_type= fails loudly with TypeError in external recipe repos, but changing scatter_rows to default allow_zero=False (ignition/components/state.py:165, 187, 200) silently drops row-0 stores for un-updated external 0-indexed callers (e.g. KV page tables) without raising.
  • No runtime hot-path or wire-format regression: reproduction_args stays wire-compatible with Helios (helios/src/runtime_core/preparation.rs:105-113) and flare inspect (flare-cli/src/inspect.rs:453-472); the state.py changes add no locks, allocations, or host syncs on the CUDA path (one persistent device-scalar load per _scatter_rows program).
Pre-merge checks: ✅ 2 passed · ⚠️ 1 warnings

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@lukealonso
lukealonso merged commit 0fca993 into main Dec 2, 2026
lukealonso added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Dec 3, 2026
`main` in `local-inference-lab/hyperflare-recipes` now requires `ImageProcessorSpec`
and `scatter_rows(..., memory_capacity=...)` from `NVIDIA/hyperflare-inference#683`
(`0fca9938`), while `uv.lock` still pinned `ignition` and `flare-heliopause` to
`d3d0e783`.

Changes (before -> after):
- `uv.lock`: advanced `ignition` and `flare-heliopause` along
  `NVIDIA/hyperflare-inference` `main` from `d3d0e783555c023ba742d53ce7c77833df55d0d0`
  to `c513e46a79f3b6ac510235aaf09bcf055b841958` (including `#683` and `#684`) while
  keeping `flashinfer-python` at `a33c0349` and lock revision `5` unchanged.

Expected effect: fresh `uv sync` installs pull the `ignition` ABI required by `#131`
and `#134`.

Verification: `uv lock --check --offline` passed (105 packages resolved, exit 0). Full
`uv sync` and `flare-heliopause` wheel rebuild were not run in this environment.

Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=6fcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:kernels GPU kernels and numerical execution. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants