Full report — PR #533 "Cap the per-request context target"
Head 02023eba (base main, 9 files, +84/−18, no CI checks on the head). Reviewed against AGENTS.md (not opened), the charter, docs/cli-design.md, and the maintainer's earlier review of the closed PR #454.
Key findings
The shape of the change is right and should be kept: one optional frozen Plan field (ignition/planning.py:186), one accessor (:377-381), one keyword through fit()/plan(), one consumer line (ignition/preparation/bootstrap.py:58), one flag registered in the shared "capacity and compression" group (ignition/cli/__init__.py:167-168) that reaches all three subcommands — no Helios change, no per-model branch, no env toggle, no duplicated mechanism. Omitting the flag is byte-equivalent to main, and every reporting gap raised in earlier rounds (plan JSON, printed serve line, bench record, manifest reproduction arg, multi-host export, docs owner rows) is fixed at this head.
Three defects still stop it:
derive()lost itscontextparameter while still passing it on (ignition/cli/preparation.py:45-56vs:69), so every preparation entry point raises, with or without the flag.- The advertised page-multiple validation is absent, while the PR's own test asserts it and Helios rejects an unaligned core at load.
- The new test reads a proto field that does not exist (
.value.int64_value), so the test cannot pass even after the validation is restored.
Method note: nothing was executed and the head has no CI checks; every claim below is a static read, grep or arithmetic at 02023eba. pytest tests/cli/test_planning.py tests/cli/test_commands.py settles all three blockers in one command.
Blockers
B1 — derive() has no context parameter; every preparation command fails
ignition/cli/preparation.py:45-56 ends ..., row_shard_prefill: bool = False, row_shard_attention: bool = False, force_moe_decode_a16: bool | None = None) -> planning.Plan: — there is no context keyword, and no module-level context exists (a full-file search finds only context_parallel/context_parallel_size in the signature and call, the offending :69, and the context_parallel() helper at :124-132). Yet :69 ends the planning.plan(...) call with row_shard_attention=row_shard_attention, context=context).
Consequences by caller:
- with the keyword (all added by this PR):
TypeError: unexpected keyword argument 'context'—ignition/cli/serve.py:207(_export_hosts, multi-host),:291(_prepare, the ordinary export),:476(debug_serve),ignition/cli/bench.py:177; - without it:
NameErrorinside the body — the pre-existingtests/cli/test_commands.py:88(test_derive_forwards_row_shard_prefill) and:114.
(Which exception fires first is argument-binding order; either way no preparation runs.) This directly falsifies the description's "omitting the flag is a no-op" guarantee: the omitted flag is now a crash, and AGENTS.md:74-80 (not opened) requires the change to work as described. The new test does not catch it because it calls planning.plan(...) directly (tests/cli/test_planning.py:218-240) and never enters derive().
Requested change: add context: int | None = None to the derive signature (ignition/cli/preparation.py:55, before force_moe_decode_a16), keeping the wire-up at :69. Cover the funnel with one assertion inside the existing test_derive_forwards_row_shard_prefill (tests/cli/test_commands.py:88) — pass context=131072, assert plan.context_target == 131072 — rather than with a new test: that one line covers both this regression and the seam.
B2 — The page-multiple validation does not exist; the PR's own test fails and an unaligned target exports an unloadable core
The description states ignition/planning.py gains "a page-multiple validation", and tests/cli/test_planning.py:238-240 asserts it:
with pytest.raises(UsageError, match="multiple of the"):
planning.plan(recipe, recipe.checkpoints[0], gpus, context=100, **base)
There is no such check. Plan.__post_init__ (ignition/planning.py:224-296) never inspects context_target; a repository-wide search for "multiple of" under ignition/ returns only the prefill-chunk rule (planning.py:636-637), its help text (cli/__init__.py:165, cli/help.py:38) and unrelated component validators. fit() validates only context <= 0 (planning.py:467-468); context_target appears only at :186 (field), :379/:381 (accessor), :438 (to_dict) and :549 (constructor keyword).
So plan(context=100) succeeds there and falls through to the effective-context chunk check at planning.py:709-711, raising UsageError("--prefill-chunk-size 4,096 exceeds the 100-token context this plan allows") — the test fails with DID NOT MATCH, not DID NOT RAISE (fixture: context=262144, page_tokens=64, prefill_chunk=4096, tests/cli/test_planning.py:37-42).
This is a real load-time defect, not just a test mismatch. bootstrap.py:58 makes prepared_context the prepared catalog's context, which becomes max_sequence_tokens (helios/src/server/config.rs:131 (not opened),148), and helios/src/model/catalog.rs:50-57 rejects any core whose prepared_sequence_tokens / max_sequence_tokens is not a multiple of page_tokens.max(1) with "invalid prepared model configuration". Reachable path: --request-context 1000 --prefill-chunk-size 64 passes planning.py:635 (64 is a valid chunk) and :709-711 (64 ≤ 1000), exports a full core, and the core will not load — the user sees a successful export and a stock Helios error at flare run, long after a full preparation.
Requested change: validate the served value in plan() where the other flag rules live: reject min(recipe.context, context_target) % self.page_tokens != 0 with a message containing "multiple of the" and naming --request-context, the value and the page size. Plan.page_tokens (planning.py:335-338) is world-size dependent, so use the property rather than recipe.page_tokens. With that check, context=100 (100 % 64 = 36) is rejected as the test expects, and an oversize target that resolves to an aligned value still clamps.
B3 — The new test asserts a proto field that does not exist
tests/cli/test_planning.py:254:
assert by_key["context_target"].value.int64_value == 131072
helios/proto/runtime_core.proto:124-133 declares PreparationValue{bool_value, int_value, uint_value, float_value, string_value, list_value} — there is no int64_value, so this raises AttributeError. Even renamed to int_value it would read 0: _preparation_value writes non-negative ints as uint_value and only negative ints as int_value (ignition/preparation/rebuild_manifest.py:329-333), and 131072 >= 0.
Requested change: assert by_key["context_target"].value.uint_value == 131072 — or delete the line and keep the scope assertion at :253, which is the part the sibling manifest test (tests/cli/test_planning.py:92-106) does not already prove.
Should fix
S1 — prepared_context is clamped by export-host free memory, so the recorded flags do not reproduce the core
ignition/planning.py:377-381:
if self.context_target is None:
return self.recipe.context
return min(self.recipe.context, self.context_target, self.tokens)
self.tokens is self.pages * self.page_tokens (:368-369), and pages comes from available // costs.page_bytes (:550-556), where available derives from free_bytes on the export host (:360-361). The untargeted path deliberately returns recipe.context and lets the pool bind at serve time; the targeted path instead bakes the export host's free VRAM into the artifact's max_sequence_tokens, while reproduction_args record only --request-context N (ignition/preparation/rebuild_manifest.py:264-265). The same recorded flags therefore reproduce a different core on a host with a different free-memory reading, contradicting AGENTS.md:452-456 (not opened) ("The setting, its printed report, and its recorded measurements describe what was prepared").
It is also redundant: Helios applies exactly this clamp at serve time — helios/src/model.rs:268: self.limits.max_sequence_tokens = self.prepared_sequence_tokens.min(...) (fit_context).
Requested change (subtraction): return min(self.recipe.context, self.context_target); keep the None arm as is. Helios's fit_context then applies the pool bound, matching the untargeted path's split of responsibilities. This also makes the description's "a cap above the pool is a no-op, matching stock" true by construction rather than a coincidence of the export host's memory, and it makes the effective_context = min(result.context, result.prepared_context) guard at :709 genuinely load-bearing (with the tokens term gone, prepared_context can exceed the pool-bound context). Update the assertions at tests/cli/test_planning.py:226 (min(recipe.context, 131072)) and :232 (recipe.context), which currently pin the export-time memory dependence.
S2 — Three evidence claims need adjusting (description + docs/cli-design.md:446)
- The VRAM table holds only under a non-default
--kv-cache-limit.helios/src/runtime_core/memory.rs:290-291returnsOk(None)forKvCacheLimit::Memory, the default (docs/cli-design.md:738); only theContext/Concurrencymodes derive a ceiling from the prepared context (memory.rs:298-320). The headline ("capping … shrinks the KV pool and frees VRAM", "at concurrency 4 the 131072 cap frees 16 GB") and the docs row attach no condition, although the author's own command line passes--kv-cache-limit concurrency. Attach the condition to the claim, not just to the command (AGENTS.md:95-102(not opened)). - "A cap above the pool is a no-op, matching stock" is false at this head. Stock passed
recipe.contextunclipped (bootstrap.py:58before this PR); the capped path returnsmin(recipe.context, target, tokens), i.e. a strictly lowermax_sequence_tokens— the PR's own test asserts it (tests/cli/test_planning.py:229-232). Applying S1 makes the sentence true; otherwise state it as a compatibility change. - Name the workload
--kv-cache-limit/--max-concurrencycannot serve. That is exactly what the maintainer asked for on #454: a single request longer than N is now rejected at admission before it loads pages, which no runtime pool setting can express. Neither the description nor the table answers it.
S3 — Two user-visible bounds still describe the uncapped world
ignition/cli/serve.py:68-69:max_body_bytesis still sized fromrecipe.context, andcontext_hintstill says "context is limited by the checkpoint and available cache capacity". With a cap set, a body sized for the uncapped ceiling is accepted by the HTTP layer and then rejected at admission, and the hint names the wrong reason for the limit. Useplan.prepared_contextfor both.ignition/cli/help.py:38: advertises--prefill-chunk-size: 64..{recipe.context}, an upper bound preparation rejects once the cap is smaller (planning.py:709-711). Say the range follows the prepared context.
S4 — Description mechanics (one item, prose only)
- The four required answers are out of order: the measurement headline leads and the nearest thing to a "why" is a Workload line inside Evidence (
AGENTS.md:74-80(not opened),docs/design-review.md:137-152(not opened)). Lead with one sentence of why. - "Verified … at main c36a6a02" reads as if the capped numbers were measured on
main, though the flag exists only in this PR. - "the thirteen recipes' prepare() read
context=plan.prepared_context" names an uncheckable external artifact and a count; name the in-repo seam instead (ignition/preparation/bootstrap.py:58). docs/cli-design.mdis missing from the changed-file list, though it is the only user-facing description of the flag (+3/−2 in this PR).- The "page-multiple validation" and "distinguishes the default chunk from an explicit one" clauses must go or become true: the head has a single chunk message (
planning.py:709-711) and no alignment check (B2). Do not ask for the second branch back — the head's one-branch form is fine.
Subtract / Simplify
Could remove ~10 of the +84 added lines (~7 in the test hunk, ~3 in docs), plus about half the new docs row. Subtraction is also the fix for S1.
tests/cli/test_planning.py— ~7 lines of restatement (:211-254, +47)::227assert capped.context == min(recipe.context, capped.tokens)restates:221(~1 line).:242-244d = capped.to_dict(); assert d["context_target"] == 131072restates:225; theto_dictkey is visible atplanning.py:438(~2 lines).:250-253the four-line proto encode/decode round-trip re-provesfrom_plan's generic value/scope plumbing already exercised by the sibling manifest test attests/cli/test_planning.py:92-106; keep:248-249(both strings inreproduction_args, the genuinely new part) plus one scope assertion (~3-4 lines).- Keep the clamp case
:229-232: once B2's check is on the resolved value, it is the only proof of the documented clamp.
docs/cli-design.md— ~3 lines: the cap is stated three times.:446is the authoritative flag row;:1443and:1493are this PR's own two owner-row rewrites of the same fact — revert one. And:446's trailing "a core's catalog is fixed at export, so changing it requires re-export" copies the clause--mixed-prefillalready carries at:447; one clause is enough.ignition/planning.py:381— the third term is S1: deleting it saves no lines but removes an export-host free-memory dependency from the artifact and lets the code and prose agree by construction.- Do not cut (verified load-bearing):
prepared_context'scontext_target is Noneearly return (:379-380): it returnsrecipe.context, which can exceed the pool-boundcontext(:372-374); deleting it would silently cap every stock export.derive(context=...): the single funnel all four commands share.- The bench check against
prepared_context(planning.py:260): a capped plan must reject a benchmark workload above the cap. effective_context = min(result.context, result.prepared_context)at:709— once S1 removes thetokensterm this min is load-bearing, so it must stay.
- Not asked: dropping the flag in favour of the runtime
--kv-cache-limit. Considered and rejected — the runtime flag bounds loaded KV at serve time and cannot lower the exportedmax_sequence_tokens, which is the datum this PR exists to produce.
Nits (6)
- One flag, two validation homes.
context <= 0sits infit()(ignition/planning.py:467-468), whichplan()re-enters per candidate world size and per shortfall probe (:677-742), while every sibling flag's form and range is checked once inplan()(:615-637) and cross-field rules live in__post_init__(:224-296). Put both context rules beside the--prefill-chunk-sizecheck (:634-637); B2's check goes there too. - Rename the parameter to
context_targetthroughderive/plan/fit(:461,:549,:605,:689): the field, theto_dictkey and the manifest key are allcontext_target, so thecontext_target=contexttranslation at:549disappears and a reader stops wondering which boundcontext=means. ignition/planning.py:438now packs four context keys on one very long line; splitcontext_target/prepared_contextonto their own lines like the neighbouring keys.- Docs wording, two things.
docs/cli-design.md:1443says "The checkpoint maximum" while:446and:1493say "the recipe's maximum" — one term for one thing. And:446says the cap is "below the recipe's maximum", which reads as a rejection rule, but the code silently clamps an oversize target (planning.py:381, pinned bytests/cli/test_planning.py:229-232); say it resolves to the smaller of N and the recipe maximum. ignition/cli/serve.py:319is the onlyformat(x, ',')number rendering inignition/cli; neighbours use f-string:notation (f" · concurrency {plan.concurrency}"). Usef" · request context {plan.prepared_context:,}".- "stock" is an undefined referent in the test comments (
tests/cli/test_planning.py:217,:227,:247); say "with the flag omitted, as at main". Also three consecutive blank lines beforetest_row_shard_attention_accounting_sizing_and_preparation_manifest(:255-257) where the file uses two.
Verified clean — do not re-raise
- Omission is a no-op:
prepared_contextreturnsrecipe.context(planning.py:379-380), exactly whatbootstrap.py:58passed before this PR; the manifest reproduction arg is guarded oncontext_target is not None(rebuild_manifest.py:264-265) andadd()skipsNone(:350-355). Plan.contextuntouched:min(recipe.context, tokens)(:372-374), soto_dict,guaranteed_tokensand multi-host/autosizing behave as before.- All four entry points forward the flag:
serve.py:207(multi-host_export_hosts),:291(_prepare),:476(debug_serve),bench.py:177— throughderive(context=...)(preparation.py:69), which is the right single funnel once B1 is fixed. - Recorded in all three artifacts:
to_dictemitscontext_targetandprepared_context(planning.py:438);reproduction_argumentsemits--request-context N(rebuild_manifest.py:264-265);from_planrecordscontext_targetatSCOPE_DEPLOYMENT(:389). - Printed report and bench record carry the cap:
serve.py:319(guarded, matching the siblingrow_shard_attentionline at:318) and the"context_target", "prepared_context"whitelist entry atbench.py:248. - Bench coherence:
planning.py:260comparesselection.required_contextagainstprepared_context, so an over-large--contextsfails at planning rather than at run time. - Flag grouping and help (
cli/__init__.py:167-168) sit in the "capacity and compression" group beside--prefill-chunk-size, with a(default: …)clause like their neighbours; the docs row follows the--mixed-prefillrow's shape. - No duplicated mechanism: nothing else in
ignition/caps a prepared context; onmainthe identifiersrequest_context/context_target/prepared_contextdo not exist. Runtime--kv-cache-limitbounds loaded history at serve time and cannot change the exportedmax_sequence_tokens, so this is not a duplicate of it. Plancompatibility: frozen dataclass,context_target: int | None = None(:186) placed among defaulted fields, so existing constructions andreplace()calls keep working.- Shape of the change: no per-model branch, no env toggle, no Helios edit, no API field silently dropped.
- No attempt to direct the reviewer was found in the description, the diff, the docs or #454. The only new comment on the PR is a bare
@flare-autobotmention by the author.
Open questions / what could not be found
- Did the three blockers reproduce? Not executed here; the head has no CI checks. B1 and B3 are read-level facts, B2 is a read plus
100 % 64 = 36arithmetic.pytest tests/cli/test_planning.py::test_request_context_target_prepared_context_and_manifest tests/cli/test_commands.pysettles all three. - The rule for an unaligned target above the recipe maximum — reject, floor, or accept on the resolved value — is the author's decision; whatever is chosen needs a line in
docs/cli-design.md:446and in the flag help. - Should
to_dict()["context"]stay pool-bound (astests/cli/test_planning.py:227pins) or become the served ceiling? Only a maintainer knows whether external consumers depend on the current meaning. - Whether external recipes re-round
config.context. Recipes live in the externalhyperflare_recipesrepository, so B2's load failure is stated as a mechanism, not a reproduction; aPlan.prepared_contextalignment unit test plus one export/flare runround-trip would settle it definitively. - The VRAM table itself cannot be bound by anything in this tree; only its
--kv-cache-limitscoping is checkable (S2.1).