Correctness and contracts report · NVIDIA/hyperflare-inference #683

Raw Markdown for agents: https://autobot.eidonix.com/p/454dc19c-4fe1-4fdb-9b23-f2f440e1a30b.md

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

Lens: Correctness, Contracts & System-Level Consequences. All citations verified by opening the files at PR head 70e84eb (or main where stated).

Key findings

  1. Blocker/Major — the motivating overflow scenario cannot launch at all. _gather_rows/_scatter_rows still use a 2-D launch whose gridDim.y grows with row width; CUDA's 65,535 cap aborts any row > 64 MiB, so the "115–215 MiB continuation row" case in the description dies with an invalid-configuration error before any index can reach 2^31. docs/TODO.txt:366-367 names this exact open item and the PR neither fixes it nor mentions it.
  2. Major — image-payload validation got weaker and moved from preparation to core load. _validate_positive_int accepts any positive int for position_side and DeepSeek min_pixels/max_tokens; Helios hard-rejects anything but position_side == 48 and max_tokens ∈ 4..=1024, min_pixels <= 64 MiB. ignition export now succeeds on checkpoints flare run refuses, after a full GPU export.
  3. Major — prog propagation is ContextVar-only; production never passes prog=. from_plan has exactly two call sites (ignition/cli/serve.py:237, :338) and both omit prog=, so correctness rests entirely on main() having bound the contextvar. Any direct handler/embedded use silently records ignition export — the same bug class, narrowed.
  4. Major — ImageProcessorSpec.extract has no snapshot access, so the displaced profile PRs cannot be expressed. extract: Callable[[Mapping, Mapping], dict] (frontend.py:57) gets only processor config + config.json (not opened). Both open PRs this refactor replaces (#483 gemma4, #229 muse_glimmer) validate envelope token IDs by opening tokenizer.json (not opened)/tokenizer_config.json (not opened) — each will need another core frontend.py edit after #683.
  5. Major — headline claims are inaccurate. "Keeps core ignition strictly at the 12 Helios-ABI modules" describes a pre-existing invariant (and the count is 13, tests/preparation/test_core_boundary.py:11-25); "recipe-owned" is partial (IMAGE_PROFILES frozenset and the per-profile payload schema stay in core, frontend.py:26-35, 154-202); and two behaviour changes are undisclosed (empty-payload rejection; requires_preprocessor/default_preprocessor).
  6. Minor/Major — scatter_rows(allow_zero=False) is a silent global default change. Existing callers writing destination row 0 now have those writes dropped with no error and no counter; the change lands entirely on external recipe repos, which is the opposite failure mode (silent) from the TypeError used elsewhere in this PR.
  7. Minor — test/evidence gaps. No test exercises the int64 casts' actual precondition (width > 64 MiB digits), three of five kernels, a main(prog=...) → manifest end-to-end path, or requires_preprocessor=False; the new test even pins the core-owned profile frozenset (tests/preparation/test_frontend_spec.py:93).

1. Correctness, Safety & Platform Parity

1.1 Blocker/Major — the int64 hardening is unreachable for the rows the PR cites; gridDim.y ceiling untouched

ignition/components/state.py:101-103

    if source.is_cuda:
        torch.library.wrap_triton(_gather_rows)[(output.shape[0], triton.cdiv(output.shape[1], 1024))](
            source, rows, output, source.stride(0), output.stride(0), rows.stride(0), output.shape[1], 1024)

ignition/components/state.py:182-184

        torch.library.wrap_triton(_scatter_rows)[(source.shape[0], triton.cdiv(source.shape[1], 1024))](
            source, rows, output, active, capacity_tensor, source.stride(0), source.stride(1), output.stride(0),
            source.shape[1], output.shape[0], 1024, memory_capacity is not None, bool(allow_zero))

gridDim.y = ceil(width / 1024); CUDA caps gridDim.y at 65,535 → max row width 65,535 × 1024 = 64 MiB. The PR's own motivation is "115–215 MiB per row"; 225,443,840 B / 1024 = 220,160 > 65,535, so the launch fails with an invalid-configuration error long before selected * SS can approach 2^31 (2^31 / 215 MiB ≈ 10 rows). The open project item is verbatim at docs/TODO.txt:366-367:

 [ ] Guard or stride the 65,535 * 1024 (~64 MiB/uint8 row) gridDim.y ceiling
     in ignition/components/state.py row kernels.

The sibling module already solved this (ignition/components/state_transfer.py:21-23 _MAX_GRID_Y = 65_535 with a strided program_id(1) loop, added in 50c876df / #484) and gather_rows_three shares the same launch shape (state.py:125).

Impact: the claimed benefit ("Eliminates signed 32-bit offset overflow … on large continuation pools") is not observable: on those pools the kernel never runs. Either the overflow fix is defense-in-depth for widths ≤ 64 MiB (fine, but then the description must say so), or the pool sizes are wrong. Fix: stride program_id(1) by tl.num_programs(1) * BLOCK and clamp gridDim.y to _MAX_GRID_Y as state_transfer._copy_rows does, which also makes the int64 casts actually reachable; at minimum reference docs/TODO.txt:366 in the description.

1.2 Major — payload validation relaxed; export succeeds on cores Helios rejects

ignition/preparation/frontend.py:142-145

def _validate_positive_int(value: Any, name: str) -> int:
    if type(value) is not int or value <= 0:
        raise ValueError(f"unsupported image processor {name}")
    return value

used at frontend.py:180 (position_side) and frontend.py:166-167 (min_pixels, max_tokens). Against the runtime contract:

helios/src/frontend/images/qwen.rs:19-26

    pub(super) fn load(settings: &QwenImageSettings, limits: ImageLimits) -> Result<Self> {
        if settings.min_pixels == 0
            || settings.max_pixels < settings.min_pixels
            || settings.position_side != 48
            || settings.image_token_id == settings.video_token_id
        {
            return Err("invalid prepared Qwen image settings".into());

helios/src/frontend/images/deepseek_row_major.rs:13-19

pub(super) fn validate(settings: &DeepseekRowMajorImageSettings) -> Result<()> {
    if settings.min_pixels == 0 || !(4..=1024).contains(&settings.max_tokens)
        || settings.min_pixels > 64 * 1024 * 1024
        || settings.max_width_height_ratio == Some(0)
    {
        return Err("invalid row-major image resize settings".into());

On main these were guaranteed by the hardcoded table: position_side=48 (main frontend.py:181), and DeepSeek took max_image_tokens/min_pixels only after _expected(vision, {..., "max_image_tokens": 1024, "min_pixels": 295936, ...}) (main frontend.py:153-155). Now the bounds are recipe-supplied free-form positives, checked nowhere.

Impact: a recipe bug (e.g. position_side=32, max_tokens=2048, min_pixels=10**9) passes preparation and full GPU export, and only flare run/load fails — a failure moved from a cheap checkpoint-validation step to after the most expensive stage in the pipeline, with the error surfacing in Helios instead of next to the checkpoint. (The image_token_id == video_token_id gap is pre-existing on main, so that one is not a regression.) Fix: encode the runtime bounds in the spec (ImageProcessorSpec range/enum fields for numeric payload values) or in _validate_image_payload (position_side == 48, 4 <= max_tokens <= 1024, min_pixels <= 64 MiB), so preparation fails first.

1.3 Major — prog correctness depends on call-site context, not on the call site

ignition/preparation/rebuild_manifest.py:262-263

    program = current_prog() if prog is None else prog
    return [program, 'export', target, *params.reproduction_args(context)]

ignition/cli/__init__.py:370

        with active_recipes(recipes), active_prog(prog), bind_source_roots(source_roots):

Production call sites — the only two (ignition/cli/serve.py:237 and :338):

                    options['preparation_manifest'] = from_plan(model, plan)

The prog= keyword added by this PR is never used in production. A handler run outside main() (an embedded caller, a test invoking serve._prepare, a recipe CLI calling the handler function directly) silently gets default "ignition" from _ACTIVE_PROG (ignition/registry.py:27-29), i.e. the exact defect being fixed, just narrowed to a different trigger. Fix: thread the name explicitly at both call sites, e.g. from_plan(model, plan, prog=getattr(args, "prog", None)) and let None fall back — then the contextvar is a convenience, not the contract. Also add a main(prog="ignition-jetson") → serve._prepare → manifest end-to-end test; today only the contextvar path is covered (tests/cli/test_parameters.py:362-368).

1.4 Minor/Major — scatter_rows default silently drops row-0 writes

ignition/components/state.py:165-172 (signature + docstring) and :198-203 (kernel):

def scatter_rows(source, rows, destination, active, *, memory_capacity=None, allow_zero=False):
    ...
      ``allow_zero`` defaults to False so continuation-state writes never mutate
      the reserved null slot 0. Pass ``memory_capacity`` (for example
    selected = tl.load(Rows + row).to(tl.int64)
    limit = tl.load(MemoryCapacity).to(tl.int64) if HAS_CAPACITY else SLOTS
    in_bounds = (selected >= 0) if ALLOW_ZERO else (selected > 0)

versus main's (selected >= 0) & (selected < SLOTS). Consequences:

Grep at head found no in-repo production caller of scatter_rows (only tests/components/test_state.py:80, :88, :91, :95, :105, :109, :112, :133, :139, :145), so the breakage is entirely in the two external recipe repos whose merge order the PR asserts — untestable from here.

1.5 Verified sound (no finding)


2. Unintended system-level consequences

  1. Failure blast radius moved later, not smaller (§1.2): a bad ImageProcessorSpec value now costs a full GPU export before it is caught, instead of a JSON validation error. In a multi-rank TP export this is the whole fan-out, not one process.
  2. Silent write loss instead of a loud contract break (§1.4) on the scatter path — the worst failure mode for a kernel whose contract is "preserve all other rows".
  3. Structural blocker for the two in-flight profile PRs (§3.2): after #683, adding a profile requires editing core frontend.py and core tests/preparation/test_frontend_spec.py:93, so the PR's stated decoupling objective is not achieved and the merge order it asserts converts into serial core edits.
  4. No contention, head-of-line blocking, memory amplification, or unbounded retention is introduced: the diff adds one contextvar read per manifest emission and one device-side scalar load per scatter program.

3. Architecture, Contracts & Charter Compliance

3.1 Major — "12 Helios-ABI modules" is a pre-existing invariant, and the count is 13

tests/preparation/test_core_boundary.py:11-25 already pins it before this PR, and :61-63:

def test_ignition_components_keeps_only_helios_abi_modules():
    actual = {py.stem for py in (ROOT / "ignition/components").glob("*.py")}
    assert actual == RETAINED_IGNITION_COMPONENTS

The frozenset holds 13 names (__init__, capacity, completion, engram, flashinfer_sampling, logprobs, ngram_delivery, readiness, sampling, state, state_transfer, vision_delivery, vision_state). The PR adds and removes no component module. The "no plugin discovery" half is true — there is no importlib/entry-point scan, and test_ignition_never_imports_recipes_or_hyperflare_recipes (:39-47) still holds.

3.2 Major — the recipe-ownership contract is incomplete, and its extract signature excludes the displaced workloads

ignition/preparation/frontend.py:57 and :242:

    extract: Callable[[Mapping[str, Any], Mapping[str, Any]], dict[str, Any]] | None = None
    raw_payload = {} if spec.extract is None else spec.extract(image, model)

prepare_frontend reads exactly one processor file (frontend.py:293-295) plus tokenizer_config.json (not opened) (:277), config.json (not opened) (:282) and tokenizer.json (not opened) only inside the DeepSeek-only helper (:250). So a recipe cannot express checkpoint validation derived from the snapshot/tokenizer — exactly what #483 (gemma4, envelope token IDs from tokenizer.json (not opened) + tokenizer_config.json (not opened)) and #229 (muse_glimmer, IDs 200092/200091) do, both inside if profile == ...: blocks in the table this PR deletes. Fix: pass the snapshot (e.g. extract(snapshot, image, model)) and have prepare_frontend hand it over, so the next profile lands as recipe code, not another core edit.

Core knowledge that did not move:

3.3 Minor — undisclosed behaviour changes in the frontend contract

    if profile in _EMPTY_IMAGE_PROFILES:
        if payload:
            raise ValueError(f"image profile {profile!r} takes no payload fields")
        return {}

On main, image_settings returned {profile: {}} regardless (main frontend.py:112, :128, :138, :150, :163). A spec whose extract returns anything for padded_grid/glm/radio/moonvit/deepseek4 now fails.

3.4 Verified wire-compatible (no finding)

reproduction_args is repeated string (helios/proto/runtime_core.proto:95, :191), validated only for non-empty/bounded text (helios/src/runtime_core/preparation.rs:105-113), and rendered generically by flare inspect (flare-cli/src/inspect.rs:453-472 (not opened)). No Rust reader assumes argv[0] == "ignition", no file under helios/proto/ is in the diff, and the emitted ImageSettings dicts for the 8 profiles are shape-identical to main's (frontend.py:161-201 vs main frontend.py:151-203). So the prog change and the payload change are wire-compatible and the "Rust tests not run" disclosure is consistent (no Rust file changed).

3.5 Minor — three unrelated changes in one PR

CLI prog (Python), frontend spec (Python API contract), and Triton kernel hardening (GPU) share no code path, no test file and no risk profile. Bundling a GPU-kernel change with an API-breaking refactor means neither can be merged or reverted independently, and the charter asks specifically for GPU-kernel scrutiny.


4. Tests & Claim Accuracy

4.1 Claim-by-claim

PR-text claim Verdict
"hardcoded 'ignition' as argv[0]" Accurate — main rebuild_manifest.py emitted a literal 'ignition'; prog reached only argparse.
"[current_prog(), 'export', …] with optional prog=" Accurate in code (rebuild_manifest.py:231,262-263,288), unused in production (§1.3).
"removes external recipe identifiers from core" Partial — model_type strings and token IDs are gone; the profile names, the closed frozenset and the per-profile payload schema stay (§3.2).
"preserving the exact Protobuf ImageSettings wire format" Accurate for the 8 representable profiles.
"Eliminates signed 32-bit offset overflow … on large continuation pools" Inaccurate as stated — those pools cannot launch (§1.1); the casts are correct but the scenario is unreachable, and the description's Limitations do not mention it.
"_scatter_rows no longer bakes SLOTS" Accurate — SLOTS survives only as the no-capacity fallback (state.py:199).
"reject writes to reserved null slot 0 by default" Accurate, but the consequence (silent drop for existing row-0 writers) is undisclosed (§1.4).
"dynamic memory_capacity honoured at replay" Accurate (state.py:175-184, :199).
"164 passed, 0 failed on SM120" Self-reported, not reproducible here — no CI checks on 70e84eba.
"Python callers must pass image_spec" Accurate, and a hard break (TypeError, frontend.py:207-208, :268-269).
"keeps core ignition strictly at the 12 Helios-ABI modules" Inaccurate — pre-existing invariant, and 13 not 12 (§3.1).
Undisclosed: empty-payload rejection, requires_preprocessor/default_preprocessor Confirmed undisclosed (frontend.py:55-56, :157-160, :290-295).

4.2 Missing tests (concrete)

4.3 Process / evidence

No CI checks, no reviews, no comments on the head commit; a single self-reported pytest run (RTX PRO 6000, SM120). Disclosed unrun items are honest (no Rust file changed — verified; full export+serve and multi-GPU TP not run), but the overflow arithmetic is unmeasured and presented as an expected effect. docs/design-review.md:124-134 restricts Claude-authored Triton changes; the state.py hunks rewrite four kernel bodies and the description does not state who authored that half — flagged for the reviewer, not asserted as a violation.


Open questions / could not verify

  1. Who authored the Triton half of this PR (design-review principle 14)? The description is silent.
  2. Will #483 / #229 be re-expressed through ImageProcessorSpec, and if so does extract gain snapshot access? Nothing in the PR, issues or comments addresses it — §3.2 says it must.
  3. Are there external scatter_rows callers writing row 0 today? Not enumerable from this repo (no in-repo production caller); the silent-drop default is therefore unverified against real usage.
  4. Does any recipe actually pass pool.memory_capacity (i.e. use the new dynamic path) rather than relying on the SLOTS fallback? The in-repo test and the Helios buffer publication (state.py:89 + Helios writing live [rows, pages]) make it possible; no in-repo caller demonstrates it.
  5. Which pool sizes motivated "115–215 MiB per row" and how were they measured? No benchmark, export log or measurement is offered, and per §1.1 those rows cannot launch today.
  6. Nothing in the searchable window reports either the prog bug or the 32-bit overflow; the PR links no issue.

Bottom line: the intent is right and most of the code is sound (casts complete, wire formats unchanged, no hot-path cost, honest disclosure of unrun checks), but the PR should not merge as described: the state.py benefit is unreachable until the gridDim.y ceiling from docs/TODO.txt:366-367 is addressed, the frontend refactor weakens checkpoint validation into a late runtime failure and its extract contract cannot absorb the two open profile PRs, and prog needs an explicit pass at ignition/cli/serve.py:237/:338 rather than contextvar-only binding.