Conventions report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/8cb7078d-aeb9-48de-8e02-296420c38392.md

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

  1. Blocking — multi-host export (export --ranks > 1) accepts --request-context and silently drops it (serve.py:193-206).
  2. Should fix — the cap is recorded nowhere: absent from Plan.to_dict(), from rebuild_manifest.from_plan, and from reproduction_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.
  3. Should fix — placement: the flag sits in the shared capacity group, so bench inherits a contract it cannot honour (its context check at planning.py:248 still uses the uncapped Plan.context), and the flag has no Configuration home unlike --prefill-chunk-size / --max-concurrency / --force-moe-decode-a16, with nothing recording that decision.
  4. Nit — Plan.prepared_context duplicates Plan.context with one added term, and effective_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:

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:

  1. 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 no context_target / prepared_context / request_context key. 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 under configuration.preparation (bench.py:243-248). Worse than an omission: to_dict()["context"] reports Plan.context == min(recipe.context, tokens) while bootstrap.py:58 prepares plan.prepared_context, so the printed and recorded plan actively misreports the prepared context whenever a cap is set.
  2. rebuild_manifest.from_plan (rebuild_manifest.py:343-454) adds one SCOPE_DEPLOYMENT parameter per plan-level preparation option: prefill_chunk (:387), max_concurrency (:380), row_shard_prefill (:392), context_parallel (:370), reserve_bytes (:389). No request_context entry exists, and Plan has no hook that forces one, so the preparation manifest of a capped core is indistinguishable from an uncapped one.
  3. 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 131072 therefore 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

  1. Plan.prepared_context is a near-copy of Plan.context (planning.py:363-366): min(recipe.context, tokens) versus min(recipe.context, context_target, tokens). The entire difference is one term, and context_target is 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 on pages // concurrency), and callers reduce over the base property instead. Threading the cap into context and deleting prepared_context would let bootstrap.py:58, the chunk check at :694-700 and to_dict()["context"] (:430) all agree on one number with no extra identifier — which is also what makes finding 2's fix trivial.
  2. 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 the min never changes the value, and plan() otherwise only ever returns result (planning.py:692-701). Prefer one term — after folding (1), result.context alone — 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)

Open questions / what a test must settle

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.