Conventions report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/f7d5476e-7926-4406-b338-1dafdaf07b19.md

Conventions-and-duplication review of PR #533 — "Cap the per-request context target"

Head reviewed: 448f70a7, base main, 8 files, +91/−28, no CI checks on the head commit. Lens: conventions and duplication only — each new construct compared with its closest precedent in the repository, plus any existing helper or mechanism it duplicates.

Key findings

The PR is structurally conventional: one optional base RecipeParameters field whose CLI flag, help text, manifest entry and scopes are all generated by the parameter system, a single preparation seam (bootstrap.py:132), no per-model branch and no Helios change (charter line 12), and an explicit reproduction_args emission that the base-class field skip makes necessary. My previous two blockers (silently dropped flag on multi-host export; unrecorded cap) and three earlier should-fixes are all fixed at this head.

Two inconsistencies remain, both of the same kind — a quantity the rest of the plan now takes from prepared_context is still computed the old way in one place:

  1. Should fix — the page-multiple rule is re-implemented by hand in Plan.__post_init__ instead of using ParamSpec.multiple_of and the RecipeParameters.validate precedent.
  2. Should fix — demand_pages is still sized from the uncapped recipe max, so the plan JSON contradicts its own prepared_context.

Plus four nits. Nothing here blocks merge on correctness grounds; the cap does what the description says, and pytest tests/cli/test_planning.py coverage exists for the behaviour (tests/cli/test_planning.py:295-335).


Should fix

1. ignition/planning.py:186-190 — the page-multiple rule is hand-written in Plan.__post_init__ although the declaration mechanism already implements it

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

Duplicates: ParamSpec.multiple_of (ignition/parameters.py:81), enforced in ParameterGroup.validate_fields (ignition/parameters.py:524-532), which already raises "{flag} for {alias} must be a multiple of {N} from {lo}{hi}" and renders "multiple of N" into --help details (:283-284; and the bare-help path :271-272).

Closest precedent: prefill_chunk (ignition/parameters.py:1294-1308) declares multiple_of=64 (:1302) and puts its recipe-dependent upper bound in RecipeParameters.validate (:1455-1460):

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

That same validate runs from Plan.__post_init__ via self.parameters.validate(context) (ignition/planning.py:185) — the identical moment — and resolve_parameters (ignition/cli/preparation.py:55-59) runs it before any GPU work.

Third home: the field's own help text hand-writes the rule as prose, "cap the prepared per-request context at N tokens; must be a multiple of the page token count" (ignition/parameters.py:1318) — prose that multiple_of would otherwise generate.

Why it matters. The check itself is correct and needed: Helios refuses a misaligned core at load (helios/src/model/catalog.rs:48-57 requires prepared_sequence_tokens and max_sequence_tokens to be multiples of page_tokens), so dropping it would export cores that fail to load. The finding is about where it lives and how it speaks: three sources of truth for one rule, and the message drops the for {alias} clause every sibling flag error carries (parameters.py:520, :531, :539, :1457-1459), so in a multi-recipe or multi-host log the error does not say which model it is about. A future page-geometry change has to find two homes.

Fix. Move the check into RecipeParameters.validate, keyed on ctx.recipe.page_tokens, mirroring prefill_chunk at :1455-1460, and delete planning.py:186-190. Caveat worth stating in the code: the page size is per-plan (adjust_page_tokens, parameters.py:571-575, consumed at planning.py:324-325), so a static multiple_of cannot cover every recipe — which is precisely why the in-validate form, not the declarative form alone, is the right precedent.

2. ignition/planning.py:319-321 — demand_pages is the last derived value still sized from the uncapped recipe max

@property
def demand_pages(self) -> int:
    return self.concurrency * (self.recipe.context // self.page_tokens)

Every neighbouring derived value now uses the capped extent: context (:352-355), prepared_context (:357-363), guaranteed_tokens (:366-368), the bench check (:212), the prefill bound (:594) and the preparation seam (ignition/preparation/bootstrap.py:132). demand_pages alone reads self.recipe.context.

With --request-context 131072 on a 262144-token recipe, the plan JSON reports demand_pages at roughly twice the served extent, directly beside "context", "prepared_context", "guaranteed_tokens" and "tokens" (planning.py:395-411) that all describe the capped plan. That JSON is printed for humans and recorded for measurements — serve.py:206/:435 and bench.py:194 — so the inconsistency lands in exactly the artifact used to explain the memory payoff table in the PR description.

Scope of impact. Record-correctness only, not runtime or compatibility: demand_pages has exactly two references in the repository (planning.py:320 definition, :407 the to_dict key), so nothing consumes it for sizing. That is also why it is "should fix" rather than blocking.

Fix. Derive it from prepared_context, so the plan keeps one definition of the served ceiling.


Nits

N1. ignition/parameters.py:1560-1561 — hand-rolled status line instead of the status_label mechanism

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

sits immediately after the generic status_label loop (:1554-1559) that consumes ParamSpec.status_label (parameters.py:98) — the mechanism the sibling base fields use for exactly this purpose (roce_ring :1366, roce_chain :1375). status_label receives only the value, so it cannot compute the clamp without ParameterContext; that is a real reason for the escape hatch, but the consequence is that the same min(target, recipe.context) expression now exists three times: planning.py:362-363 (prepared_context), parameters.py:1561 (status line) and planning.py:594 (the prefill bound's effective). One accessor would do; the printed line could read the plan's value rather than recompute it.

N2. ignition/parameters.py:1316-1317 — redundant spec kwargs

manifest_key="context_target" restates the fallback key already derived from the field name (parameters.py:607-612), and scope=ParameterScope.DEPLOYMENT restates the ParamSpec default (:89). Consistency-neutral — it copies prefill_chunk :1303-1304 — so droppable, not wrong.

N3. docs/cli-design.md:458 vs ignition/parameters.py:1318 — the two descriptions of one flag's constraints disagree in coverage

The docs row documents the clamp and the admission consequence but not page alignment; the --help text states alignment only. The adjacent --prefill-chunk-size row does document its alignment rule (cli-design.md:457, "aligned to the recipe's chunk alignment"), so the sibling precedent covers both. Fix by folding alignment into the row, or letting multiple_of render it automatically in help per Should fix 1.

N4. docs/direct-execution.md:53-57 — one stale hand-maintained flag enumeration

The passage enumerates the preparation flags that "apply as they do without --direct" (--max-concurrency, --prefill-chunk-size, --mtp-draft-tokens, --no-mtp-adaptive-verification, --no-mtp, --no-context-parallel, --no-stream-overlap, --no-compile) and does not mention --request-context, although the cap does apply there: bootstrap.py:132 sets BasePreparationConfig.context (bootstrap.py:33), which the --direct path reads via ignition/direct/scheduler.py:110 (context=config["max_sequence_tokens"]). Low severity — the sentence is illustrative and the flag is documented in the preparation table — and this PR's own fix elsewhere was to delete exactly this kind of list in favour of a pointer to RecipeParameters (docs/cli-design.md:446-453, docs/preparation-development.md:17-19), so the consistent fix is to delete or delegate this list too.


Followed the established pattern — checked in context, no finding


Open questions / not settleable by reading

  1. The test suite was not executed at this head and there are no CI checks, so tests/cli/test_planning.py:295-335 is verified only by reading. pytest tests/cli/test_planning.py -k request_context would settle it.
  2. Whether any shipped recipe's adjust_page_tokens actually changes the page size (parameters.py:571-575) decides whether Should fix 1's fix must stay in validate rather than becoming a static multiple_of; I read the mechanism but did not enumerate every recipe.
  3. demand_pages intent — whether the key is meant to describe the uncapped recipe demand on purpose. No consumer exists to say; a maintainer note on the key's contract would settle whether Should fix 2 is a bug or a documentation gap.

No prompt-injection material was found in the diff, the description or the docs.