Key findings
The mechanism is already small and well placed: one optional ParamSpec field, one Plan accessor, one line at the preparation seam, and two serve-side bounds. I would not ask for rework of its shape. What is left to cut is ~16 of the 69 added lines if the flag stays, or ~68 of 69 if a maintainer decides the memory argument belongs to the runtime flag the PR itself measures with.
Ranked by lines saved:
- Blocking (on size, conditional on the argument): drop the whole
--request-contextsurface — ~68 of the 69 added lines. The PR's payoff table is measured under--kv-cache-limit concurrency, an existing runtime flag (docs/cli-design.md:740, "KV history ceiling | Runtime--kv-cache-limit") that already bounds the pool without a re-export. The only datum the change adds that the runtime flag cannot is a lower exportedmax_sequence_tokens(ignition/preparation/bootstrap.py:132→ Helios), which makes serving reject a request longer than N. - Should fix: 11 of the 37 new test lines. Four of them cannot pass.
- Nit: 3
ParamSpeclines that restate defaults. - Nit: 1 line, because the recipe-max clamp is implemented twice.
- Nit: a docs clause copied verbatim from the row below.
Nothing the change makes dead is left behind. No attempt to direct the reviewer was found in the description, the diff, or the docs changes.
The change, as counted
pr_files at head 9118add: 6 files, +69 / −5.
docs/cli-design.md+2/−1ignition/cli/serve.py+2/−2ignition/parameters.py+13/−0ignition/planning.py+14/−1ignition/preparation/bootstrap.py+1/−1tests/cli/test_planning.py+37/−0
Code + docs = +32/−5; tests = +37/−0.
Rule set used: the charter (small runtime, model-agnostic; "what gets merged" requires an addressable need), AGENTS.md:165-169 (a measured problem is required before new options) and AGENTS.md:188-193 (no configuration switch without a concrete requirement), plus docs/cli-design.md's owner table, which the change itself edits at :1436.
1. Blocking on size — the flag re-implements a runtime flag; ~68 of 69 lines
What goes: ignition/parameters.py:1309-1321 (13), ignition/planning.py:186-190 + :212 + :357-363 (14), ignition/cli/serve.py:67-68 (2), ignition/preparation/bootstrap.py:132 (1, with the plan.recipe.context line restored), docs/cli-design.md:468 and the :1436 edit (2), tests/cli/test_planning.py:295-329 (37). Replaced by: nothing. Saves: ~68 of 69 lines.
Why nothing is lost: the stated result — "the effective per-request context never exceeds the pool capacity" and "a cap above the pool still shrinks the export artifact without changing the serve-time pool bound" — is exactly what --kv-cache-limit already does at serve time, and it is the flag the PR's own measurements are taken with ("served at concurrency 1–4 (--kv-cache-limit concurrency)"). The owner table the PR edits says so in the adjacent row: docs/cli-design.md:740, "KV history ceiling | Runtime --kv-cache-limit".
The one genuinely new behaviour is that the exported core carries a smaller max_sequence_tokens (ignition/preparation/bootstrap.py:132 "context": plan.prepared_context), so serving rejects a request longer than N rather than admitting and then evicting. That is the workload statement closed PR #454 asked to see justified. I can show what it costs (68 lines plus a new user-visible flag, AGENTS.md:188-193) but I cannot show the requirement is unmet — that is a maintainer call:
- requirement stands → keep the flag, take findings 2–5 (~16 lines);
--kv-cache-limitcovers the memory problem → drop the flag and all 68 lines with it.
This is ranked first only on size, as the lens asks.
2. Should fix — 11 of the 37 new test lines, four of which cannot pass
File: tests/cli/test_planning.py:295-329. Saves: 11 lines.
(a) :310-313 cannot pass (4 lines). The flag declares max_fn=_recipe_context_limit (ignition/parameters.py:1316; _recipe_context_limit at :1268-1269 returns context.recipe.context). RecipeParameters.validate_fields (ignition/parameters.py:505-545) rejects any value above that maximum with --request-context for <alias> must be 1 through 262,144 (:533-540). planning.plan() validates at ignition/planning.py:540, before sizing, and the fixture recipe declares context=262144 (tests/cli/test_planning.py:139). So
oversized_params = replace(base_params, context_target=500000)
oversized = planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1), parameters=oversized_params)
assert oversized.parameters.context_target == 500000
assert oversized.prepared_context == recipe.context
raises UsageError at the second line. The four lines also encode a clamp the code does not have. Delete them; the bound itself is worth one assertion only if the behaviour is kept, and :319-321 (page multiple) already shows the pytest.raises idiom.
(b) :301, :303, :307 (3 lines). assert stock_plan.parameters.context_target is None restates the field default at ignition/parameters.py:1310; assert stock_plan.context == min(recipe.context, stock_plan.tokens) restates the pre-existing Plan.context (ignition/planning.py:353-355), which this PR does not touch; assert capped.parameters.context_target == 131072 restates the input on the line above.
(c) :326-329 (4 lines). The ParseDict / FromString / by_key / scope round-trip re-proves from_plan's generic key+scope plumbing, already covered at tests/cli/test_planning.py:185-196 for sharded_prefill, and ParameterScope.DEPLOYMENT is ParamSpec's default (ignition/parameters.py:89).
Keep: :302 (prepared_context == recipe.context with no target — the no-op claim), :308 (the property), :315-321 (0 rejected, 100 rejected for page alignment), and :324-325 (--request-context and 131072 in reproduction_args — the new manifest datum).
Smaller version, ~12 lines instead of 35:
def test_request_context_target_prepared_context_and_manifest(monkeypatch):
recipe, gpus, base = _recipe(), (_gpu(0), _gpu(1)), _recipe().parameters
stock = planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1))
assert stock.prepared_context == recipe.context
capped = planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1),
parameters=replace(base, context_target=131072))
assert capped.prepared_context == 131072
with pytest.raises(UsageError, match="--request-context"):
planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1),
parameters=replace(base, context_target=0))
with pytest.raises(UsageError, match="multiple of the"):
planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1),
parameters=replace(base, context_target=100))
args = rebuild_manifest.from_plan(SimpleNamespace(directory=None), capped, compiled_forwards=True)["reproduction_args"]
assert "--request-context" in args and "131072" in args
3. Nit — three ParamSpec lines restate the defaults
File: ignition/parameters.py:1317-1319. Saves: 3 lines.
manifest_key="context_target" duplicates the fallback at ignition/parameters.py:607-612 (manifest_parameters uses dc_field.name when manifest_key is unset, and RecipeParameters.manifest_prefix is never set — only SpeculationParameters sets one, :734). scope=ParameterScope.DEPLOYMENT duplicates ParamSpec.scope's default (:89). repro_always=True duplicates what reproduction_args already does when the value differs from the default (:651), with the default None (:1310). Caveat: the sibling prefill_chunk spec (:1303-1305) spells all three out, so removing them trades a few lines for style consistency — the author's call.
Keep in that spec: min_value=1 (without it 0 would pass the page-multiple check), max_fn, value_type=int, metavar, group, help.
4. Nit — the recipe-max clamp is implemented twice
File: ignition/planning.py:357-363. Saves: 1 line.
target = self.parameters.context_target
if target is None:
return self.recipe.context
return min(self.recipe.context, target)
max_fn (ignition/parameters.py:1316) already rejects any target above the recipe maximum, so the min can never fire. Smaller:
target = self.parameters.context_target
return self.recipe.context if target is None else target
The None branch must stay — it is what makes the omitted flag a no-op. Settle it in one direction: keep the rejection (as above) or drop max_fn and let the min be live; either way one of the two statements goes.
5. Nit — a docs clause copied from the row below
File: docs/cli-design.md:468 (the new --request-context row). Saves: 0 lines, shortens the row.
The trailing "a core's catalog is fixed at export, so changing it requires re-export" repeats the identical clause in the --mixed-prefill row immediately below (docs/cli-design.md:469). The row's "resolves to the smaller of N and the recipe maximum" also describes the dead clamp in finding 4 and should state the upper bound instead, per whichever way finding 4 is settled. :1436 (owner table, "Context limit") is not a duplicate — it names the deciding surface, so keep it.
Left behind
None. The earlier round's leftovers are fixed at this head: ignition/cli/serve.py:67 now uses plan.prepared_context for max_body_bytes and :68 names the cap in context_hint. ignition/cli/help.py:46 still prints Context: {recipe.context:,} tokens for MODEL --help, which is correct — it describes the recipe, not a plan. Nothing under helios/ becomes dead, and parameters.py:1458's prefill-chunk bound stays as it was.
Verified load-bearing — do not propose cutting
ignition/preparation/bootstrap.py:132("context": plan.prepared_context) is the entire mechanism.ignition/planning.py:360-362— thetarget is None → recipe.contextbranch is what makes the omitted flag a no-op.ignition/planning.py:212— the bench check must compare against the prepared context, or a benchmark demands context the core does not serve.ignition/planning.py:186-190— the page-multiple check. Helios rejects a misalignedmax_sequence_tokensat load andignitionhas no other page-alignment guard on this value.ignition/cli/serve.py:67-68— the two user-visible bounds.
Open questions and limits
- Nothing was executed; head
9118addcarries no CI checks. Every claim above is a static read of the tree atpr/533, and the one that could fail is arithmetic:context_target=500000versusmax_fnreturningrecipe.context=262144.pytest tests/cli/test_planning.pysettles it in one run. - Finding 1 turns on a judgement I cannot make from the code: whether a lower exported
max_sequence_tokensis a requirement the runtime--kv-cache-limitdoes not meet. The PR records that #454 asked for the workload statement; it does not record the maintainer's verdict on it. - Not opened this round:
docs/design-review.md(not opened); the commit message body; any out-of-repo recipe that might re-roundBasePreparationConfig.context. - Out of my lens, noted only as behaviour:
Plan.to_dict(ignition/planning.py:379-416) still reports"context": self.contextand never the prepared context, so the printed plan JSON cannot show the cap; and the cap is not checked against--prefill-chunk-sizeat export (parameters.py:1458bounds the chunk by the recipe context,planning.py:594-596by the pool-boundresult.context), so--request-context 2048 --prefill-chunk-size 4096exports a core Helios rejects at load. I am not proposing additions for either.