Conventions-and-duplication review of PR #533 "Cap the per-request context target"
PR: https://github.com/NVIDIA/hyperflare-inference/pull/533 — author roobyz (CONTRIBUTOR), open, base main, head 1a006c6, 7 files, +35/−15, no reviews, no CI checks. It supersedes closed PR #454 (same author, same title, closed 2026-11-23 after CHANGES_REQUESTED).
My lens: compare each new construct with its closest in-repository precedent and flag departures, citing them; flag duplicated helpers/mechanisms. Every changed file was read in its surrounding code (not only the diff), and the callers of the changed behaviour were followed.
Key findings
- Blocking — multi-host export (
export --ranks > 1) accepts--request-contextand silently drops it (serve.py:193-206). - Should fix — the cap is recorded nowhere: absent from
Plan.to_dict(), fromrebuild_manifest.from_plan, and fromreproduction_arguments. This breaks AGENTS.md's explicit "plan, its printed report and its recorded measurements describe what was prepared" contract that every sibling preparation flag satisfies. - Should fix — placement: the flag sits in the shared
capacitygroup, sobenchinherits a contract it cannot honour (its context check at planning.py:248 still uses the uncappedPlan.context), and the flag has noConfigurationhome unlike--prefill-chunk-size/--max-concurrency/--force-moe-decode-a16, with nothing recording that decision. - Nit —
Plan.prepared_contextduplicatesPlan.contextwith one added term, andeffective_context = min(result.context, result.prepared_context)(planning.py:694) is a no-op.
Rules cited: charter line 13 ("Don't silently ignore API fields… Never accept it and quietly drop it (#417)"); AGENTS.md "Configuration", lines 452-456; AGENTS.md "A setting has one of three homes…"; docs/design-review.md principle 10 (explicit configuration); AGENTS.md "Require focused, meaningful validation".
No finding on the seam itself: the bootstrap.py retarget to plan.prepared_context, the derive()→plan()→fit() threading style, the validation placement, and the docs rows all follow precedent (details below).
Blocking
1. ignition/cli/serve.py:193-206 — multi-host export silently ignores --request-context
export dispatches to _export_hosts(args) when args.ranks > 1 (serve.py:153-156). _export_hosts calls planning.plan(...) with a long list of preparation flags — mixed_prefill, prompt_logprobs (:201), online_mxfp8, language_model_only, mla_compute_mode (:203-205), row_shard_prefill (:206) — and via the replace at :207-211 also compile_workers, autotune_effort, lock_gpu_clocks, native_dense_activations, force_moe_decode_a16, shard_hyperconnections, joint_tuning. It never passes context=args.request_context.
The other three preparation entry points all do:
_prepare(single-host export), serve.py:289mla_compute_mode=args.mla_compute_mode, context=args.request_contextdebug_serve, serve.py:472row_shard_prefill=args.row_shard_prefill, context=args.request_contextbench.run, bench.py:177context=args.request_context
A grep for request_context across ignition/ returns exactly those three call sites plus planning.py:460 (the validation) and planning.py:699 (the error text) — no fourth site exists.
Why it matters: ignition export MODEL --ranks 2 --request-context 131072 parses, validates nothing differently, and produces a core at the full recipe context: Plan.context_target stays None, so Plan.prepared_context resolves to recipe.context (planning.py:371-372), and preparation/bootstrap.py:58 hands the recipe max to BasePreparationConfig. The user paid for the flag and got stock behaviour with no warning — exactly the failure mode the charter bans (line 13, #417). The multi-host path is the supported path for multi-host serving, and --request-context is precisely a setting whose whole point is the exported core.
Fix: add context=args.request_context to the planning.plan(...) call at serve.py:206 (or to the replace at :207-211, matching how the other late-bound settings are attached there).
Settle by test: a test in the shape of tests/cli/test_commands.py:59-70 (test_row_shard_prefill_flag_is_model_agnostic, parametrized over export/debug-serve/bench) does not cover this case because it only asserts parser/help behaviour, not plan construction. A GPU-free unit test that drives _export_hosts's plan construction (or a --dry-run-style assertion of plan.to_dict()["context_target"] for --ranks 2) would settle it; only a test can pin it.
Should fix
2. The cap is not recorded in the plan JSON or the preparation manifest — ignition/planning.py:389-442, ignition/preparation/rebuild_manifest.py:231-318 and :343-454
AGENTS.md:452-456 states the contract for a new preparation setting: "A setting… is an advanced flag carried through the plan into the recipe's PreparationConfig, so the plan, its printed report, and its recorded measurements describe what was prepared." The established three-part convention, satisfied by every sibling flag, is:
Plan.to_dict()(planning.py:389-442) lists every plan field:mixed_prefill(:401),prompt_logprobs(:402),joint_tuning(:407),shard_hyperconnections(:408),row_shard_prefill(:409),force_moe_decode_a16(:412),online_mxfp8/online_mxfp8_scope(:415), and the context pair"context": self.context, "checkpoint_context": self.recipe.context(:430). There is nocontext_target/prepared_context/request_contextkey. This dict is printed as{"plan": …}by export (serve.py:215), debug-serve (serve.py:485) and bench (bench.py:182), and copied into the bench result underconfiguration.preparation(bench.py:243-248). Worse than an omission:to_dict()["context"]reportsPlan.context == min(recipe.context, tokens)whilebootstrap.py:58preparesplan.prepared_context, so the printed and recorded plan actively misreports the prepared context whenever a cap is set.rebuild_manifest.from_plan(rebuild_manifest.py:343-454) adds oneSCOPE_DEPLOYMENTparameter per plan-level preparation option:prefill_chunk(:387),max_concurrency(:380),row_shard_prefill(:392),context_parallel(:370),reserve_bytes(:389). Norequest_contextentry exists, andPlanhas no hook that forces one, so the preparation manifest of a capped core is indistinguishable from an uncapped one.reproduction_arguments(rebuild_manifest.py:231-318) emits a flag per recorded setting, e.g.--prefill-chunk-size(:263),--max-concurrency(:257),--row-shard-prefill(:306),--mixed-prefill(:268-269). A core exported with--request-context 131072therefore records reproduction arguments that would re-export at the recipe max — the manifest cannot reproduce the core it belongs to.
Fix: add "request_context": self.context_target (or "prepared_context": self.prepared_context; the former matches the flag name, the latter the quantity that matters — either is acceptable, but one must be present) to to_dict(); add add('request_context', SCOPE_DEPLOYMENT, plan.context_target) in from_plan (its add() already skips None, matching the existing optional entries, so the uncapped case stays byte-compatible); and in reproduction_arguments emit args.extend(['--request-context', str(plan.context_target)]) guarded by if plan.context_target is not None.
Settle by test: tests/cli/test_planning.py:92-106 already walks a tuple of candidate plans (ordinary, sharded, fitted) and asserts to_dict() keys, reproduction_args membership and manifest key/scope — it does exactly this for --row-shard-prefill. Adding a capped plan to that loop would pin all three parts at once.
3. ignition/cli/__init__.py:156-170 — the flag is placed in the shared capacity group, so bench inherits a contract it cannot honour; and it bypasses Configuration
--request-context is added to the capacity argument group inside _preparation_arguments (cli/init.py:167-170), which is applied to export (:50), bench (:53) and debug-serve (:60). Two departures from precedent:
(a) bench. Bench exports no core (docs/cli-design.md:212-216) and already owns the context vocabulary --contexts LIST (docs/cli-design.md:239). The relevant validation lives at planning.py:248-249: if selection.required_context > self.context: raise UsageError("benchmark workload and output allowance exceed the prepared context"). Plan.context is deliberately left stock by this PR, so with a cap set that check compares the workload against the uncapped context while bootstrap.py:58 prepares the capped one — the check is now weaker than its own message claims, and no check compares required_context to prepared_context. The established pattern for a preparation flag bench cannot use is explicit rejection: bench.py:115-116 rejects --mixed-prefill and --prompt-logprobs with "ignition bench measures speculative rounds or unscored prefill; --mixed-prefill and --prompt-logprobs do not apply", and bench.py:117-118 rejects --official-source because bench exports no core.
(b) No configuration home. AGENTS.md:452-453 gives a setting one of three homes. --prefill-chunk-size, --max-concurrency, --image-concurrency and --compile-workers all read through Configuration (ignition/cli/config.py:25-41, _SECTIONS["defaults"]/_BUILT_IN, and preparation.py:58-94), and --force-moe-decode-a16 has preparation.force_moe_decode_a16 (config.py:28, :42). The cap bypasses Configuration entirely: every call site passes context=args.request_context straight through with a literal None default (serve.py:289, :472, bench.py:177) and there is no _BUILT_IN entry. That may be an intentional decision — docs/cli-design.md:446 does say "Command line only; a core's catalog is fixed at export, so changing it requires re-export", the same clause --mixed-prefill uses (:447) — but the neighbouring rows that do have a config home name it, and nothing in the PR records that the absence here is deliberate.
Fix: either drop --request-context from bench's parser (or reject it in bench.Settings.from_args the way bench.py:115-116 does) unless the benchmark-plan path is taught to compare required_context against prepared_context; and either add a [preparation] request_context key threaded through Configuration, or state in the docs row that it is command-line only by design.
Settle by test: a parser/help test in the shape of tests/cli/test_commands.py:59-70 that asserts bench either rejects or honours the flag; and a planning test asserting the benchmark-vs-cap error fires when required_context > prepared_context < context.
Nit
4. ignition/planning.py:368-373 and :694 — prepared_context / effective_context duplicate Plan.context
Plan.prepared_contextis a near-copy ofPlan.context(planning.py:363-366):min(recipe.context, tokens)versusmin(recipe.context, context_target, tokens). The entire difference is one term, andcontext_targetis already validated positive at planning.py:459-460, so the two could be one property. The precedent in this file is the opposite of a parallel accessor: variant properties express a real change of quantity (guaranteed_tokens, planning.py:375-378, gates onpages // concurrency), and callers reduce over the base property instead. Threading the cap intocontextand deletingprepared_contextwould let bootstrap.py:58, the chunk check at :694-700 andto_dict()["context"](:430) all agree on one number with no extra identifier — which is also what makes finding 2's fix trivial.effective_context = min(result.context, result.prepared_context)(planning.py:694) is provably a no-op. With a target set,prepared_context = min(recipe.context, target, tokens) <= min(recipe.context, tokens) = context. With no target,prepared_context = recipe.context >= min(recipe.context, tokens) = context. So theminnever changes the value, andplan()otherwise only ever returnsresult(planning.py:692-701). Prefer one term — after folding (1),result.contextalone — so a reader does not look for a case where the two differ.
Both are nits individually; recorded together because the same edit fixes both. The chunk-vs-context error split itself (:695-700) is fine: it preserves the stock message for an explicit --prefill-chunk-size and offers a fix for the default chunk, and the _shortfall/options machinery (:703-731) is correctly untouched (the cap is not a capacity remedy).
Checked and consistent with precedent (no finding)
ignition/preparation/bootstrap.py:58("context": plan.prepared_contextinstead ofplan.recipe.context) is the right seam:common_preparation_kwargs(bootstrap.py:47-65) is the single place a plan setting becomesBasePreparationConfigand every other kwarg there is plan-derived the same way. This is what makes the cap reachmax_sequence_tokens, which was the blocking objection in PR #454 ("Preparation passesplan.recipe.contextto every recipe…").- Threading style:
derive(..., context=None)(preparation.py:56) →planning.plan(..., context=context)(:68) →fit(..., context=context)(planning.py:674) →Plan(context_target=context)(:535) matches howrow_shard_prefillandonline_mxfp8_scopeare threaded through the same functions. - Validation placement: the positive check sits in
fit()(planning.py:459-460) rather thanPlan.__post_init__; validations that depend only on plan fields live in__post_init__(planning.py:212-289), butcontextis pre-Planat that point, and the error text follows the houseUsageError(f"--flag {value}: …")form (cf. planning.py:468-469, :501-502). - docs/cli-design.md: the new row (:446) matches the table's shape and the sibling
--mixed-prefillrow's wording (:447); the two derived-owner edits (:1443, :1493) attach the cap to existing owner rows rather than adding new owners — correct. - No duplicated mechanism: nothing else in
ignition/caps a prepared context (grep forrequest_context/prepared_context/max_sequence_tokensreturns only this PR's sites plus doc hits). The nearest existing lever is the runtime--kv-cache-limit context|concurrency(docs/cli-design.md:738, :828-833), which bounds loaded KV history at serve time and needs no re-export; PR #533 is genuinely distinct because it changes the exported core, so it does not duplicate that, and PR #454's second objection should not be re-raised on duplication grounds.
Open questions / what a test must settle
- Is the absence of a
Configurationhome for the cap deliberate? docs/cli-design.md:446 says "Command line only", but its neighbours state whether a config key exists; a maintainer answer decides whether finding 3(b) is a fix or a one-line doc clarification. - Should
benchhonour the cap (comparerequired_contexttoprepared_context) or reject the flag? Only a maintainer preference or a test can settle it; the code currently does neither and silently weakens its own check. - The PR adds no tests. The precedents that would pin findings 1-3 already exist and are cheap:
tests/cli/test_commands.py:59-70(parametrized over export/debug-serve/bench) andtests/cli/test_planning.py:92-106(plan JSON keys,reproduction_args, manifest key/scope per candidate plan).
Recommendation
Request changes: fix finding 1 (one keyword argument), fix finding 2 (three small additions following the exact sibling pattern), decide finding 3 with a maintainer (reject in bench or teach bench the capped context; add a config key or say "command line only"), and add the two precedent tests. Finding 4 is optional cleanup that makes finding 2's to_dict() fix fall out naturally.