Full report — PR #533 "Cap the per-request context target"
Head 448f70a7, base main, 8 files, +91/−28 (docs/cli-design.md +5/−14, docs/preparation-development.md +3/−5, ignition/cli/help.py +1/−1, ignition/cli/serve.py +4/−2, ignition/parameters.py +15/−0, ignition/planning.py +19/−5, ignition/preparation/bootstrap.py +1/−1, tests/cli/test_planning.py +43/−0). Link: https://github.com/NVIDIA/hyperflare-inference/pull/533. No CI checks on the head; nothing was executed — every claim below is a static read of the cited lines.
Key findings
Recommendation: Changes Requested — 0 blockers, 2 should fix, 7 subtractive suggestions, 5 nits.
Keep the design as designed; do not rework it. One optional field on the universal base (ignition/parameters.py:1309-1319: flag="--request-context", value_type=int, min_value=1, no max_fn, manifest_key, scope) from which the parameter system generates the CLI option, the --help row, the manifest entry and the to_dict key (add_arguments :353-400, manifest_parameters :596-616, to_dict :667-692); one accessor (ignition/planning.py:357-363); one consumer seam (ignition/preparation/bootstrap.py:132 → BasePreparationConfig.context, bootstrap.py:33); no Helios change and no per-model branch. Plan.context (planning.py:352-355) is untouched, so pool sizing is unchanged. Omitting the flag returns recipe.context (planning.py:361-362), i.e. main's behaviour, so shipped artifacts and exported cores still load. Issue #454's review asked for exactly this capability ("carry the cap into the core, so that serving rejects longer requests").
Verified fixed at this head — do not re-raise:
- The clamp is live: no
max_fnon the field (parameters.py:1309-1319), the alignment check is gated ontarget <= self.recipe.context(planning.py:186-190), so--request-context 500000on a 262,144 recipe resolves to 262,144; the PR's own case (tests/cli/test_planning.py:311-314) is reachable. - The printed status line carries the clamped value, not the request (
parameters.py:1560-1561, rendered into theSelect GPUsline atignition/cli/serve.py:271), satisfying AGENTS.md:452-456. - The bench pre-check is pool-aware:
selection.required_context > min(self.context, self.prepared_context)(planning.py:212), so an uncapped plan with a small pool still rejects selections the core cannot serve. - The prefill bound uses the served extent (
effective = min(result.context, result.prepared_context),planning.py:594-597), covering the Helios load gateprefill_chunk <= max_sequence_tokens(helios/src/scheduler.rs:66-77(not opened) (not opened)). --request-contextis hand-emitted inRecipeParameters.reproduction_args(parameters.py:1483-1484) ahead of the base-class-field skip (:1491-1495); the manifest then carries it.- Multi-host export resolves the parameters and forwards them (
ignition/cli/serve.py:180,:193-201). guaranteed_tokensnow derives fromprepared_context(planning.py:366-368).- The new test is mutation-sensitive on the seam.
tests/cli/test_planning.py:316-319calls the real seam function and assertskwargs["context"] == capped.prepared_context == 131072, so revertingbootstrap.py:132toplan.recipe.contextmakes the test fail. Two lenses asserted the opposite at this head; that is false — checked. What the test does not do is constructBasePreparationConfig, a coverage gap best closed while shrinking the test (Subtract 1).
Blockers
None.
Should Fix
1 — The plan record now describes two different worlds, and the description says otherwise
Where: ignition/planning.py:396, :320-321, :407.
What is wrong: two halves of one defect.
(a) to_dict replaced main's "checkpoint_context": self.recipe.context (main planning.py:383) with "prepared_context": self.prepared_context (:396). Once a cap is set, the plan document printed by ignition export / multi-host export (serve.py:206, :435), ignition bench (bench.py:194 (not opened) (not opened)) and stored in benchmark results (bench.py:263-266 (not opened) (not opened)) carries context (pool-bound), prepared_context (capped) and context_target, but no recipe maximum at all — a key that existed at main is gone. The PR description presents this as an addition ("Plan.to_dict() emits "prepared_context""), which AGENTS.md:88-94 forbids: the before/after and the material compatibility change must be explicit.
(b) demand_pages is the last derived value still sized from the uncapped recipe maximum, self.concurrency * (self.recipe.context // self.page_tokens) (:320-321), and it is printed in the same document at :407, beside prepared_context, guaranteed_tokens and context that all describe the capped plan. With --request-context 131072 on a 262,144 recipe the record overstates demand by roughly 2× — in exactly the artifact used to explain the PR's memory table.
Requested change (subtractive, net zero lines): derive demand_pages from self.prepared_context // self.page_tokens (:321, line-neutral) and state in the description that prepared_context replaces checkpoint_context. Cheapest complete option if the maintainer wants the recipe maximum preserved in the record: one extra key ("checkpoint_context": self.recipe.context beside :396).
Why: demand_pages has exactly two references in the tree (:320 definition, :407 the key), so this is reporting-only and cannot affect sizing; and a stored benchmark JSON produced before this PR is no longer comparable to one produced after, which the author has to say out loud rather than let a reader infer.
2 — The page-multiple rule is undocumented in the docs row and not attributable in its error
Where: ignition/planning.py:186-190; ignition/parameters.py:1318; ignition/cli/help.py:46; docs/cli-design.md:458.
What is wrong: one rule is stated three ways and enforced a fourth:
- the check rejects
target % self.page_tokens(planning.py:187), whereself.page_tokensis the plan's page (:324-325→adjust_page_tokens,parameters.py:571-575), notrecipe.page_tokens— which is what--helpprints (help.py:46) and what "the page token count" in the help text (parameters.py:1318) names. Latent today (the onlyadjust_page_tokensdefinition in the tree is the base hook,parameters.py:571; external recipes are where the hook system is used,docs/preparation-development.md:30-34), but it is the wrong quantity to name. - the error message (
planning.py:188-190) omits thefor {alias}clause every sibling flag error carries (parameters.py:520,:531,:539,:1457-1459), so in a multi-recipe or multi-host log it does not say which model it is about. docs/cli-design.md:458documents the clamp and the admission rejection but not the alignment rule, so a user who passes--request-context 100000meets an undocumented usage error; the neighbouring--prefill-chunk-sizerow (:457) does state its alignment rule.- the help text states the rule unconditionally although
planning.py:187enforces it only at or below the recipe maximum (an oversize unaligned value is a silent no-op, astests/cli/test_planning.py:311-314asserts). Requested change (words only, no new code): say "page size" inparameters.py:1318; addfor {alias}to the message atplanning.py:189; add one clause todocs/cli-design.md:458— "must be a multiple of the core's page size; a misaligned value is rejected at export, and a value above the recipe maximum is ignored". Do not move the check intoRecipeParameters.validate: the quantity is the plan's page size, whichvalidatedoes not see, soParamSpec.multiple_of/ theprefill_chunkprecedent (parameters.py:1294-1308,:1455-1460) cannot express it — the hand-written check is justified, its wording is not. Why: Helios refuses to load a core whose prepared extent is not a page multiple (helios/src/model/catalog.rs:48-57(not opened) (not opened)), so the export-time rejection is the right behaviour and must stay; the defect is that the user is told the wrong page and, in docs, nothing at all.
Subtract / Simplify
Could remove ≈14 of the +91 added lines, plus ~20 words of duplicated docs prose and one stale paragraph. The section is kept separate so these removals are not crowded out by the other lenses.
tests/cli/test_planning.py— −7 lines of the +43. Delete the assertions that restate their own input or property bodies this PR does not touch::302(context_target is None, the default just constructed),:303and:304(restateplanning.py:361-362/:355),:308and:313(restate thereplace()values two lines above),:319(!= recipe.contextfollows from== 131072and the fixture's 262144 at:139). Collapse the four-line proto round trip:332-335into one assertion that also checks the recorded value, which:335does not (rebuild_manifest.py:270-274(not opened) (not opened) writes ints touint_value):
And put the seam assertion through the config object instead of two redundant comparisons:assert {(p.key, p.scope, p.value.uint_value) for p in decoded.parameters} >= { ("context_target", proto.PREPARATION_PARAMETER_SCOPE_DEPLOYMENT, 131072)}BasePreparationConfig(**common_preparation_kwargs(capped, kernel_cache=None, retain_graphs=False)).context == 131072(pattern:tests/cli/test_commands.py:150-153;tests/cli/test_parameters.py:254(not opened) (not opened)). Keep:301-303's no-cap case,:307/:309,:311-314(the only case exercising the false branch of thetarget <= self.recipe.contextgate),:316-318,:321-327(bothUsageErrors) and:329-331(reproduction_args, the only coverage of the override atparameters.py:1483-1484). Not a saving: inliningcapped_params/oversized_paramsexceeds the file's line width.ignition/planning.py:357-363— −2 lines. The four-line body is one expression:return min(self.recipe.context, target or self.recipe.context). Safe:min_value=1(parameters.py:1315) means a resolved target is never 0, and the docstring plus theNoneearly return stay.ignition/parameters.py:1316-1317— −2 lines.manifest_key="context_target"restates the field-name fallback (:607-612;RecipeParameters.manifest_prefixisNone,:334) andscope=ParameterScope.DEPLOYMENTrestates theParamSpecdefault (:89). Caveat: the siblingprefill_chunkspells both out (:1303-1304), so this is consistency-neutral; the manifest-scope assertion keeps it honest.ignition/cli/serve.py:68-70— −1 line. Two branches restate the same prefix; keep the "only when the cap is active" condition (it is load-bearing, and the siblingdecode_weight_bytesat:72is conditional too):
Do not collapse it to a single always-naming string that mentions a flag the user never passed."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:187-190— −1 line.target % self.page_tokensalready rejects 0 andmin_value=1forbids it, so drop!= 0and let the message be one line. Keep both guards and theself.page_tokensoperand (see Should Fix 2).ignition/parameters.py:1560-1561— remove a duplicated rule (0 lines saved, one definition).min(self.context_target, context.recipe.context)is the third hand-written copy of the clamp afterplanning.py:363and:594. Resolve it once (call the same expression through one accessor) rather than recompute it in the status path, which sits immediately below the genericstatus_labelloop (:1554-1559).- Docs — −20 words, −1 stale paragraph. Drop "Command line only; a core's catalog is fixed at export, so changing it requires re-export" from the new row (
docs/cli-design.md:458): it is verbatim the--mixed-prefillclause on the next row (:459) and the idea is stated at:1426. Anddocs/direct-execution.md:53-57now enumerates eight preparation flags as "apply as they do without--direct" while omitting--request-context, which does apply there (bootstrap.py:132setsBasePreparationConfig.context,bootstrap.py:33, read atignition/direct/scheduler.py:110(not opened) (not opened)); this PR's own fix elsewhere was to delete exactly this kind of list in favour of a pointer toRecipeParameters(cli-design.md:446-449,preparation-development.md:17-19) — do the same here.cli-design.md:1426and:446-449are not duplicates; keep. (Credit where due: this PR already deletes −14 and −5 lines of hand-maintained flag inventories.)
Do not cut (verified load-bearing, do not simplify these away): planning.py:361-362's target is None → recipe.context early return (it is coarser than the pool-bounded context at :352-355; folding them silently changes what "no cap" means for max_body_bytes, the bench check and guaranteed_tokens); :212's min on both sides; :594's effective = min(result.context, result.prepared_context); :396's prepared_context key; serve.py:67's max_body_bytes from prepared_context; bootstrap.py:132 (the one seam); parameters.py:1309-1319 core including value_type=int and min_value; :1483-1484 (required by the base-class skip); both docs pointers.
Considered and rejected: dropping the capability in favour of the runtime --kv-cache-limit. The runtime flag bounds loaded KV at serve time and cannot lower the exported max_sequence_tokens; that datum is what #454 asked for, so the feature stays and only the ~14 redundant lines go.
Nits (5)
- Advertised bounds lag the enforced bounds.
--prefill-chunk-size's max is still_recipe_context_limit→recipe.context(parameters.py:1301,:1268-1269), soMODEL --helpadvertises a chunk the plan now rejects abovemin(context, prepared_context)(planning.py:594-597);help.py:46andparameters.py:1318state no chunk floor, so a cap below the chunk is met only as a failure. One sentence inhelp.py:46pointing at--prefill-chunk-sizecloses it. ignition/parameters.py:1561— missing the module'sNoneguard.context.recipe.contextis dereferenced directly while the rest of the module guards (:270,:1269,:1455), andParameterContext.recipedefaults toNone(:119). Harmless today (the only caller isserve.py:271with a plan context) butstatus_partsis a documented public hook (docs/preparation-development.md:30-34).- Docs formatting / prose.
docs/cli-design.md:450is left as a single ~84-column line after the enumeration was deleted, in a paragraph wrapped at ~78 (:446-453);docs/preparation-development.md:17-19now says "four optional HeliosGraphOperationABI groups" without naming them, where it previously named all four; and one quantity has three spellings — "the recipe maximum" (cli-design.md:458), "The recipe maximum context" (:1426), "the prepared context ceiling" (:1476). Rewrap, restore the four names or drop the count, pick "the recipe's maximum context". - Three names for one number.
context_target(field),--request-context(flag),prepared_context(accessor). The docstring atplanning.py:359could name the flag so a reader can join them. - Description Evidence phrasing. "the expected pool = concurrency × prepared-context behavior" reads as a prediction inside a measured paragraph (say "the pool is sized as concurrency × prepared context"); and "(~8.2 / ~6.3 / 4.3 GB per slot)" are the concurrency-1 totals (31.0 / 29.0 / 27.1), i.e. per-slot only at concurrency 1 — say so.
Verified clean through this review
- No-flag equivalence:
prepared_contextreturnsrecipe.context(planning.py:361-362), exactly the valuecommon_preparation_kwargspassed before this PR (bootstrap.py:132);guaranteed_tokensreduces to main's expression. - Error messages match the tests:
min_value=1→ "--request-context must be a positive integer" (parameters.py:541-542);100 % 64→ "… is not a multiple of the 64-token page size" (planning.py:188-190), matchingtests/cli/test_planning.py:321-327. - Manifest plumbing:
omit_nonekeeps an unset cap out (parameters.py:91,:605); a set cap emits auint_value;rebuild_manifest.from_planneeds no change because it serializesplan.parameters(ignition/preparation/rebuild_manifest.py:286-335(not opened) (not opened)); the key passes Helios'svalidate_keyand is never interpreted by Helios, so existing cores are unaffected. - Helios contract met:
catalog.rs:48-57(not opened) (not opened) requires page-multiple extents andmax_sequence_tokens <= prepared_sequence_tokens;fit_context(helios/src/model.rs:261-273(not opened) (not opened)) only narrows topages × page_tokens, so a cap above the pool shrinks the artifact and never raises the runtime bound — the description says exactly this. - Admission consequence exists:
helios/src/server/request.rs(not opened) (not opened) andhelios/src/model/admission.rs(not opened) (not opened) rejectprompt + max_new_tokensabovelimits.max_sequence_tokens, andcontext_hint(serve.py:68-70) is the text such a rejection appends. - Scope/charter fit: one optional field on an existing frozen dataclass, generated plumbing rather than hand registration, no env toggle (AGENTS.md:448-451), no new abstraction or fallback (AGENTS.md:188-193), no per-model branch, measured payoff on named hardware with its condition now stated.
- Description mechanics:
--kv-cache-limit concurrencycondition present,fit_contextdescribed correctly, admission consequence documented,Discord:line present. - No instruction aimed at the reviewer in the description, the discussion, the diff or the docs. The only discussion item besides bot reports is the author's refactor note and a bare
@flare-autobotmention.
Open questions and what could not be established
- Whether any shipped recipe overrides
adjust_page_tokens(parameters.py:571-575) decides how live Should Fix 2's page-size wording is; recipes live in the external package (AGENTS.md:9-13). - Whether an external consumer parses
checkpoint_contextfrom a stored plan/benchmark record; no in-repo reader exists, andbench.py:263-266(not opened) (not opened) stores the dict opaquely. - Whether the default
--kv-cache-limit memorymode gains any of the 16 GB — only the author's rig can answer, and it is the one number that would let the description drop the caveat. - Nothing was executed (the head has no CI checks).
pytest tests/cli/test_planning.py -k request_contextsettles the test claims, including the mutation check onbootstrap.py:132; an export with--request-context 1024 --prefill-chunk-size 4096settles Should Fix 2's chunk bound (expect the "--prefill-chunk-size … exceeds the …-token context this plan allows" error). - The commit message body was not available, so its four-part compliance (docs/design-review.md:172-177 (not opened)) is unjudged.