Conventions report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/19256366-c0fb-4b3f-bd37-dcfa86ee7869.md

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

Head reviewed: e6239855, base main. 8 files, +79/−10. No CI checks on the head commit.

Key findings

Verdict: should-fix issues only — no blockers.

The change already follows the house pattern at every structural level that matters: one optional field on the shared RecipeParameters base (ignition/parameters.py:1309-1320), auto-generated CLI and manifest plumbing, one Plan accessor in the style of the neighbouring derived properties (ignition/planning.py:357-363 next to :352-355), one preparation seam (ignition/preparation/bootstrap.py:132), no per-model branch and no Helios change (charter line 12). The earlier blockers I recorded against this PR — a max_fn that made the documented oversized-clamp unreachable, --request-context missing from reproduction_args, missing page-multiple/prefill bounds, absent status_label, stale doc enumerations, an unconditional context_hint — are all fixed at this head and are not re-reported below.

Two should-fix findings remain, both pure duplication/consistency:

  1. ignition/planning.py:186-190 — the page-multiple rule is hand-written in Plan.__post_init__, duplicating the generic ParamSpec.multiple_of mechanism, and the closest precedent (prefill_chunk) puts its rule in RecipeParameters.validate instead.
  2. ignition/planning.py:366-368, :320-321, :379-416 — the two sibling derived values and the plan JSON still use the uncapped recipe.context, so a capped plan reports uncapped guarantees and the new accessor is the only derived ceiling missing from to_dict.

Plus three nits. Everything below was read in context and verified in the code at this head.


Should fix

1. The page-multiple rule is hand-written in Plan.__post_init__ instead of using the declaration mechanism

File: ignition/planning.py:186-190

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"
    )

What is wrong: ParamSpec already has a first-class multiple_of field (ignition/parameters.py:81) enforced by the shared validator ParameterGroup.validate_fields (ignition/parameters.py:524-532), which emits exactly this rule — "{flag} for {alias} must be a multiple of {multiple_of} from {lo}{hi}" — and also renders "multiple of N" into the --help details automatically (ignition/parameters.py:283-284). This PR re-implements that rule with a bespoke message in a second location.

The precedent to copy: prefill_chunk — the sibling field in the same "capacity and compression" group — declares multiple_of=64 (ignition/parameters.py:1302) and enforces its recipe-dependent bound inside RecipeParameters.validate (ignition/parameters.py:1457-1461), i.e. a static multiple in the spec, the in-recipe bound in the group's own validate. RecipeParameters.validate is run from Plan.__post_init__ via self.parameters.validate(context) at ignition/planning.py:185, so a rule placed there still fires before any sizing work — the same moment, but with the mechanism's consistent message and the for {alias} context.

Why it matters: (a) two sources of truth for one rule — the field's own help text at ignition/parameters.py:1319 ("must be a multiple of the page token count") is also hand-written prose, so the rule now lives in three places (help string, Plan check, --help details that would render it automatically if declared); (b) the error message departs from every sibling flag's message shape, which names the alias (e.g. ignition/parameters.py:1459, :520, :531); (c) a future change to the multiple (say, per-recipe page sizes) must find both homes.

Fix: declare multiple_of on the ParamSpec where the page size is fixed, and/or move the recipe-dependent check into RecipeParameters.validate keyed on ctx.recipe.page_tokens, mirroring prefill_chunk:1457-1461, and delete the check from Plan.__post_init__.

Caveat worth stating in the review thread: the page size is not globally constant — it is adjusted per parameter group by adjust_page_tokens (ignition/parameters.py:571-575, consumed at ignition/planning.py:324-325), which is why the PR needs self.page_tokens rather than a literal. A static multiple_of therefore cannot cover every recipe; that is an argument for the in-validate form keyed on ctx.recipe.page_tokens, not for keeping the logic in Plan.

2. One served ceiling, three names — and the plan JSON still reports the uncapped one

Files: ignition/planning.py:366-368 (guaranteed_tokens), :320-321 (demand_pages), :379-416 (to_dict)

Every consumer of the served ceiling now reads the new accessor: bootstrap.py:132, serve.py:67-70, planning.py:212 (bench check), planning.py:594-597 (prefill bound). But the two sibling derived values on the same Plan still use the uncapped recipe maximum:

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

@property
def guaranteed_tokens(self) -> int:
    return min(self.recipe.context, self.pages // self.concurrency * self.page_tokens)  # :366-368

and to_dict (ignition/planning.py:379-416) emits "context": self.context (:395) and "checkpoint_context": self.recipe.context (:396) plus context_target via param_dict (ignition/parameters.py:667-692, field name fallback at :609-612), but never prepared_context.

Why it matters: with --request-context 131072 against a 262144-token recipe, the plan record serialized to JSON reports guaranteed_tokens: 262144 — a guarantee the prepared core cannot honour (it serves 131072, planning.py:357-363) — while the number the PR exists to introduce is absent from the record. demand_pages is oversized in the same direction (page demand computed against the uncapped context; benign for sizing because it is a demand estimate, but it makes the record internally inconsistent with context). This also means the ceiling has three overlapping names in one record — context, checkpoint_context, context_target — and the one name every runtime consumer uses is missing.

Fix: emit "prepared_context": self.prepared_context in to_dict, and derive guaranteed_tokens (and, if it is meant as a demand estimate at the served context, demand_pages) from self.prepared_context instead of self.recipe.context, so one definition of the served ceiling exists.


Nits

  1. ignition/parameters.py:1316-1317 — manifest_key="context_target" restates the fallback (the dataclass field name is already context_target, ignition/parameters.py:607-612) and scope=ParameterScope.DEPLOYMENT restates the ParamSpec default (ignition/parameters.py:89). Both are redundant. This follows the prefill_chunk precedent (:1303-1304), so it is consistency-neutral — droppable, not wrong.

  2. ignition/planning.py:594 — effective = min(result.context, result.prepared_context) is a third hand-rolled min over the same numbers that context (:352-355) and prepared_context (:357-363) already combine; since prepared_context is itself min(recipe.context, target), the expression is min(recipe.context, tokens, target) spread across two accessors. Folding it into one accessor keeps the ceiling rule in a single place.

  3. ignition/cli/help.py:46 — the epilog line now carries two facts (the context maximum and the page size plus a flag hint) whereas the sibling lines carry one each (ignition/cli/help.py:43-45, :51-60). Minor formatting consistency only.


Verified clean (checked through this lens, no finding)


Open questions / what only a run can settle

Nothing in the PR content attempted to direct me; no prompt-injection material found in the diff, description or docs.