Review — PR #533 "Cap the per-request context target" (architecture & scope lens)
Key findings
The design is right and the wiring is nearly complete. Plan.prepared_context is a clean, small addition: it keeps Plan.context stock (ignition/planning.py:363-366), returns recipe.context when no target is set (:371-372), so omitting the flag is byte-equivalent to stock, and it reaches the core through exactly one line — ignition/preparation/bootstrap.py:58 — which flows into Helios as prepared_sequence_tokens / limits.max_sequence_tokens (helios/src/server/config.rs:131, :148) and is enforced at admission. That was the objection on the earlier attempt (#454) and it is genuinely fixed. The VRAM table answers the "hypothetical deployment" objection with measurements.
Two things block, both about the flag not being carried everywhere a preparation setting must be carried:
- One export path silently drops the flag.
_export_hosts(ignition/cli/serve.py:193-206) builds its plan with its ownplanning.plan(...)call that omitscontext=args.request_context, although the flag is registered on every preparation command. A--ranks Nexport accepts the cap and prepares at the recipe maximum. - The setting is invisible in every artifact the project requires to describe preparation.
Plan.to_dictstill reports onlycontext/checkpoint_context;reproduction_argumentsandfrom_planrecord nothing about the target. The printed plan, the benchmark record and the rebuild manifest all describe a core that was not prepared.
Two should-fix items remain: no validation of the target against the page size (the resolved value becomes max_sequence_tokens, which Helios requires to be page-aligned), and no tests for a change in shared planning code that alters exported cores.
Blocking
1. --request-context is silently ignored on the multi-host export path
File: ignition/cli/serve.py:193-206
_export_hosts constructs the plan itself:
plan = planning.plan(model.recipe, model.checkpoint, gpus, selected=tuple(range(len(gpus))),
concurrency=concurrency.value, reserve_bytes=configuration.reserve_bytes,
...
row_shard_prefill=args.row_shard_prefill) # :206 — no context=
The keyword list ends at row_shard_prefill; there is no context=args.request_context. The flag is registered in _preparation_arguments (ignition/cli/init.py:167-170), which every preparation command shares, so ignition export MODEL --ranks 2 --request-context 131072 parses successfully, prints a plan, and prepares a core at the recipe maximum with no warning or error.
The other three paths do thread it: _prepare (ignition/cli/serve.py:289), debug_serve (ignition/cli/serve.py:472) and bench.run (ignition/cli/bench.py:177). The diff touched only the two serve.py call sites, not this one.
Why it matters: the entire benefit claimed in the description is a smaller max_sequence_tokens and a smaller KV pool. A multi-host deployment is a supported shape (AGENTS.md:157-163), and its export is exactly the case where the pool is largest. The user gets a full-context core, no error, and discovers the failure either as absent VRAM payoff or as a request ceiling that is not enforced — the same class of defect #454 was blocked on, confined now to one path. This also violates the project's explicit stance on not accepting a setting and then dropping it (charter line 13, "Don't silently ignore API fields"; AGENTS.md "Be explicit and pin everything", :165-169).
Fix: pass context=args.request_context in the _export_hosts call. A test that asserts every command path reaching planning.plan forwards the parsed target would prevent recurrence, since this is the third distinct caller.
2. The cap is absent from the plan report and the rebuild manifest
Files: ignition/planning.py:389-442; ignition/preparation/rebuild_manifest.py:231-318, :343-454
Three reporting surfaces omit the new setting:
Plan.to_dict(:389-442) emits"context": self.context, "checkpoint_context": self.recipe.context(:430) and has no key forcontext_targetorprepared_context.self.contextstays stock by design (planning.py:363-366), so the plan JSON printed at serve.py:215, serve.py:485 and bench.py:182 reports a context the core does not serve: a core exported with--request-context 131072printscontext: 262144.reproduction_arguments(:231-318) never appends--request-context, so the recorded reproduction command rebuilds a full-context core with differentmax_sequence_tokens. Confirmed by search: the onlycontextoccurrences in that file arecontext_parallel/context_parallel_size(:252-256, :370-374).from_plan(:343-454) records no parameter entry for it either, so nothing in the manifest distinguishes two cores that differ only in prepared context — while AGENTS.md's compatibility rule (:431-444) expects metadata to describe the prepared capacities. bench.py:243-248 also selects a fixed key list fromplan.to_dict()with no context key.
Why it matters: AGENTS.md's Configuration rule states that a setting "is carried through the plan into the recipe's PreparationConfig, so the plan, its printed report, and its recorded measurements describe what was prepared." The prepared context is now a deployment-visible capacity (it sets the request ceiling and the pool size), and it is the one thing this PR changes — yet no artifact records it. This also makes the measured table in the description impossible to reproduce from a package: given two exported cores and their manifests, nothing says which one is the 128K one.
Fix: add context_target (and the resolved prepared_context) to Plan.to_dict; append --request-context in reproduction_arguments when the target is set; add the corresponding parameter entry in from_plan.
Should fix
3. The target is never validated against the page size, though the resolved value must be page-aligned
File: ignition/planning.py:368-373, :459-460
prepared_context is min(recipe.context, context_target, tokens); tokens is pages * page_tokens, and pages is sized from free memory (:536-542). That value becomes the core's max_sequence_tokens (ignition/preparation/bootstrap.py:58 → helios/src/server/config.rs:131, :148). Helios validates on load that both prepared_sequence_tokens and limits.max_sequence_tokens are multiples of page_tokens (helios/src/model/catalog.rs:44-57), returning "invalid prepared model configuration" otherwise.
fit validates only context > 0 (:459-460). recipe.context and tokens are page-aligned in practice, but a user target is arbitrary: --request-context 100000 with a 64-token page yields a non-aligned max_sequence_tokens, and the visible outcome would be a core that took a long preparation to produce and then fails to load. That the export path reaches this state, rather than clamping, is what the code shows; whether the failure surfaces at load or is rounded somewhere in preparation can only be settled by an export test on SM120.
Separately, prepared_context is clamped by tokens (total pool) rather than guaranteed_tokens (:376-378), so a target above the per-request share still admits one long request while slots are contended — unchanged stock behaviour, but the docs row should say so, since the flag reads like a hard per-request guarantee.
Fix: reject (or round down and report) a target that is not a multiple of the recipe's page size in fit, next to the existing positivity check; state the tokens-versus-guaranteed_tokens clamp in the docs row.
4. No tests for a shared planning change that changes exported cores
File: ignition/planning.py (whole change); tests/cli/test_planning.py
The diff adds no tests. This is core planning code consumed by export, serve, bench and the multi-host path, and it changes what a core declares about itself. AGENTS.md:194-199 requires tests for affected behaviour; tests/cli/test_planning.py (e.g. :71-120) already covers plan resolution and is the natural home for: prepared_context == recipe.context when unset; prepared_context == min(recipe.context, N, tokens) when set; the <= 0 rejection; and the below-chunk message.
That last branch (planning.py:694-700) is currently untested and selects its message on whether prefill_chunk is None, not on whether the user set the target. With the recipe's own chunk it correctly suggests --prefill-chunk-size ... or a larger --request-context; with an explicit --prefill-chunk-size above a low target it reports only the chunk mismatch, which is fine. The branch is only reachable when a target is set below the chunk, since context >= chunk already holds at :621-623 for the stock path — so it is new, reachable code with no coverage.
Nits
- Motivation leans on a charter non-goal. docs/cli-design.md:446 calls
--request-contexta way to buy "concurrency headroom in a memory-constrained multi-model deployment". Multi-model hosting is an explicit Non-Goal requiring maintainer sign-off (charter Non-Goals; AGENTS.md:171-175). The flag itself is a preparation capacity, not hosting, so this is not a violation — but the description should name the single-model workflow the headroom buys (free VRAM for a co-process, or a reserve already expressible at serve time via--memory-limit/[memory] reserve, docs/cli-design.md:845-855, :1414-1418), and the docs row should not present an unsupported workflow as the purpose. - Overlap with existing mechanisms is not argued.
--kv-cache-limit context/concurrency(docs/cli-design.md:738, :828-843) and--memory-limit/[memory] reservealready bound the pool at serve time without re-export, and the earlier review raised exactly this (#454). The measurement setup does reconcile it — the table uses--kv-cache-limit concurrency, so the delta really isconcurrency × prepared_context— but the description would be stronger stating plainly what--kv-cache-limitalone cannot do (lower the core's advertised ceiling, hence the pool the runtime sizes from it).
Verified clean
- The cap reaches the core. bootstrap.py:58 passes
plan.prepared_contextintoBasePreparationConfig.context(bootstrap.py:33); Helios reads it asprepared_sequence_tokens(helios/src/server/config.rs:131) and setslimits.max_sequence_tokens(:148), enforced at admission (server/request.rs:350 (not opened); scheduler.rs:2289 (not opened), :2358). "A request that would exceed the cap is rejected" holds. - Omitting the flag is a no-op.
prepared_contextreturnsrecipe.contextwhen unset (planning.py:371-372) — byte-identical to the previousplan.recipe.context;Plan.contextis untouched;fit/plandefault tocontext=None, so every existing caller, including_export_hosts, behaves exactly as before (which is why finding 1 is a silent drop rather than a crash). - Pool sizing is unchanged by design.
fitstill gives the cache all free memory (:536-542); the cap reaches the pool because the runtime sizes pages from the core's now-smallermax_sequence_tokens(helios/src/runtime_core/memory.rs:631-635 viapage_ceiling). Nothing in the diff misstates this. - Other consumers are unaffected or correctly inherit the cap. serve.py:68 (
max_body_bytes) still usesrecipe.context, correct since rejection happens at admission; the diagnostic capacity clamp (serve.py:538-546) and the--directpath (ignition/direct/scheduler.py:110 (not opened)) inherit the capped value, so direct execution enforces the cap too.prepared_contextis read at exactly two sites: bootstrap.py:58 and the chunk check at planning.py:694. - Validation placement. The positivity check lives in
fit, so it fires on every planning path, not onlyplan;--request-context 0/negative yields aUsageError. Argument placement in the "capacity and compression" group (ignition/cli/init.py:167-170) matches AGENTS.md:452-456.
Open questions / not settled from code
- Whether a non-page-aligned
--request-contextfails at core load, at export, or is silently rounded somewhere in preparation. The load-time validator (helios/src/model/catalog.rs:44-57) and the singlebootstrap.py:58assignment suggest a load-time rejection, but only an export test on SM120 settles it. This is the concrete case behind finding 3. - Whether the maintainers consider the multi-host omission (finding 1) acceptable as a follow-up rather than in this PR; it is a one-line fix at serve.py:206 and should be here.
- Finding 2's fix has a design choice: report the resolved
prepared_context(memory-dependent, but truthful about the core) or the requestedcontext_target(reproducible, but may differ from what was prepared). Both are defensible; reporting both is clearest.