Simplicity report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/3da89997-dac5-4d0f-a213-870cedf30c11.md

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

Head reviewed: e6239855 · 8 files, +79/−10 · base main · no CI checks on head · no pytest run performed by me.

Key findings

Verdict: should-fix issues only. Nothing blocking. The design is the right shape for simplicity: one universal field on RecipeParameters (context_target), one derived accessor (Plan.prepared_context), and exactly one consumer seam in the preparation path (bootstrap.py:132), with Plan.context deliberately left stock. The three defects raised earlier in the review (a max_fn that made min(recipe.context, target) dead, a missing --request-context in reproduction_args, and a prefill bound that ignored the cap) are resolved at this head and should not be re-raised.

One should-fix: the new test does not test the behaviour this PR exists to deliver. Six nits, each with a strictly smaller version.

Rule cited throughout: AGENTS.md:194-199 — "Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness", and AGENTS.md:188-193 — no unsolicited abstraction, configuration switches, or comment/doc expansion.


SHOULD FIX

tests/cli/test_planning.py:295-329 — the test tests the accessor, not the cap

Why it matters. The one line that carries the cap into the prepared core is ignition/preparation/bootstrap.py:132:

"context": plan.prepared_context,

Nothing in the new test reads it. Revert that line to plan.recipe.context and test_request_context_target_prepared_context_and_manifest stays green — the VRAM table in the PR description, the whole point of the change, would no longer be produced by the code. Per AGENTS.md:194-199 the test must exercise the affected behaviour or contract; here it does not reach the behaviour.

Specific bloat inside the same test:

Smaller version. Keep the two pytest.raises cases (:315-321, which do test a rejection path this PR adds) and one reproduction-args assertion; replace the arithmetic assertions with two seam assertions using the existing repo pattern (tests/cli/test_commands.py:150-153, tests/cli/test_parameters.py:254-256):

def test_request_context_caps_the_prepared_context(monkeypatch):
    monkeypatch.setattr("ignition.preparation.source_identity.source_identity", lambda: "test-source")
    recipe, gpus = _recipe(), (_gpu(0), _gpu(1))
    kw = dict(compile_forwards=True, kernel_cache=None, retain_graphs=False)

    stock = planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1))
    assert common_preparation_kwargs(stock, **kw)["context"] == recipe.context

    capped = planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1),
                           parameters=replace(recipe.parameters, context_target=131072))
    assert common_preparation_kwargs(capped, **kw)["context"] == 131072
    assert "131072" in rebuild_manifest.from_plan(SimpleNamespace(directory=None), capped,
                                                  compiled_forwards=True)["reproduction_args"]

    for bad in (0, 100):
        with pytest.raises(UsageError, match="--request-context|multiple of the"):
            planning.plan(recipe, recipe.checkpoints[0], gpus, selected=(0, 1),
                          parameters=replace(recipe.parameters, context_target=bad))

That is roughly half the lines and fails if the seam is severed.


NITS (each with the smaller version)

1. ignition/parameters.py:1316 — manifest_key="context_target" is redundant

manifest_parameters (parameters.py:607-612) falls back to dc_field.name when manifest_key is None and manifest_prefix is empty; RecipeParameters never sets manifest_prefix (only SpeculationParameters does, parameters.py:734; base at :334). The key is already context_target. Delete the line. (Sibling prefill_chunk at :1303 spells it out too, so keep both if consistency is judged to win — but the field adds nothing.)

2. ignition/parameters.py:1317 — scope=ParameterScope.DEPLOYMENT is the default

ParamSpec.scope defaults to ParameterScope.DEPLOYMENT (parameters.py:89). Delete the line (same consistency caveat as above).

3. ignition/planning.py:186-190 — the clamp is re-derived a third time

target = self.parameters.context_target
if target is not None and target <= self.recipe.context and target % self.page_tokens != 0:

Plan.prepared_context (planning.py:357-363) already owns "how big is the served context", and __post_init__ re-runs on every fit (planning.py:570-572) and every candidate world size (:577, :585, :600) plus each shortfall probe. The three-clause condition duplicates that resolution and has to be kept in sync with it by hand. Smaller: if self.prepared_context % self.page_tokens: raise UsageError(...) — same behaviour, because recipe.context is itself a page multiple and an oversized target resolves to it, and it states the invariant the runtime enforces (helios/src/model/catalog.rs:44-57 requires prepared_sequence_tokens and max_sequence_tokens to be page multiples).

4. ignition/cli/serve.py:68-70 — two full strings sharing a prefix

Both branches spell out "context is limited by the checkpoint". Smaller:

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

5. docs/cli-design.md:468 — clause copied verbatim from the next row

The trailing "a core's catalog is fixed at export, so changing it requires re-export" is identical to the --mixed-prefill row at :469. Keep it once — the table's reader gets the point from either. Smaller: drop it from the new row.

6. docs/preparation-development.md:17-20 and docs/cli-design.md:448-451 — two hand-maintained field enumerations

Both list the universal RecipeParameters fields and both had to be edited by this PR; the first now wraps lock_gpu_clocks, alone onto line 19 (preparation-development.md:19), which is the tell that the list is maintained by hand. Smaller: replace both enumerations with a pointer — "Core ignition defines the universal preparation fields (ignition/parameters.py)" — so adding a field no longer requires two unrelated doc edits. (Optional/structural; a maintainer may prefer the explicit list.)


Load-bearing lines — do not cut

Already resolved at this head (do not re-raise)

Open questions / not verified