Code review summary report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/9ba5ac5c-527a-4772-9394-ba24d3e3e608.md

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:

  1. The clamp is live: no max_fn on the field (parameters.py:1309-1319), the alignment check is gated on target <= self.recipe.context (planning.py:186-190), so --request-context 500000 on a 262,144 recipe resolves to 262,144; the PR's own case (tests/cli/test_planning.py:311-314) is reachable.
  2. The printed status line carries the clamped value, not the request (parameters.py:1560-1561, rendered into the Select GPUs line at ignition/cli/serve.py:271), satisfying AGENTS.md:452-456.
  3. 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.
  4. The prefill bound uses the served extent (effective = min(result.context, result.prepared_context), planning.py:594-597), covering the Helios load gate prefill_chunk <= max_sequence_tokens (helios/src/scheduler.rs:66-77 (not opened) (not opened)).
  5. --request-context is hand-emitted in RecipeParameters.reproduction_args (parameters.py:1483-1484) ahead of the base-class-field skip (:1491-1495); the manifest then carries it.
  6. Multi-host export resolves the parameters and forwards them (ignition/cli/serve.py:180, :193-201).
  7. guaranteed_tokens now derives from prepared_context (planning.py:366-368).
  8. The new test is mutation-sensitive on the seam. tests/cli/test_planning.py:316-319 calls the real seam function and asserts kwargs["context"] == capped.prepared_context == 131072, so reverting bootstrap.py:132 to plan.recipe.context makes the test fail. Two lenses asserted the opposite at this head; that is false — checked. What the test does not do is construct BasePreparationConfig, 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:

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.

  1. 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), :303 and :304 (restate planning.py:361-362 / :355), :308 and :313 (restate the replace() values two lines above), :319 (!= recipe.context follows from == 131072 and the fixture's 262144 at :139). Collapse the four-line proto round trip :332-335 into one assertion that also checks the recorded value, which :335 does not (rebuild_manifest.py:270-274 (not opened) (not opened) writes ints to uint_value):
    assert {(p.key, p.scope, p.value.uint_value) for p in decoded.parameters} >= {
        ("context_target", proto.PREPARATION_PARAMETER_SCOPE_DEPLOYMENT, 131072)}
    
    And put the seam assertion through the config object instead of two redundant comparisons: 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 the target <= self.recipe.context gate), :316-318, :321-327 (both UsageErrors) and :329-331 (reproduction_args, the only coverage of the override at parameters.py:1483-1484). Not a saving: inlining capped_params/oversized_params exceeds the file's line width.
  2. 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 the None early return stay.
  3. ignition/parameters.py:1316-1317 — −2 lines. manifest_key="context_target" restates the field-name fallback (:607-612; RecipeParameters.manifest_prefix is None, :334) and scope=ParameterScope.DEPLOYMENT restates the ParamSpec default (:89). Caveat: the sibling prefill_chunk spells both out (:1303-1304), so this is consistency-neutral; the manifest-scope assertion keeps it honest.
  4. 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 sibling decode_weight_bytes at :72 is conditional too):
    "context_hint": ("context is limited by the checkpoint and cache capacity"
                     + (", and the --request-context cap" if plan.prepared_context < recipe.context else "")),
    
    Do not collapse it to a single always-naming string that mentions a flag the user never passed.
  5. ignition/planning.py:187-190 — −1 line. target % self.page_tokens already rejects 0 and min_value=1 forbids it, so drop != 0 and let the message be one line. Keep both guards and the self.page_tokens operand (see Should Fix 2).
  6. 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 after planning.py:363 and :594. Resolve it once (call the same expression through one accessor) rather than recompute it in the status path, which sits immediately below the generic status_label loop (:1554-1559).
  7. 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-prefill clause on the next row (:459) and the idea is stated at :1426. And docs/direct-execution.md:53-57 now enumerates eight preparation flags as "apply as they do without --direct" while omitting --request-context, which does apply there (bootstrap.py:132 sets BasePreparationConfig.context, bootstrap.py:33, read at ignition/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 to RecipeParameters (cli-design.md:446-449, preparation-development.md:17-19) — do the same here. cli-design.md:1426 and :446-449 are 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)

  1. Advertised bounds lag the enforced bounds. --prefill-chunk-size's max is still _recipe_context_limit → recipe.context (parameters.py:1301, :1268-1269), so MODEL --help advertises a chunk the plan now rejects above min(context, prepared_context) (planning.py:594-597); help.py:46 and parameters.py:1318 state no chunk floor, so a cap below the chunk is met only as a failure. One sentence in help.py:46 pointing at --prefill-chunk-size closes it.
  2. ignition/parameters.py:1561 — missing the module's None guard. context.recipe.context is dereferenced directly while the rest of the module guards (:270, :1269, :1455), and ParameterContext.recipe defaults to None (:119). Harmless today (the only caller is serve.py:271 with a plan context) but status_parts is a documented public hook (docs/preparation-development.md:30-34).
  3. Docs formatting / prose. docs/cli-design.md:450 is 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-19 now says "four optional Helios GraphOperation ABI 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".
  4. Three names for one number. context_target (field), --request-context (flag), prepared_context (accessor). The docstring at planning.py:359 could name the flag so a reader can join them.
  5. 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

Open questions and what could not be established

  1. 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).
  2. Whether an external consumer parses checkpoint_context from a stored plan/benchmark record; no in-repo reader exists, and bench.py:263-266 (not opened) (not opened) stores the dict opaquely.
  3. Whether the default --kv-cache-limit memory mode 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.
  4. Nothing was executed (the head has no CI checks). pytest tests/cli/test_planning.py -k request_context settles the test claims, including the mutation check on bootstrap.py:132; an export with --request-context 1024 --prefill-chunk-size 4096 settles Should Fix 2's chunk bound (expect the "--prefill-chunk-size … exceeds the …-token context this plan allows" error).
  5. The commit message body was not available, so its four-part compliance (docs/design-review.md:172-177 (not opened)) is unjudged.