Architecture report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/1b6aba5b-278e-4c20-93ea-a260a8195827.md

Architecture & scope review — PR #533 "Cap the per-request context target"

Head reviewed: 448f70a (rebased onto #545's compositional RecipeParameters), 8 files, +91/−28.

Key findings

Verdict: no blocking issues and no should-fix items at this head. Four nits.

The change belongs in this repository and the approach is right, so it should be kept as designed:

I found no instruction-injection attempt in the PR body, comments or diff.

Previously raised issues: all fixed at this head (verified in code, do not re-raise)

  1. The cap now clamps instead of being rejected. No max_fn on the field (parameters.py:1309-1319), so an oversize target passes validate; the page-multiple check is gated on target <= self.recipe.context (planning.py:186-190), so --request-context 500000 on a 262,144-context recipe is a no-op that resolves to 262,144. The PR's own clamp case (tests/cli/test_planning.py:311-314) is consistent with the code.
  2. The printed report names the prepared value, not the request. RecipeParameters.status_parts emits f"request context {min(self.context_target, context.recipe.context):,} tokens" (parameters.py:1560-1561) and that list builds the "Select GPUs" line (ignition/cli/serve.py:270-274). There is no status_label on the field any more, so no raw-value duplicate. This satisfies AGENTS.md:452-456 ("the plan, its printed report ... describe what was prepared").
  3. The hand-off is tested. tests/cli/test_planning.py:316-319 asserts common_preparation_kwargs(capped, ...)["context"] == capped.prepared_context == 131072 and != recipe.context; reverting bootstrap.py:132 to plan.recipe.context now fails the suite (AGENTS.md:194-199).
  4. The cap cannot produce a core Helios refuses at load. Prefill chunk is bounded by min(result.context, result.prepared_context) (planning.py:594-597), covering the prefill_chunk_size <= max_sequence_tokens load gate (helios/src/model/catalog.rs:42-57, helios/src/scheduler.rs:66-73 (not opened)), and page alignment of max_sequence_tokens is covered by planning.py:186-190 against catalog.rs:50-57.
  5. Bench and guarantee use the cap. selection.required_context > min(self.context, self.prepared_context) (planning.py:212) is pool-aware: a small pool still rejects selections the core cannot serve, while an uncapped plan is unaffected. guaranteed_tokens uses prepared_context (planning.py:365-368).
  6. Manifest and reproduction args carry the flag. reproduction_args hand-emits --request-context N before the base-class loop that skips base-class fields (parameters.py:1483-1484, loop :1491-1495), and the manifest entry comes from manifest_key/scope (parameters.py:1316-1317); both asserted at tests/cli/test_planning.py:329-335.
  7. Multi-host export, serve options, help and docs. Parameters are forwarded to planning.plan on the multi-host path (serve.py:180,193-201); max_body_bytes is sized from plan.prepared_context and context_hint names the cap only when it is active (serve.py:67-70); help.py:46 labels the recipe context a maximum --request-context can lower; docs/cli-design.md:458 and :1426 document the flag, its admission consequence and that a core's catalog is fixed at export.

Nits (none blocking)

  1. ignition/planning.py:396 — to_dict renames a key instead of adding one. The diff replaces "checkpoint_context": self.recipe.context with "prepared_context": self.prepared_context. On main the key is checkpoint_context (planning.py:383 at main). The plan JSON (serve.py:206,435; bench.py:194) therefore loses the recipe's declared maximum, and the two facts differ once a cap is set. Searched checkpoint_context across flare-cli, tests, docs: no in-repo consumer, so this is reporting fidelity, not compatibility. Emitting both keys is free and keeps the record complete.
  2. ignition/planning.py:320-321 — demand_pages still sizes from the recipe. self.concurrency * (self.recipe.context // self.page_tokens). With a cap set, the demand row in the same plan document describes the uncapped world while context_target and prepared_context describe the capped one. Low impact (a reported demand, not a bound); min(self.recipe.context, self.prepared_context) would make it agree.
  3. ignition/parameters.py:1318 — help under-describes the check. "must be a multiple of the page token count" reads as unconditional, but the check binds only when target <= recipe.context (planning.py:187); an oversize unaligned value is accepted as a no-op. One clause ("ignored above the recipe maximum") closes the gap. The related case: --prefill-chunk-size's advertised bound is still recipe.context (parameters.py:1301 via _recipe_context_limit at :1269) while the plan now rejects above min(context, prepared_context) (planning.py:594-597), so MODEL --help can accept a chunk the plan then refuses. The new behaviour is the correct one; only the advertisement lags.
  4. ignition/parameters.py:1561 — missing the module's None guard. context.recipe.context is dereferenced directly, whereas the rest of the module guards (:270, :716, :1269 return None if context.recipe is None else context.recipe.context). A recipe-less ParameterContext would raise AttributeError. Harmless today: the only caller is serve.py:271 with a plan's context, which always has a recipe.

Evidence scoping (already stated in the description; recorded so the claim is not overstated)

The measured table is real and is the kind of evidence the charter requires, and the description now carries its condition: the pool savings hold under the non-default --kv-cache-limit concurrency, where the pool is sized as M × prepared context. Under the default memory mode page_ceiling derives no ceiling (helios/src/runtime_core/memory.rs:284-331) and export-side sizing is unchanged (fit sizes pages from free memory, planning.py:435-480), so the cap's effect there is admission control only. At serve time Helios's fit_context clamps the effective context to the physical pool (helios/src/server/config.rs:131-148,225, helios/src/model.rs:261-273), so a cap above the pool shrinks the artifact without raising the runtime bound — which the description says explicitly and correctly.

Doc edits checked (no finding)

Replacing the enumerated universal-field list with a pointer to RecipeParameters (docs/cli-design.md:446-453, docs/preparation-development.md:14-22) is disclosed in the description and stops the list drifting against the compositional rewrite in #545; it is in line with AGENTS.md:207 rather than a weakening of documentation.

Open questions / limits of this review

Coverage

All eight changed files were read in context through this lens — ignition/parameters.py, ignition/planning.py, ignition/cli/serve.py, ignition/cli/help.py, ignition/preparation/bootstrap.py, docs/cli-design.md, docs/preparation-development.md, tests/cli/test_planning.py — plus the unmodified downstream consumers that give the change its meaning: ignition/preparation/rebuild_manifest.py:253-312, ignition/preparation/runtime_core.py:332, helios/src/server/config.rs:131-148,225, helios/src/model.rs:261-273, helios/src/model/catalog.rs:42-57, helios/src/scheduler.rs:66-73 (not opened), helios/src/runtime_core/memory.rs:284-331, ignition/direct/scheduler.py:110 (not opened).