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:
- One declaration drives everything. A single optional field on the universal
RecipeParametersbase (ignition/parameters.py:1309-1319:flag="--request-context",value_type=int,min_value=1, nomax_fn,manifest_key="context_target",scope=ParameterScope.DEPLOYMENT). The existing dynamic plumbing (add_arguments:353-400,option_arities:402-429,resolve:450-492,validate_fields:505-545,manifest_parameters:596-616) generates the CLI option, the manifest entry and the validation without a line of per-model code. That is exactly the charter's "Keep the runtime small and model-agnostic" and the no-per-model-special-case rule; no Helios change at all. - One accessor, one consumer.
Plan.prepared_context(ignition/planning.py:357-363) returnsrecipe.contextwhen no target is set andmin(recipe.context, target)otherwise; the single behavioural change downstream is"context": plan.prepared_contextincommon_preparation_kwargs(ignition/preparation/bootstrap.py:132), the seam every recipe consumes intoBasePreparationConfig.context(bootstrap.py:33).Plan.context(planning.py:352-355) is untouched, so the pool-extent semantics used by sizing are unchanged. - Compatibility by construction. Omitting the flag makes the value identical to
maineverywhere, satisfying the charter rule "verify that existing data, artifacts, and exported cores still load". No env toggle (AGENTS.md:448-451), no new abstraction or fallback layer (AGENTS.md:188-193). - Scope precedent.
ParameterScope.DEPLOYMENTmatches the other core-affecting capacity field,prefill_chunk(parameters.py:1294-1307), soignition combine/ weight-reuse semantics stay consistent (docs/runtime-core-design.md:385-388). - Evidence rule. The description carries a measured VRAM table on named hardware (RTX PRO 6000 Blackwell, 96 GB, Qwen3.8-27B) and now states the condition on the claim (
--kv-cache-limit concurrency), which is what "Bring real evidence" requires.
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)
- The cap now clamps instead of being rejected. No
max_fnon the field (parameters.py:1309-1319), so an oversize target passesvalidate; the page-multiple check is gated ontarget <= self.recipe.context(planning.py:186-190), so--request-context 500000on 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. - The printed report names the prepared value, not the request.
RecipeParameters.status_partsemitsf"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 nostatus_labelon the field any more, so no raw-value duplicate. This satisfies AGENTS.md:452-456 ("the plan, its printed report ... describe what was prepared"). - The hand-off is tested.
tests/cli/test_planning.py:316-319assertscommon_preparation_kwargs(capped, ...)["context"] == capped.prepared_context == 131072and!= recipe.context; revertingbootstrap.py:132toplan.recipe.contextnow fails the suite (AGENTS.md:194-199). - 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 theprefill_chunk_size <= max_sequence_tokensload gate (helios/src/model/catalog.rs:42-57,helios/src/scheduler.rs:66-73(not opened)), and page alignment ofmax_sequence_tokensis covered byplanning.py:186-190againstcatalog.rs:50-57. - 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_tokensusesprepared_context(planning.py:365-368). - Manifest and reproduction args carry the flag.
reproduction_argshand-emits--request-context Nbefore the base-class loop that skips base-class fields (parameters.py:1483-1484, loop:1491-1495), and the manifest entry comes frommanifest_key/scope(parameters.py:1316-1317); both asserted attests/cli/test_planning.py:329-335. - Multi-host export, serve options, help and docs. Parameters are forwarded to
planning.planon the multi-host path (serve.py:180,193-201);max_body_bytesis sized fromplan.prepared_contextandcontext_hintnames the cap only when it is active (serve.py:67-70);help.py:46labels the recipe context a maximum--request-contextcan lower;docs/cli-design.md:458and:1426document the flag, its admission consequence and that a core's catalog is fixed at export.
Nits (none blocking)
ignition/planning.py:396—to_dictrenames a key instead of adding one. The diff replaces"checkpoint_context": self.recipe.contextwith"prepared_context": self.prepared_context. Onmainthe key ischeckpoint_context(planning.py:383at 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. Searchedcheckpoint_contextacrossflare-cli,tests,docs: no in-repo consumer, so this is reporting fidelity, not compatibility. Emitting both keys is free and keeps the record complete.ignition/planning.py:320-321—demand_pagesstill 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 whilecontext_targetandprepared_contextdescribe the capped one. Low impact (a reported demand, not a bound);min(self.recipe.context, self.prepared_context)would make it agree.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 whentarget <= 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 stillrecipe.context(parameters.py:1301via_recipe_context_limitat:1269) while the plan now rejects abovemin(context, prepared_context)(planning.py:594-597), soMODEL --helpcan accept a chunk the plan then refuses. The new behaviour is the correct one; only the advertisement lags.ignition/parameters.py:1561— missing the module'sNoneguard.context.recipe.contextis dereferenced directly, whereas the rest of the module guards (:270,:716,:1269return None if context.recipe is None else context.recipe.context). A recipe-lessParameterContextwould raiseAttributeError. Harmless today: the only caller isserve.py:271with 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
- Nothing was executed: head 448f70a has no CI checks. The source-level claims above are settled by
pytest tests/cli/test_planning.pyand by an export with--request-context 1024 --prefill-chunk-size 4096(expect a usage error). - Whether the default
--kv-cache-limit memorymode gains any of the 16 GB is unmeasured; only the author's rig can answer it, and it is the one number that would let the description drop the caveat. - Nit 1's fix shape (emit both
checkpoint_contextandprepared_context, or only the former pluscontext_target) is a maintainer call; nothing in-repo depends on either key.
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).