Simplicity report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/afeb3379-1c7f-4304-aac3-e997e2f44db3.md

Lens D (simplicity) review — PR #533 "Cap the per-request context target"

Head reviewed: 448f70a7 (8 files, +91/−28, base main). No CI checks on the head commit; I ran nothing myself.

Key findings

Verdict: should-fix issues only — 0 blocking, 1 should fix, 6 nits.

The shape of this change is right and needs no rework: one universal field (context_target on RecipeParameters), one accessor (Plan.prepared_context, ignition/planning.py:357-363), one consumer seam (ignition/preparation/bootstrap.py:132), Plan.context deliberately left stock (planning.py:353-355), no Helios change, and this head deletes both hand-maintained field enumerations from the docs in favour of a pointer to ignition/parameters.py (docs/cli-design.md:446-453, docs/preparation-development.md:17-19) — the removal the charter's "no churn / no parallel paths" line asks for (AGENTS.md:188-193).

What remains is subtraction, not design:

  1. The new test proves the accessor's arithmetic, not the cap's only consumer seam (should fix).
  2. Six places re-derive or restate the same clamp, or duplicate a neighbouring line (nits).

Resolved at this head, not re-raised (they were findings in my earlier passes at heads 9118add / e6239855 / 02023eba): max_fn is gone from context_target (ignition/parameters.py:1309-1319), so min(recipe.context, target) at planning.py:363 is live and the oversized case at tests/cli/test_planning.py:311-314 can pass; --request-context is emitted in the RecipeParameters.reproduction_args override (parameters.py:1483-1484); the prefill bound compares min(result.context, result.prepared_context) (planning.py:594-597); the bench check compares against min(self.context, self.prepared_context) (planning.py:212); Plan.to_dict() publishes prepared_context (planning.py:396); max_body_bytes uses plan.prepared_context (ignition/cli/serve.py:67).


Should fix

S1. The new test does not test the cap — it tests the accessor and re-proves generic manifest plumbing

File: tests/cli/test_planning.py:295-335 (test_request_context_target_prepared_context_and_manifest)

The only line that carries the cap out of the Plan and into the prepared core is ignition/preparation/bootstrap.py:132:

"context": plan.prepared_context,

Revert that line to plan.recipe.context and this test stays green. The reason is the shape of the "seam" block at :316-319:

from ignition.preparation.bootstrap import common_preparation_kwargs
kwargs = common_preparation_kwargs(capped, kernel_cache=None, retain_graphs=False)
assert kwargs["context"] == capped.prepared_context == 131072
assert kwargs["context"] != recipe.context

capped.prepared_context on both sides of the comparison is computed from the same field the seam reads, so the assertion restates the accessor rather than the configuration the exporter actually builds. BasePreparationConfig(**kwargs) is never constructed, so nothing proves the cap reaches the config object every recipe consumes.

The rest of the test is either input restatement or coverage that already exists:

Why it matters: this is the repo rule the PR has to satisfy — "Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness" (AGENTS.md:194-199). As written, the regression the whole PR is about (a cap that silently does not reach max_sequence_tokens) is untested.

Fix (smaller and behaviourally stronger, roughly half the lines): keep the three plans, drop the arithmetic duplicates and the :329-335 manifest block, and assert through the real config path in the repo's existing pattern (tests/cli/test_commands.py:150-153, kwargs = common_preparation_kwargs(plan, ...) → BasePreparationConfig(**kwargs)):

from ignition.preparation.bootstrap import BasePreparationConfig, common_preparation_kwargs

def _config(plan):
    return BasePreparationConfig(**common_preparation_kwargs(
        plan, compile_forwards=True, kernel_cache=None, retain_graphs=False))

assert _config(stock_plan).context == recipe.context
assert _config(capped).context == 131072
assert _config(oversized).context == recipe.context

Keep the two pytest.raises cases (:321-327 — --request-context 0, and the non-page-multiple 100) and one reproduction-args assertion ("--request-context" in manifest["reproduction_args"]); those are the only assertions carrying behaviour not covered elsewhere. This version fails when bootstrap.py:132 is reverted; the current one does not.

(If only a test can settle it: pytest tests/cli/test_planning.py -k request_context, then edit bootstrap.py:132 to plan.recipe.context and re-run — it must go red. It will not.)


Nits

N1. manifest_key="context_target" is redundant

File: ignition/parameters.py:1316

manifest_parameters already falls back to the field name when manifest_key is unset (parameters.py:607-612: key = dc_field.name), and RecipeParameters.manifest_prefix defaults to None (parameters.py:334; only SpeculationParameters sets it, :734). Smaller: delete the line; the manifest key stays context_target. (Contrast: the sibling prefill_chunk at :1303 does need its manifest_key, because the field is prefill_chunk — there the key is unchanged too, so both are arguably removable, but that is pre-existing code and outside this PR.)

N2. scope=ParameterScope.DEPLOYMENT restates the default

File: ignition/parameters.py:1317

ParamSpec.scope already defaults to ParameterScope.DEPLOYMENT (parameters.py:89). Smaller: delete the line. Keep it only if the neighbouring prefill_chunk (:1304) convention is considered worth the consistency; either is defensible, but as written this field spells out a default that the dataclass already guarantees.

N3. The clamp is re-derived in __post_init__ instead of reusing prepared_context

File: ignition/planning.py:186-190

target = self.parameters.context_target
if target is not None and target <= self.recipe.context and target % self.page_tokens != 0:
    raise UsageError(
        f"--request-context {target:,} is not a multiple of the {self.page_tokens:,}-token page size"
    )

That is a third copy of the clamp resolution already owned by Plan.prepared_context (:357-363) — and __post_init__ re-runs it for every candidate world size (planning.py:583-587), so it executes many times per plan() call. Smaller, same behaviour, one condition:

if self.prepared_context % self.page_tokens:
    raise UsageError(
        f"--request-context {self.prepared_context:,} is not a multiple of the {self.page_tokens:,}-token page size")

Equivalence: recipe.context is itself a page multiple, so an oversized target resolving to it passes, and a target <= recipe.context is checked exactly as before. It also states the rule Helios actually enforces (prepared_sequence_tokens and max_sequence_tokens must be page multiples — helios/src/model/catalog.rs:49-57) rather than the pre-clamp value. Guard the message so it only fires when a target is set if the wording would otherwise mislead an unset plan (prepared_context == recipe.context is always aligned, so it will not fire).

N4. status_parts re-derives the clamp a third time, as a parallel path to the generic loop

File: ignition/parameters.py:1560-1561

if self.context_target is not None:
    parts.append(f"request context {min(self.context_target, context.recipe.context):,} tokens")

min(self.context_target, context.recipe.context) is the same clamp as planning.py:363 and :187 — the third hand-written copy in the change. It sits immediately below the generic emission loop (:1554-1559) that every other field uses via spec.status_label (parameters.py:98), so this is a parallel path for one field. Second, smaller issue: context.recipe.context is unguarded, while ParameterContext.recipe defaults to None (parameters.py:119), so any caller with a bare context raises AttributeError.

Fix: give the field status_label like its neighbours, or — better, since the clamp must not be re-derived — resolve it once (e.g. expose the single resolver and call it here) and drop the inline min. If the label must stay inline, at minimum guard context.recipe.

N5. Two full hint strings duplicate their common prefix

File: ignition/cli/serve.py:68-70

"context_hint": ("context is limited by the checkpoint, cache capacity, and --request-context cap"
                 if plan.prepared_context < recipe.context
                 else "context is limited by the checkpoint and cache capacity"),

The condition itself is correct and load-bearing (the cap must be named only when active). Smaller:

"context_hint": "context is limited by the checkpoint and cache capacity"
                + (", and the --request-context cap" if plan.prepared_context < recipe.context else ""),

N6. Docs row: a clause copied verbatim from the row below; one over-long line

File: docs/cli-design.md:458 (vs :459), and :450

The new --request-context row ends "a core's catalog is fixed at export, so changing it requires re-export", which is the same tail as the --mixed-prefill row at :459. It is also the only row in the table that carries it for a flag rather than a catalog setting; smaller: drop the clause from the new row (the idea is already stated by the neighbouring row and at :1426), or state it once outside the table.

Also at docs/cli-design.md:450: after the enumeration was deleted, the line "Recipes compose additional domain parameter groups and subclasses." is left as a single over-long unwrapped line in a paragraph that is otherwise wrapped at ~78 columns (:446-453). Rewrap.


Load-bearing — do not simplify these away

Recorded so a later pass does not cut what looks redundant and is not:


Open questions / not verified