Simplicity report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/554f9dbe-0f8d-44ee-a04f-645707a1c9b8.md

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

Diff reviewed: 7 files, +35/−15 at head 1a006c6 (pr_diff). Every changed site was read in its surrounding function, and the callers of derive()/fit()/plan() were followed.

Key findings

  1. Blocking (cross-lens, functionality): --request-context is accepted by export for multi-host exports and then silently dropped, so the cap never reaches the plan. This is the one thing in the PR that produces a wrong artifact while reporting success.
  2. Should fix (cross-lens, observability): the plan's printed report (Plan.to_dict) and the reproduction arguments / manifest parameters (rebuild_manifest) omit the new setting entirely, so the export report and flare inspect describe a core prepared at the recipe maximum — a direct violation of AGENTS.md:454-456.
  3. Should fix (lens D): the PR ships no test for anything it adds; the "omitting the flag is a no-op" claim is prose only.
  4. Should fix (lens D): the positive-target validation is inside fit, which is re-entered many times per command; the same message can live once, beside the other flag checks.
  5. Nits: one dead min, one bloated error message, and a help line plus a docs row that carry rationale belonging in the PR description.

Simplicity-relevant verdict in one line: the feature body is already minimal — one optional field, one accessor, one threaded keyword, one line in bootstrap.py. What is missing is deletion of redundancy (the dead min, the mislocated check) and addition of the one test that would justify the context_target=None no-op path.


Findings in detail

1. Blocking — multi-host export silently drops --request-context

File: ignition/cli/serve.py:193-206 (the planning.plan(...) call inside _export_hosts), reached from export() at ignition/cli/serve.py:153-156.

The flag is declared in the shared preparation group (ignition/cli/__init__.py:167-170, group capacity and compression), so export, debug-serve and bench all accept it. Three of four planning call sites were threaded:

The fourth does not. _export_hosts builds the plan at serve.py:193-206 with mla_compute_mode=args.mla_compute_mode, row_shard_prefill=args.row_shard_prefill as the last keywords; there is no context=. plan() defaults context=None (ignition/planning.py:591), so Plan.context_target stays None (planning.py:176), prepared_context returns recipe.context (planning.py:371-372), and common_preparation_kwargs hands the recipe maximum to the core (ignition/preparation/bootstrap.py:58). The command prints Exported cache entry: … and a plan whose context is the stock value.

Why it matters: the user's whole purpose is to shrink the KV pool for a co-run; a multi-host export silently produces the unshrunk core, and the served model will then OOM or evict where the operator budgeted headroom. This is exactly the failure mode the repo forbids: AGENTS.md "Don't silently ignore API fields" (charter line 13: "If a standard request field is passed in, either implement it according to the spec or reject it"), and the new docs row docs/cli-design.md:446 promises the cap applies on export with no multi-host carve-out.

Fix (smaller version, one keyword):

                         mla_compute_mode=args.mla_compute_mode,
                         row_shard_prefill=args.row_shard_prefill, context=args.request_context)

A test that asserts _export_hosts forwards the target — or, if the plan is to defer support, an explicit rejection of --request-context with --ranks > 1 — settles it.

2. Should fix — the plan report and the reproduction arguments omit the new setting

Files: ignition/planning.py:389-442 (Plan.to_dict), ignition/preparation/rebuild_manifest.py:231-300 (reproduction_arguments), ignition/preparation/rebuild_manifest.py:343-454 (from_plan).

Plan.context_target (planning.py:176) is read only by prepared_context (planning.py:369-373) and set by fit (planning.py:535). Grep for request_context|context_target|prepared_context over the repository returns nothing in either introspection path.

Why it matters: AGENTS.md:454-456 — "A setting that only experiments need 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 PR satisfies the plumbing half and skips the reporting half; for a memory-sizing knob, the reported number is the artifact the operator relies on.

Fix (smallest):

"context": self.context, "prepared_context": self.prepared_context,
"checkpoint_context": self.recipe.context,

in to_dict (line 430), and in reproduction_arguments after the concurrency lines:

if plan.context_target is not None:
    args.extend(['--request-context', str(plan.context_target)])

plus add('request_context', SCOPE_DEPLOYMENT, int(plan.context_target)) in from_plan if the parameter list is meant to be complete (every other deployment-local flag is there: prefill_chunk, max_concurrency, row_shard_prefill, …).

3. Should fix — nothing in the tree tests the feature

Files: tests/cli/test_planning.py, whole tests/ tree.

Searching the repository for request_context, context_target, prepared_context and --request-context yields hits only in ignition/planning.py, ignition/cli/*, ignition/preparation/bootstrap.py and docs/cli-design.md. tests/cli/test_planning.py mentions context only as the recipe field it builds (line 37: context=262144). tests/cli/test_planning.py:71-120 shows the established pattern: row_shard_prefill was landed with validation, automatic-sizing, to_dict and rebuild_manifest assertions in one test — the shape this PR should have copied.

Why it matters: AGENTS.md:194-199 — "Require focused, meaningful validation. Tests must exercise the affected behavior or contract… Do not present scaffolding or partially wired features as supported." The PR's loudest claim ("omitting the flag is a no-op: prepared_context resolves to the recipe max and context to min(recipe.context, tokens), byte-equivalent to stock") is currently asserted only in prose, and finding 1 above is precisely the class of bug a single forwarding test would have caught.

Smallest proving test, reusing the fixture at tests/cli/test_planning.py:22-59 (recipe context=262144, prefill_chunk=4096, page_tokens=64):

capped = planning.plan(recipe, ckpt, pair_gpus, context=65536, **settings)
stock  = planning.plan(recipe, ckpt, pair_gpus, **settings)
assert capped.prepared_context == 65536 and capped.context_target == 65536
assert stock.prepared_context == recipe.context and stamp(...) == stock  # no-op claim
assert common_preparation_kwargs(capped, ...)["context"] == 65536      # bootstrap.py:58
with pytest.raises(UsageError, match="positive token count"):
    planning.plan(recipe, ckpt, pair_gpus, context=0, **settings)
with pytest.raises(UsageError, match="below the .* default prefill chunk"):
    planning.plan(recipe, ckpt, pair_gpus, context=2048, **settings)

The third assertion is the one line in the whole PR that makes the cap reach the core; it should not be untested.

4. Should fix — the positive-target check is in the wrong place and is re-run per candidate

File: ignition/planning.py:459-460, inside fit.

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

fit is called through plan's closure fitted (planning.py:662-674), which candidates/automatic invoke once per candidate world size (planning.py:684-687) and again for each option probe in the shortfall path (planning.py:707-724) — so an immutable CLI value is re-validated up to a dozen times per command. Every other user-facing range check lives once at the top of plan(): --max-concurrency at planning.py:613-614, --image-concurrency at 615-617, --prefill-chunk-size at 620-623.

Fix: delete planning.py:459-460 and put the identical guard beside the other flag checks, e.g. after line 619:

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

Same message, one site, outside the candidate loop. (Alternative and equally small: type=_positive_int on the add_argument at ignition/cli/__init__.py:167; that has the advantage of also covering the derive() entry point, but the plan() guard matches the file's existing convention, so prefer it.)

5. Nit — dead expression at ignition/planning.py:694

effective_context = min(result.context, result.prepared_context)

prepared_context is already min(recipe.context, target, tokens) (planning.py:373) and context is min(recipe.context, tokens) (366), so prepared_context <= context always; the outer min can never select context. With no target, prepared_context == recipe.context >= context, so the two are equal exactly when the target is unset or above the pool — which is the stock behaviour the PR wants.

Fix: delete the local and use the property in both arms:

if chunk > result.prepared_context:
    ...  # result.prepared_context in both messages

Behaviour is identical and the reader no longer has to prove an invariant.

6. Nit — the new error restates syntax the help already gives

File: ignition/planning.py:696-699.

f"the {context:,}-token request context is below the {chunk:,}-token default prefill chunk;"
f" pass --prefill-chunk-size (a multiple of 64) below {context:,} or a larger --request-context"

The (a multiple of 64) clause duplicates --prefill-chunk-size's own help (ignition/cli/__init__.py:163-166, "a multiple of 64"), and the guidance is longer than the constraint. Keeping two arms is right (the maintainer asked for the default/user-set distinction in #454); each arm can be one line, e.g. f"the {n:,}-token request context is below the default {chunk:,}-token prefill chunk; pass a smaller --prefill-chunk-size".

7. Nit — help text and docs row are longer than the setting

Files: ignition/cli/__init__.py:167-170, docs/cli-design.md:446.

The help says "Omitted flag uses the recipe's max context (the pool fills the free VRAM)" — a parenthetical explaining sizing nobody asked about, duplicating the docs. Its neighbour --prefill-chunk-size uses a clause plus a default. Suggested:

"cap the prepared per-request context and max_sequence_tokens at N tokens; longer requests are rejected"
" (default: the recipe's maximum context)"

docs/cli-design.md:446 likewise carries a rationale sentence ("Shortening the per-request context buys concurrency headroom in a memory-constrained multi-model deployment, since the per-request cache allocation is sized from the prepared context") that repeats the Configuration-table row at docs/cli-design.md:1443 and the KV section; the neighbourhood convention is the trailing "Command line only; a core's catalog is fixed at export, so changing it requires re-export", which the row already has. Drop the rationale to the PR description (where the measurement table lives) and keep the row tabular.


Checked and deliberately not reported

Open questions / what a test or maintainer must settle