Simplicity report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/d473a963-eb89-4461-a79d-b037266a36fc.md

Review of PR #533 "Cap the per-request context target" — lens D (simplicity), head de1b5b5

9 files, +98/−18. Read in context against the charter (small-model-agnostic runtime, "don't silently ignore API fields"), AGENTS.md (required prose review :43-50; "require focused, meaningful validation" :194-199; one home per setting and "the plan, its printed report, and its recorded measurements describe what was prepared" :452-456) and .agents/skills/repo-prose/SKILL.md:26-29 (not opened) ("Documentation is a present-state specification, not a changelog").

Key findings

Verdict for this lens: should-fix issues only. No blocking issues. The feature's shape is already minimal — one optional field, one accessor, one keyword threaded through derive()/fit()/plan(), one line in bootstrap.py. Three things can still be made smaller or must be made to prove what they claim: a duplicate clamp, a test that proves the property's own arithmetic instead of the seam that matters, and recorded measurements that omit the prepared value.

I re-checked and retracted one observation of my own: min(result.context, result.prepared_context) at ignition/planning.py:696 is not dead. With no target, prepared_context returns self.recipe.context (planning.py:374), which can exceed the pool-bound context = min(recipe.context, tokens) (planning.py:368), so the clamp is what preserves stock behaviour. The simplification is to move the clamp into the accessor, not to delete it.

Resolved since my earlier pass and verified at this head: multi-host export forwards the target (ignition/cli/serve.py:206), page-multiple validation sits in Plan.__post_init__ (planning.py:289-290), to_dict/reproduction_arguments/from_plan record the setting (planning.py:432, ignition/preparation/rebuild_manifest.py:264-265, :390), and tests/cli/test_planning.py:211-265 covers the no-op path, clamp, both validations and the manifest.


Should fix

1. prepared_context and the caller both clamp — collapse into the accessor

Where: ignition/planning.py:371-375 (accessor) and ignition/planning.py:696 (caller)

@property
def prepared_context(self) -> int:
    """The context the prepared core serves per request; the recipe max when no target is set."""
    if self.context_target is None:
        return self.recipe.context
    return min(self.recipe.context, self.context_target, self.tokens)
result = attempt()
if result is not None:
    effective_context = min(result.context, result.prepared_context)
    if chunk > effective_context:

What is wrong: the accessor already knows the pool bound self.tokens and the recipe bound, and self.context is exactly min(self.recipe.context, self.tokens) (planning.py:366-368). The caller therefore re-derives the same bound with a differently named local, so the invariant "prepared_context never exceeds the pool capacity" (a claim the PR description makes) exists in two places and has to be re-proved by every reader of the chunk check. Why it matters: two clamps of the same quantity are how the two drift apart in a later edit; and the local effective_context is a second name for a value the plan already publishes. Fix: fold the clamp into the accessor and use the accessor at the call site:

@property
def prepared_context(self) -> int:
    """The context the prepared core serves per request; the recipe max when no target is set."""
    return self.context if self.context_target is None else min(self.context, self.context_target)
if result is not None:
    if chunk > result.prepared_context:

Behaviour identical (six lines to three, one local gone), and prepared_context <= context becomes true by construction.

2. The new test asserts the property's own expressions, not the seam the PR depends on

Where: tests/cli/test_planning.py:220-232 and :247; unasserted seam ignition/preparation/bootstrap.py:58 ("context": plan.prepared_context) What is wrong: the assertions are restatements of planning.py:368,375:

assert stock_plan.prepared_context == recipe.context
assert stock_plan.context == min(recipe.context, stock_plan.tokens)
assert capped.prepared_context == min(recipe.context, 131072, capped.tokens)
assert capped.context == min(recipe.context, capped.tokens)
assert d["context"] == capped.context

None of them would fail if bootstrap.common_preparation_kwargs stopped reading plan.prepared_context — the one line that actually carries the cap into max_sequence_tokens, which is the whole point of the PR. The rule is AGENTS.md:194-199: "Tests must exercise the affected behavior or contract". Fix: keep the flag/validation/manifest assertions, and replace the mirrored min(...) restatements with the established seam check, patterned on tests/cli/test_commands.py:88-91:

kwargs = common_preparation_kwargs(capped, compile_forwards=True, kernel_cache=None, retain_graphs=False)
assert BasePreparationConfig(**kwargs).context == 131072
assert BasePreparationConfig(**common_preparation_kwargs(
    stock_plan, compile_forwards=True, kernel_cache=None, retain_graphs=False)).context == recipe.context

The second line is the no-op path (the omission the PR description calls byte-equivalent to main), the first is the cap reaching the prepared core. Fewer assertions, both load-bearing.

3. The recorded measurement does not state the prepared context

Where: ignition/cli/bench.py:243-248; ignition/planning.py:432

"preparation": {key: preparation[key] for key in (
    "tensor_parallel", "prefill_chunk", "stream_overlap", "context_parallel", "context_parallel_size",
    "native_dense_activations", "force_moe_decode_a16", "autotune_effort", "compile_workers",
    "speculative_token_capacity", "speculation", "expert_scale_compression", "mla_compute_mode",
    "row_shard_prefill",
    "online_mxfp8", "online_mxfp8_scope", "language_model_only")}}
"context": self.context, "context_target": self.context_target, "checkpoint_context": self.recipe.context,

What is wrong: the bench preparation record is a hand-picked tuple and contains no context key at all, so a benchmark result records neither the target nor the prepared context — the quantity this PR's VRAM table is a function of. to_dict publishes the stock pool-bound "context" and the requested "context_target", but not the value that was actually handed to the recipe, so a reader cannot tell from the recorded plan whether the core was prepared at 131072 or 262144. Why it matters: AGENTS.md:452-456 requires the plan's recorded measurements to describe what was prepared; and the PR's own evidence (VRAM per slot scaling with the prepared context) is unreadable from the artifact the benchmark writes. Fix: add "prepared_context": self.prepared_context beside "context_target" in to_dict (planning.py:432), and add "context_target", "prepared_context" to the bench key tuple (bench.py:243-248).


Nits

4. The positive-target check lives in fit, which runs per candidate and per probe

Where: ignition/planning.py:461-462

if context is not None and context <= 0:
    raise UsageError(f"--request-context {context}: a positive token count is required")

fit is re-entered once per candidate world size and once per shortfall option probe (planning.py:664-692, :707-724), while every comparable CLI range check sits once in plan() — e.g. --prefill-chunk-size at planning.py:623-625, and this PR's own page-multiple check at :289-290. Fix: move the identical guard beside the chunk check in plan(); one home for CLI argument validation instead of two.

5. The two-arm default-chunk error restates the fix twice in one ~170-character line

Where: ignition/planning.py:697-700

if chunk > effective_context:
    if prefill_chunk is None:
        raise UsageError(f"the {effective_context:,}-token request context is below the {chunk:,}-token default prefill chunk; pass --prefill-chunk-size below {effective_context:,}")
    raise UsageError(f"--prefill-chunk-size {chunk:,} exceeds the {effective_context:,}-token context this plan allows")

Both arms state the same constraint and differ only in naming the default chunk; the pass --prefill-chunk-size below N remedy is implied by the constraint. The first arm is reachable only through an explicit target below the default 4096-token chunk (the pool floor is 8192 tokens: MINIMUM_REQUEST_TOKENS at planning.py:32 with minimum_pages at :336), so a clause is enough. Fix:

raise UsageError(f"--prefill-chunk-size {chunk:,} exceeds the {result.prepared_context:,}-token prepared context"
                 + ("; the default chunk is 4096" if prefill_chunk is None else ""))

The (a multiple of 64) hint belongs to --prefill-chunk-size's own help (ignition/cli/__init__.py:163-166), where it already is.

6. Help entry and docs row are longer than the setting they describe

Where: ignition/cli/__init__.py:167-170 and docs/cli-design.md:446 The help spends three lines ("cap the prepared context and max_sequence_tokens at N; a request that would exceed N is rejected. Omitted flag uses the recipe's max context") against the neighbour pattern of one clause plus a default (:163-166). The docs row carries a rationale sentence ("With --kv-cache-limit concurrency, shortening the per-request context frees VRAM for additional concurrent requests") that restates the KV-limit section (docs/cli-design.md:828-841) and duplicates the two owner rows this PR edits (:1443, :1493). Per .agents/skills/repo-prose/SKILL.md:26-29 (not opened) documentation is a present-state specification, not an argument (see also AGENTS.md:43-50). Fix: help becomes one clause plus a default, e.g. "cap the prepared per-request context at N tokens; longer requests are rejected (default: the recipe's maximum)"; keep the docs row's tabular behaviour and its existing "Command line only" clause and move the rationale to the PR description.


Checked and deliberately not reported (no deletion warranted)

Open questions / not verifiable from the code