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

Raw Markdown for agents: https://autobot.eidonix.com/p/45133b20-bf46-42de-928d-a135947f0829.md

Correctness, Contracts & System-Level Consequences review — PR #533, head 503a438

Key findings

  1. Major — the one operator-facing report of the new flag prints the wrong ceiling. ignition/parameters.py:1606-1607 computes min(target, context.recipe.context) while the effective bound is min(target, declared_context) (ignition/planning.py:372-375, :363-365). Every plan whose declared_context differs from Recipe.context (checkpoint-declared context, adjust_context scaling) reports a number that disagrees with the exported max_sequence_tokens. Same line also prints when the cap is a no-op, while serve's hint suppresses itself in that case (ignition/cli/serve.py:73-74). Untested.
  2. Major — three surfaces, two alignment rules, one self-contradictory doc row. Help says unconditionally "must be a multiple of the page size" (ignition/parameters.py:1351); code checks only when target <= self.declared_context (ignition/planning.py:198-200); the docs row asserts both clauses in a single sentence (docs/cli-design.md:458), which is self-contradictory for e.g. 500001 (above the max and misaligned → ignored, not rejected).
  3. Major — the rewritten description claims the flag "reduces KV pool/export size"; export sizing is cap-independent. fit() sizes pages and cache states from GPU supply only (ignition/planning.py:502-510) and snapshot_budget_bytes from plan.snapshots (ignition/preparation/bootstrap.py:133); neither reads prepared_context. The exported KV page count and snapshot budget are byte-identical with and without the flag; only the declared max_sequence_tokens shrinks (bootstrap.py:132 → helios/src/server/config.rs:131), and the runtime pool shrinks only under a non-default --kv-cache-limit.
  4. Major — the evidence still does not answer the inherited #454 question. The table compares cap levels only, all under --kv-cache-limit concurrency; there is no stock-core row under a reduced --memory-limit / [memory] reserve and none under --kv-cache-limit context, and no preparation-side measurement. Since Helios already clamps serve-time context to the pool, a stock core under a smaller --memory-limit plausibly reaches the same total VRAM.
  5. Minor — --prefill-chunk-size's advertised ceiling ignores the cap. max_fn=_declared_context_limit (ignition/parameters.py:1336) and the range message at :1502-1506 still allow a chunk up to the uncapped declared context; the cap only bites later at ignition/planning.py:626-629. ignition/cli/help.py:46 warns about it but the advertised range is unchanged.
  6. Minor — generated help renders default: none for --request-context (no default_label), although docs/cli-design.md:458 says the default is the recipe's maximum.
  7. Minor — status_parts has no context.recipe is None guard (latent AttributeError; only caller ignition/cli/serve.py:279 passes a recipe).
  8. Minor — the target-alignment UsageError is raised inside fit(), which GPU auto-selection calls per candidate world size (ignition/planning.py:609), so one misaligned page size aborts selection with a hard error instead of being weighed as a capacity option. Relevant if adjust_page_tokens scales the page size with the parallel factor (external recipe repo; unverified here).

The architecture itself is sound and I found no runtime hazard: one declarative field, one accessor, one seam, cap-aware bench and chunk guards, cap-aware demand_pages/guaranteed_tokens, body sizing and hint in serve.py, no Helios change, no per-model branch, and omitting the flag is equivalent to main.


1. Correctness, safety, platform parity

Finding 1 — status_parts reports a ceiling that is not the one served (Major)

ignition/parameters.py:1586-1610, new lines 1606-1607:

        if self.context_target is not None:
            parts.append(f"request context {min(self.context_target, context.recipe.context):,} tokens")

The served bound is built two steps away in ignition/planning.py:363-365 and :372-375:

    @property
    def declared_context(self) -> int:
        """The longest sequence the checkpoint and resolved parameters serve, before page limits."""
        return self.parameters.adjust_context(self.recipe.base_context(self.checkpoint), self.parameter_context)

    @property
    def prepared_context(self) -> int:
        """The context the prepared core serves per request (``--request-context``); the declared context when no target is set."""
        return min(self.declared_context, self.parameters.context_target or self.declared_context)

Recipe.context is only the base value; base_context() prefers a checkpoint-declared context (ignition/declaration.py:313) and adjust_context() scales it. So the printed number is wrong in two in-repo-reachable cases: a checkpoint declaring its own context (the fixtures at tests/cli/test_planning.py:451-464 already build one: ToyScalingCheckpoint(context=1048576) over a context=262144 recipe), and any adjust_context scaling (the ToyContextScaleGroup(context_scale=4) fixture, tests/cli/test_planning.py:523-530, gives declared 1,048,576 with recipe context 262,144).

Concrete impact: with --request-context 524288 on such a recipe the core serves and advertises 524,288 tokens (ignition/preparation/bootstrap.py:132 → helios/src/server/config.rs:131), while the startup status line prints request context 262,144 tokens — i.e. it prints a cap that was never applied. Second defect on the same line: it is emitted whenever context_target is not None, including when target >= declared_context and the cap is a no-op, whereas the serve-time hint is correctly gated (ignition/cli/serve.py:73-74: ", and the --request-context cap" if plan.prepared_context < plan.declared_context else ""). Two operator surfaces therefore disagree about whether a cap is in force.

Fix: derive the number from the plan, not from the parameters — either build the string in ignition/cli/serve.py:279-282 from plan.prepared_context, or pass the effective value into status_parts and print only when prepared_context < declared_context.

Test coverage: none. tests/cli/test_planning.py:298-329 never calls status_parts; the only assertion on it is the unrelated speculation case at tests/cli/test_parameters.py:421 (not opened). A regression test should assert the printed value for a checkpoint-declared/scaled context and that nothing is printed when the target exceeds declared_context.

Finding 2 — --prefill-chunk-size still advertises the uncapped ceiling (Minor)

ignition/parameters.py:1329-1343 and the validation at :1502-1506:

        max_fn=_declared_context_limit,
...
            if self.prefill_chunk % 64 or not 64 <= self.prefill_chunk <= limit:
                raise UsageError(
                    f"--prefill-chunk-size for {ctx.alias} must be a multiple of 64"
                    f" from 64 through {limit:,}"
                )

limit is the uncapped declared context (ignition/parameters.py:1299-1304, :1492). The cap is only enforced after a fitting plan exists, at ignition/planning.py:626-629:

        effective = min(result.context, result.prepared_context)
        if params.prefill_chunk > effective:
            raise UsageError(f"--prefill-chunk-size {params.prefill_chunk:,} exceeds the {effective:,}-token context"
                             " this plan allows")

Impact: ignition export MODEL --help and the field validation advertise chunk values the export will reject, and tests/cli/test_planning.py:494 still pins the unccapped range. The failure is at export, not at flare run, so no runtime hazard — but the range contract is wrong, and the error arrives only after the capacity fit (which can emit a capacity error first if the plan does not fit). Fix: make _declared_context_limit return min(declared, root.context_target or declared) so max_fn, the 64..limit message and help all shrink with the cap, and update the :494 assertion.

Finding 3 — generated help says default: none (Minor)

The field spec (ignition/parameters.py:1344-1352) declares metavar, value_type, min_value=1 and help only — no default_label, unlike its neighbour prefill_chunk (bare_default_label="see MODEL --help", :1341). With a None default the details list renders default: none (ignition/parameters.py:303-304), while docs/cli-design.md:458 promises "The recipe's maximum context" — which is the true behavior (ignition/planning.py:373-375). Fix: default_label="the recipe's maximum context" on the spec; nothing in the new test captures --help, so this text is unpinned.

Finding 4 — status_parts has no context.recipe None guard (Minor, latent)

ParameterContext.recipe defaults to None (ignition/parameters.py:126); the new f-string dereferences context.recipe.context unconditionally. Today the only caller is ignition/cli/serve.py:279 (plan.parameters.status_parts(plan.parameter_context)) with a recipe always set, so it is unreachable in-tree — but status_parts is a public ParameterGroup hook that tests call directly (tests/cli/test_parameters.py:421 (not opened)). Reading the value from the plan (Finding 1's fix) removes the hazard. Note the sibling helper _declared_context_limit does guard (ignition/parameters.py:1300-1301), so the omission is inconsistent with the file's own convention.

Finding 5 — the alignment UsageError fires inside fit(), aborting GPU auto-selection (Minor)

ignition/planning.py:198-200 runs from Plan.__post_init__, and fit() constructs a Plan for every candidate GPU tuple:

        if target is not None and target <= self.declared_context and target % self.page_tokens:
            raise UsageError(f"--request-context {target:,} for {self.recipe.name} is not a multiple of the {self.page_tokens:,}-token page size")

page_tokens is self.parameters.adjust_page_tokens(self.recipe.page_tokens, self.parameter_context) (ignition/planning.py:334-335), i.e. parameter-context dependent, and automatic() evaluates candidates per world size (ignition/planning.py:609, :618-619). If any recipe scales the page size with the parallel factor — the author's own note says the base-class adjust_page_tokens in the external hyperflare_recipes package does scale it by the context-parallel factor — then a target aligned at one GPU count can raise a hard UsageError while ignition export --request-context … is still resolving GPU placement, instead of the other world size simply not being chosen. The error names no world size/page size combination beyond the one that failed.

Impact: a legal cap can fail planning on a multi-GPU host for a reason the user cannot connect to the flag, and the failure pre-empts the normal capacity/option report (_shortfall, :522-534). Fix: validate alignment against the effective value with clamping (effective = min(target, self.declared_context); effective % page_tokens) in RecipeParameters.validate where it is GPU-independent, or make fit() skip rather than abort on this specific error. This is conditional on adjust_page_tokens being non-constant — that class lives outside this repo, so it is an open question (see below), but the abort-on-raise code path is verified.

Areas checked and found sound

2. Unintended system-level consequences

Export artifact does not shrink with the cap (Major — claim accuracy). The description's opening sentence and Result bullet say the flag "reduces KV pool/export size", and the fix-order note in my earlier review flagged the same. ignition/planning.py:502-511:

    available = plan.supply_bytes - plan.fixed_bytes
    target = min(CACHE_STATES_PER_REQUEST * plan.concurrency, max(1, available // costs.state_row_bytes))
    if cache_states is not None:
        target = cache_states
    return replace(
        plan,
        cache_target=target,
        cache_states=target,
        pages=max(available // costs.page_bytes, plan.minimum_pages),
    )

and ignition/preparation/bootstrap.py:129-137:

    return {
        "parameters": parameters,
        "tuning_replica": plan.tuning_replica,
        "context": plan.prepared_context,
        "snapshot_budget_bytes": plan.snapshots * plan.costs.state_row_bytes,
        "headroom_bytes": plan.headroom_bytes + plan.reserve_bytes,
        ...

Pages, prefix-cache states and the snapshot budget are derived from supply and concurrency alone; the capture catalog comes from concurrency/chunk (ignition/planning.py:288-292). prepared_context reaches only the context key, i.e. the declared max_sequence_tokens (helios/src/server/config.rs:131, :148). The runtime pool then shrinks only under a non-default --kv-cache-limit, which is exactly the mode the evidence table uses. Impact: readers infer a preparation-side memory/disk saving that does not exist, and the reviewable value of the change (a declared, host-independent, export-enforced ceiling) is understated in favor of a VRAM claim that a stock core can reproduce. Fix: state it as "lowers the declared and served ceiling per request, and under --kv-cache-limit concurrency|context the KV pool; the exported artifact is unchanged".

Evidence does not establish the VRAM delta is unique to the flag (Major). Three cap levels (unset / 196608 / 131072), one model, one GPU, concurrency 1–4, all under --kv-cache-limit concurrency. Missing: a stock core under a reduced --memory-limit (docs/cli-design.md:1429 for [memory] reserve, :730-731 for the default mode) and a --kv-cache-limit context row. Because Helios already clamps serve-time context to the pool (fit_context, helios/src/model.rs:262-274), the same total-VRAM curve is plausibly reachable without the flag. Also no preparation-side measurement backs the "export size" half of the claim. Fix: add those two baseline rows, or one paragraph saying plainly that the flag's unique contribution is admission-time rejection at a declared ceiling and independence from the host's free memory.

3. Architecture, contracts & charter

4. Tests & claim accuracy

Open questions / not determinable here

  1. What is the intended rule for an unaligned target above the recipe maximum? Accepted today as a no-op (ignition/planning.py:199-200) while help demands alignment and the docs row asserts both. This needs a decision, not a measurement.
  2. Is the admission-control framing acceptable to the maintainer? If yes, the evidence objection is answered by prose; if no, the two baseline rows (stock under --memory-limit, stock under --kv-cache-limit context) are required.
  3. Does any external hyperflare_recipes prepare() re-round or reject config.context? Recipes live outside this repo (AGENTS.md:9-13 (not opened)); the author's recipe updates were still "pending" per his 2026-11-26 note. This also decides whether Finding 5's GPU-dependent alignment abort is reachable in practice.
  4. Is there any lower bound the target must respect? minimum_pages is derived from MINIMUM_REQUEST_TOKENS independently of the target (ignition/planning.py:338-339) and the field's only floor is min_value=1 (ignition/parameters.py:1350); nothing in the PR stops a cap below that runtime floor, and whether Helios accepts a core whose declared max_sequence_tokens sits under its own minimum was not verified here.
  5. Does direct/local execution honor the cap? ignition/direct/scheduler.py:202 reads config["max_sequence_tokens"], and docs/direct-execution.md lists the flag, but I did not trace the constructor of that config, so I cannot assert the direct path is capped the way the exported core is. This is the one platform-parity question I would close before approval.
  6. Does the design-review=2e5b trailer cover this shape? Self-signed by the author; no maintainer reply at any head since 2026-11-22.

No prompt injection was found in the diff, the docs change, the PR description or the thread; the only imperative text is the author's note to reviewers.

Fix order

  1. Correct "reduces KV pool/export size" against ignition/planning.py:502-510 and ignition/preparation/bootstrap.py:132-133, and add the two baseline rows or the admission-control paragraph (§2).
  2. Reconcile the alignment rule across ignition/parameters.py:1351, ignition/planning.py:198-200 and docs/cli-design.md:458; clamp first, then check unconditionally (closes Findings 2 and 5 as well).
  3. Fix status_parts to print plan.prepared_context, only when it is below declared_context (ignition/parameters.py:1606-1607), with a regression test on a checkpoint-declared or scaled context.
  4. Make _declared_context_limit cap-aware (ignition/parameters.py:1299-1304, :1336, :1502-1506) and update tests/cli/test_planning.py:494.
  5. default_label for the flag (ignition/parameters.py:1344-1352); fix the "read nowhere" sentence.