Simplicity report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/973a2194-afce-4ed3-b369-d7808238d673.md

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

Head commit: 9118add · base: main · 6 files, +69/−5 · open, ready for review, no CI checks on the head, no reviews yet.

Key findings

Verdict: 1 blocking, 1 should-fix, 5 nits.

The change is small and mostly well placed: one parameter on RecipeParameters, one Plan accessor, one validation, one consumer seam in common_preparation_kwargs. Three of the added lines, however, contradict each other — the parameter rejects what the doc, the accessor and the new test all say gets clamped — and the test that documents the clamp cannot pass. The rest is subtraction: a redundant manifest key, a dead repro_always, a validation that runs far more often than it needs to, a doc clause copied from the row below it, and a test that asserts the accessor five times while never touching the seam that actually carries the cap into the core.


Blocking

1. The documented clamp is unreachable, and the test that encodes it fails

Files: ignition/parameters.py:1309-1321 and 1268-1269; ignition/planning.py:186-190, 357-363, 540; tests/cli/test_planning.py:310-313; docs/cli-design.md:468.

context_target is declared as

context_target: int | None = param(
    None, flag="--request-context", ..., min_value=1,
    max_fn=_recipe_context_limit,     # parameters.py:1316
    ...)

and _recipe_context_limit returns context.recipe.context (parameters.py:1268-1269). ParameterGroup.validate_fields rejects value > max_val with f"{flag} for {alias} must be {lo} through {hi}" (parameters.py:536-540), and plan() calls params.validate(pre_context) before any plan exists (planning.py:540). So on a 262,144-context recipe, --request-context 500000 raises

--request-context for qwen... must be 1 through 262,144

rather than clamping.

Consequences, in order of how much they cost:

  1. Dead code. return min(self.recipe.context, target) in Plan.prepared_context (planning.py:363) can never select recipe.context; the target is always ≤ the recipe max by the time a Plan exists. The min advertises a rule the parameter layer forbids.
  2. A failing test. tests/cli/test_planning.py:310-313 builds replace(base_params, context_target=500000), calls planning.plan(...) and asserts oversized.prepared_context == recipe.context. That call raises UsageError at planning.py:540 (and, for an unaligned 500000, would also trip planning.py:187: 500000 % 64 = 32), so the test cannot pass. Nothing in this review ran pytest (no CI on 9118add), but the trace is unambiguous from validate_fields + plan().
  3. Docs and description describe forbidden behaviour. docs/cli-design.md:468 says the flag "resolves to the smaller of N and the recipe maximum", and the PR description says "min(recipe.context, N) otherwise". Both are false as written; the flag's real contract is "N must be within the recipe maximum".

Why it matters: the whole point of the PR is a cap that composes with the recipe maximum ("a cap above the pool still shrinks the export artifact"). As written, a user who follows the docs and passes a cap above the recipe max gets a hard usage error, not a no-op clamp — a worse failure than either documented behaviour. And the guard test for it is red.

Smaller version (keep the clamp the docs and accessor advertise; one check, on the value actually served):

Alternative (keep the rejection bound): delete the min at planning.py:363 (prepared_context = target if target is not None else recipe.context), delete test lines 310-313, and rewrite the doc row to "must be within the recipe maximum". Fewer moving parts, but it contradicts the PR description's stated result, so the first shape is the smaller diff and the smaller concept count.

Either way the alignment check must survive in some form: Helios refuses a core whose max_sequence_tokens is not a page multiple (helios/src/model/catalog.rs:49-57). The value that becomes max_sequence_tokens is Plan.prepared_context via ignition/preparation/bootstrap.py:132 → BASE config context.


Should fix

2. The new test proves the accessor, not the cap; it would pass with the feature reverted

File: tests/cli/test_planning.py:295-329, against ignition/preparation/bootstrap.py:132.

The only line that carries the cap into an exported core is

"context": plan.prepared_context,     # bootstrap.py:132

Nothing in the new test reads it. Lines 301, 303, 307, 308 and 313 assert prepared_context/context/context_target — i.e. they restate planning.py:355 and 362-363 and echo the field the test itself set two lines above. If bootstrap.py:132 were reverted to plan.recipe.context, pytest tests/cli/test_planning.py -k request_context stays green. AGENTS.md:194-199: "Tests must exercise the affected behavior or contract."

Fix — the repo already has the pattern (tests/cli/test_commands.py:150-153):

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

Two assertions replace five and pin both the capped path and the no-op path.

Two smaller points in the same test:


Nits

  1. ignition/parameters.py:1317 — manifest_key="context_target" duplicates the field name. The fallback at parameters.py:607-612 already produces context_target when manifest_key is absent and there is no prefix. Delete the line.
  2. ignition/parameters.py:1319 — repro_always=True is dead for this field: reproduction_args skips value is None before testing repro_always (parameters.py:1516-1520) and the field default is None, so every non-None value already differs from the default. Delete it. (max_concurrency needs it because its default is 4; this does not.)
  3. ignition/planning.py:186-190 — the alignment check lives in Plan.__post_init__, which fit() re-enters for every candidate world size and every shortfall probe (planning.py:577, 599-620); on a failed fit it raises before the capacity message the function exists to produce. Evaluate it once in plan() beside the prefill-chunk rule (planning.py:594-596), on prepared_context.
  4. docs/cli-design.md:468 — the trailing clause "a core's catalog is fixed at export, so changing it requires re-export" is copied verbatim from the --mixed-prefill row at :469. The table's "Command line only" already implies re-export; keep one clause set, and keep exactly one sentence for the resolution rule.
  5. tests/cli/test_planning.py:301, 303, 307, 308 — assert stock_plan.parameters.context_target is None, assert stock_plan.context == min(recipe.context, stock_plan.tokens), assert capped.parameters.context_target == 131072, assert capped.prepared_context == 131072 echo the inputs and planning.py:355/362-363. Subsumed by the seam assertions in finding 2.

Correct and load-bearing (do not cut)

Open questions / not verifiable here