Full report — PR #533 "Cap the per-request context target"
Head e6239855, base main, 8 files, +79/−10 (docs/cli-design.md +3/−2, docs/preparation-development.md (not opened) +2/−1, ignition/cli/help.py (not opened) +1/−1, ignition/cli/serve.py +4/−2, ignition/parameters.py +14/−0, ignition/planning.py +17/−3, ignition/preparation/bootstrap.py +1/−1, tests/cli/test_planning.py +37/−0). No CI checks on the head; nothing was executed — every claim below is a static read of the cited lines at this head.
Key findings
Recommendation: Changes Requested. No blockers. The shape of the change is right and must not be reworked: one optional field on the universal RecipeParameters base (ignition/parameters.py:1309-1320), which the dynamic CLI/manifest/reproduction-arg plumbing generates without per-model code; one Plan.prepared_context accessor (ignition/planning.py:357-363); one consumer line where recipes learn their extent (ignition/preparation/bootstrap.py:132); no Helios change and no per-model branch; omitting the flag returns recipe.context, so shipped artifacts and exported cores are unchanged.
All three blockers raised against earlier heads are fixed in the code at this head and must not be re-raised:
max_fn=_recipe_context_limitis gone;context_targetdeclares onlymin_value=1(parameters.py:1309-1320), and the alignment check is gated ontarget <= self.recipe.context(planning.py:186-190), so an oversized cap clamps atplanning.py:363exactly asdocs/cli-design.md:468, the accessor docstring and the description promise. The oversized case attests/cli/test_planning.py:310-313(500000 → recipe max) is now reachable.--request-contextis emitted inRecipeParameters.reproduction_args(parameters.py:1484-1485) ahead of the base-class-field skip (:1492-1496); norepro_alwaysremains on the spec.- The prefill-chunk bound uses the served extent (
effective = min(result.context, result.prepared_context),planning.py:594-597), so a cap below the chunk is rejected at export instead of producing a core Helios refuses to load (helios/src/model/catalog.rs:42,48-57).
What remains is one behavioural regression on the default (uncapped) path, a test that never reaches the seam the feature hangs on (and silently depends on FlashInfer), two reporting surfaces that describe the request rather than the artifact, and the description/docs evidence prose.
Blockers
None.
Should Fix
S1 — The bench pre-check got looser on the uncapped path
Where: ignition/planning.py:212 (changed by this PR; main:207 read if selection.required_context > self.context:).
What is wrong: with no cap, prepared_context returns self.recipe.context (planning.py:361-362) while context is min(recipe.context, tokens) (:353-355). So whenever the KV pool cannot hold the full recipe context — precisely the memory-constrained deployments this PR targets — the check now admits a bench selection the prepared core cannot serve. self.context is the correct operand: the served ceiling is fit_context-narrowed to min(prepared_sequence_tokens, (pages − draft_pages) × page_tokens) (helios/src/model.rs:261-273), which for an uncapped plan equals self.context, and that is the value ignition/direct/scheduler.py:110 reads and ignition/bench/runner.py:388-389 enforces ("benchmark case exceeds prepared capacities").
Requested change: if selection.required_context > min(self.context, self.prepared_context): — the same shape the chunk check already uses at :594.
Why: it turns a cheap early rejection into a failure after model download, tuning and graph capture.
S2 — The new test never reaches the seam, and drops the stub its siblings use
Where: tests/cli/test_planning.py:295-329.
What is wrong: revert ignition/preparation/bootstrap.py:132 to plan.recipe.context and every assertion still passes. The test asserts the accessor, the rejection paths and generic manifest plumbing; it never asserts the hand-off into PreparationConfig.context, which is the one behavioural change the PR makes — and AGENTS.md:194-199 requires tests to exercise the affected contract. In addition :295 accepts monkeypatch and never uses it, while :323 calls rebuild_manifest.from_plan, which calls source_identity() (ignition/preparation/rebuild_manifest.py:290,327); that imports flare_heliopause and raises RuntimeError("the preparation environment requires FlashInfer") when FlashInfer is absent (ignition/preparation/source_identity.py:35-41), or when its native data/include/data/csrc trees are missing (:76-81). All three sibling tests that reach from_plan stub it (tests/cli/test_planning.py:159,223,333; tests/cli/test_parameters.py:296), and there is no root conftest.py doing it globally. flashinfer-python[b12x] is a declared dependency (pyproject.toml:25), so in a synchronized environment the call may succeed — but the unused fixture is the tell that the stub was meant to be there, and without it the test silently depends on a GPU preparation environment.
Requested change (also a net shortening — see Subtract 1):
monkeypatch.setattr("ignition.preparation.source_identity.source_identity", lambda: "test-source")
kw = dict(compile_forwards=True, kernel_cache=None, retain_graphs=False)
assert BasePreparationConfig(**common_preparation_kwargs(capped, **kw)).context == 131072
assert BasePreparationConfig(**common_preparation_kwargs(stock_plan, **kw)).context == recipe.context
(pattern: tests/cli/test_commands.py:150-153; common_preparation_kwargs requires kernel_cache and retain_graphs, bootstrap.py:123-137). Keep the two pytest.raises cases (:315-321) and one --request-context/131072 reproduction-arg assertion (:324-325).
Why: that pair locks both the capped and the no-op path and would catch a regression in the single line the feature reduces to. Settled by pytest tests/cli/test_planning.py -k request_context.
S3 — The printed plan reports the requested cap, not the served one
Where: ignition/parameters.py:1318, rendered from the raw field value at :1558 into the Select GPUs line (ignition/cli/serve.py:270-274).
What is wrong: status_label=lambda v: f"request context {v:,} tokens" if v else None receives the raw target; Plan.prepared_context clamps (planning.py:357-363). --request-context 500000 on a 262,144-context recipe prepares a core for 262,144 tokens but prints "request context 500,000 tokens". AGENTS.md:452-456 requires the plan, its printed report and its recorded measurements to describe what was prepared; and a core's catalog is fixed at export (docs/cli-design.md:468), so a user who trusts the report only learns otherwise by re-exporting.
Requested change (subtractive): delete status_label from the spec and emit the clamped part where the recipe is in scope — RecipeParameters.status_parts (parameters.py:1541-1563, which already receives the ParameterContext) — e.g. before the compile workers part:
if self.context_target is not None and ctx.recipe is not None:
parts.append(f"request context {min(ctx.recipe.context, self.context_target):,} tokens")
(keep the ctx.recipe is not None guard, as validate does at :1456).
Why: one surface prints a true number, and the raw request stays visible in the manifest as context_target, so no information is lost.
S4 — The plan record names no served extent, and carries a dead key
Where: ignition/planning.py:395-396, :320-321, :366-368.
What is wrong: to_dict emits "context": self.context (pool-bound) and "checkpoint_context": self.recipe.context — a pre-existing key (present on main:383) with no reader anywhere in the tree — but never prepared_context, the value that becomes max_sequence_tokens through bootstrap.py:132. The two sibling derived values still use the uncapped recipe maximum: demand_pages (:320-321) and guaranteed_tokens (:366-368), so a capped plan serializes a guarantee the prepared core cannot honour. Both feed only to_dict (:407, :411), so changing them is reporting-only.
Requested change: "prepared_context": self.prepared_context in place of the dead "checkpoint_context", and derive guaranteed_tokens (and demand_pages, if it is meant to describe the served extent) from self.prepared_context.
Why: one definition of the served ceiling in the record; net line change zero.
S5 — Description and docs prose: order, evidence scope, one wrong mechanism sentence, one missing consequence
(a) The body runs What Changed → Result → Evidence; the only causal "why" survives as a Workload clause inside Evidence. AGENTS.md:74-80 requires why → what changed → claimed result → evidence, in that order (docs/design-review.md:137-152 (not opened)). Open with one or two sentences of why: the 256K default over-provisions the KV pool, so the desired concurrency does not fit.
(b) The −16 GB result is stated unconditionally, but every row was measured with --kv-cache-limit concurrency; the documented default is memory (docs/cli-design.md:740), and page_ceiling returns Ok(None) for KvCacheLimit::Memory (helios/src/runtime_core/memory.rs:290-292). Export-side sizing does not follow the cap either (fit derives pages from free memory, planning.py:435-480; demand_pages still uses recipe.context). Attach the condition to the Result sentence and to docs/cli-design.md:468, and say what the default mode gains (only the serve-time fit_context clamp).
(c) "fit_context applies min(context, prepared_context)" names the wrong operands: it is prepared_sequence_tokens.min((pages − draft_pages) × page_tokens) (helios/src/model.rs:261-273) — the prepared extent against the physical page pool. Reword: the cap sets an export-time ceiling and never raises the runtime bound.
(d) docs/cli-design.md:468 omits the consequence the description promises: a request whose prompt plus requested output exceeds N is rejected at admission (helios/src/server/request.rs:349-355). The neighbouring --prefill-chunk-size row states its consequence; this one should too.
(e) Table labels: "192k"/"128k" against the recorded 196608/131072 (state once that 128k = 131,072 tokens), and "Total VRAM (GB)" neither says per-GPU/process-wide nor whether it is nvidia-smi total or allocator reserved — the table cannot be reproduced from the text as written.
Subtract / Simplify
Could remove ≈14 of the +79 added lines — 7 in the test hunk, 2 in the spec, 3 in the accessor, 1 in planning, 1 in serve — plus about a third of the new docs prose. Ranked by size:
tests/cli/test_planning.py— ≈7 of the +37 lines. Delete:301(restates the field default,parameters.py:1310),:303(restates the untouchedPlan.context,planning.py:353-355),:307and:312(restate the values passed toreplace()two lines above), and collapse the four-line proto round trip:326-329into one assertion that also checks the recorded value, which:329does not:
assert {(p.key, p.scope, p.value.uint_value) for p in decoded.parameters} >= {
("context_target", proto.PREPARATION_PARAMETER_SCOPE_DEPLOYMENT, 131072)}
Keep :302 (no cap is a no-op), :308, :310-313 (the target <= recipe.context gate's false branch), :315-321 (both UsageErrors) and :324-325 (the reproduction-arg emission).
2. ignition/parameters.py:1316-1317 — 2 lines. manifest_key="context_target" duplicates the field-name fallback (:607-612; RecipeParameters sets no manifest_prefix, :334), and scope=ParameterScope.DEPLOYMENT is ParamSpec's default (:89). Caveat: the sibling prefill_chunk spells both out (:1303-1304), so dropping them is consistency-neutral — not wrong either way.
3. ignition/planning.py:360-363 — 3 lines. Four body lines to one: return min(self.recipe.context, target or self.recipe.context). Safe because min_value=1 makes a resolved target never 0; keep the docstring and the no-op semantics.
4. ignition/cli/serve.py:68-70 — 1 line. Two branches spell out the same prefix:
"context_hint": ("context is limited by the checkpoint and cache capacity"
+ (", and the --request-context cap" if plan.prepared_context < recipe.context else "")),
ignition/planning.py:594— 1 line. Theeffectivelocal exists only to be compared once; inlinemin(result.context, result.prepared_context)into the comparison and the message (judgement call: the doubleminmay read worse).docs/cli-design.md:468— prose. Drop the trailing "a core's catalog is fixed at export, so changing it requires re-export", copied verbatim from the--mixed-prefillrow immediately below (:469); "Command line only" already carries it.docs/cli-design.md:448-451anddocs/preparation-development.md:17-20(not opened) — prose. Two hand-maintained enumerations of the same universal field list, both edited by this PR (the second now strandslock_gpu_clocks,on:19). Replace both with a pointer toignition/parameters.pyso adding a field stops requiring two unrelated doc edits. (docs/cli-design.md:1436is not a duplicate — it names the deciding surface; keep it.)
Do not cut (verified load-bearing): the target is None → recipe.context early return (planning.py:361-362), which makes the omitted flag a no-op and preserves today's pool-bound path; bootstrap.py:132; the bench check (planning.py:212); the alignment check's two guards (planning.py:187) — a one-clause if self.prepared_context % self.page_tokens would reject a stock plan on any recipe whose adjust_page_tokens (parameters.py:571-575) changes the page size, because recipe.context need not be a multiple of the adjusted size; serve.py:67 (max_body_bytes); and the min(recipe.context, target) clamp itself.
Considered and rejected: dropping the whole surface (Subtractive's ≈68 of 79 lines, leaving only the runtime --kv-cache-limit). The runtime flag bounds loaded KV at serve time and cannot lower the exported max_sequence_tokens; the surviving delta — a per-request ceiling independent of the pool, so an over-long request is refused at admission instead of admitted then evicted — is what #454 asked for. Keep the feature; take the ≈14 lines.
Nits (7)
ignition/planning.py:186-190— placement and message shape. The check runs inPlan.__post_init__, re-entered for every candidate world size and shortfall probe (planning.py:577,587,600), so on failure it raises a flag-shaped message before the capacity messageplan()exists to produce; unlike sibling rules it does not name the alias (parameters.py:1454,1459). Keep the guards; consider moving it besideplan()'s chunk check (:594-597).ignition/parameters.py:1319help says "a multiple of the page token count" — "page token count" has no antecedent in--help(the page size appears only in the epilog,ignition/cli/help.py:46(not opened)) — and states no floor, although a cap below--prefill-chunk-sizeis now rejected (planning.py:594-597). Say "page size" and note that lowering the cap below the chunk also needs a smaller chunk.ignition/cli/help.py:46(not opened) now carries two facts on one line (context maximum plus page size plus a flag hint) where sibling lines carry one (:43-45,51-60), and states no floor.- Naming.
context_target(field),--request-context(flag) andprepared_context(accessor) are three names for one number; the docstring atplanning.py:359could name the flag so a reader can join them. docs/cli-design.md— three spellings of one ceiling: "the recipe maximum context" (:468,:1436) and "the prepared context ceiling" (:1486). Pick one, "the recipe's maximum context".- Description table units/metric — state once that 128k = 131,072 tokens and define "Total VRAM" (per GPU or process-wide;
nvidia-smitotal or allocator reserved). See S5(e). docs/preparation-development.md:19(not opened) — the added field pusheslock_gpu_clocks,onto a line of its own inside a prose list; reflow it (or replace the list, Subtract 7).
Verified clean (do not re-raise)
- No-flag equivalence:
prepared_contextreturnsself.recipe.context(planning.py:361-362), exactly the valuecommon_preparation_kwargspassed before this PR (bootstrap.py:132→BasePreparationConfig.context,bootstrap.py:33). - Alignment gating: an above-maximum, unaligned target (500000 on 262144) resolves to the aligned recipe context rather than raising (
planning.py:186-190);100 % 64is still rejected with "not a multiple of the 64-token page size", matchingtests/cli/test_planning.py:319-321;min_value=1produces "--request-context must be a positive integer", matching:315-317. - Manifest plumbing:
omit_nonekeeps an unset cap out of the manifest (parameters.py:604-606); a set cap emitsuint_value(rebuild_manifest.py:270-274); the key is additive, so existing manifests still round-trip. - Multi-host export carries the resolved parameters into
planning.plan(ignition/cli/serve.py:180,193-201). - Serve-side:
max_body_bytesfromprepared_context(serve.py:67);context_hintnames the cap only when it binds (:68-70). - Helios side coherent now that chunk ≤ served extent is enforced at export:
catalog.rs:42,48-57validates page multiples andmax_sequence_tokens <= prepared_sequence_tokens;fit_context(model.rs:261-273) only narrows, so a cap above the pool shrinks the artifact and cannot raise the runtime bound. - Docs:
docs/cli-design.md:449,468,1436anddocs/preparation-development.md:18(not opened) list the flag/field;help.py:46(not opened) labels the recipe context a maximum the flag can lower. - Scope/charter fit: one optional field on an existing frozen dataclass, no env toggle (AGENTS.md:448-451), generated plumbing rather than hand-written registration, no new abstraction or fallback layer, no per-model branch, and a measured memory payoff on named hardware.
- No instruction aimed at the reviewer in the description, comments, diff or docs; the only discussion item is a bare
@flare-autobotmention by the author. No injection material found.
Open questions
- Do the savings survive under the default
--kv-cache-limit memory? Only the author's rig can answer; it is the number that would let the description drop the caveat (S5b). - Does any real recipe's
adjust_page_tokens(parameters.py:571-575) change the page size per world size? If so, the alignment check's placement (nit 1) matters more than it looks. - The commit message body (
git log -1 --format=%B) was not available here, so its four-part compliance is unjudged. - Nothing was executed and the head has no CI checks.
pytest tests/cli/test_planning.pysettles S2; S1 needs a plan withtokens < recipe.contextplus a selection between the two bounds.