Simplicity scratchpad · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/89536b66-612e-45b6-9781-5439fe7e2a9e.md

#1 [high] BLOCKING: multi-host export silently drops --request-context

PR #533 adds --request-context to the shared _preparation_arguments group (ignition/cli/init.py:167-170), so export, debug-serve and bench all accept it. Three of the four planning call sites were threaded:

The fourth, _export_hosts (ignition/cli/serve.py:163-250), which export() dispatches to when args.ranks > 1 (serve.py:153-156), calls planning.plan(...) at serve.py:193-206 with no context= argument. plan() defaults context=None, so a multi-host export with --request-context 131072 prepares the recipe maximum and reports success.

Rule violated: AGENTS.md "Don't silently ignore API fields" / charter line "If a standard request field is passed in, either implement it according to the spec or reject it." Also the new docs row (docs/cli-design.md:446) promises the cap applies on export, with no multi-host carve-out.

Fix: pass context=args.request_context into the planning.plan call at serve.py:205-206, next to row_shard_prefill=args.row_shard_prefill. A test asserting _export_hosts/plan() receives the target (or rejecting --request-context with --ranks > 1) settles it.

#2 [high] SHOULD FIX: plan report and reproduction args omit the new setting

Plan.context_target (ignition/planning.py:176) is read only by Plan.prepared_context (planning.py:369-373) and set by fit (planning.py:535). Two plan-introspection paths that every other setting in the plan goes through were not updated:

  1. Plan.to_dict() (planning.py:389-442) still publishes only "context": self.context (line 430) and "checkpoint_context": self.recipe.context. Neither the requested target nor prepared_context appears. This dict is the JSON plan printed by export/debug-serve/bench (serve.py:215, serve.py:485, bench.py:182) and saved as the benchmark's preparation record (bench.py:237-248, which hand-picks keys). After --request-context 131072 the printed plan therefore shows context = min(recipe.context, tokens) — the stock number — and nothing that says the core was prepared for 131072.

  2. rebuild_manifest.reproduction_arguments() (ignition/preparation/rebuild_manifest.py:231-318) emits --max-concurrency, --prefill-chunk-size, --row-shard-prefill, --autotune-effort, etc., but not --request-context (grep: no occurrence outside planning.py/cli). So flare inspect's reproduction_args, and the preparation.parameters list built by from_plan (rebuild_manifest.py:343-454), cannot reproduce the exported core: replaying them silently yields the recipe maximum.

Rule: AGENTS.md Configuration section — "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."

Fix: add "prepared_context": self.prepared_context (and the target, or just the prepared value) to to_dict, and add to reproduction_arguments: if plan.context_target is not None: args.extend(['--request-context', str(plan.context_target)]) plus a SCOPE_DEPLOYMENT entry in from_plan if the parameter list is meant to be complete.

#3 [high] Lens D consolidated: tests absent, validation misplaced, prose bloat

Lens D (simplicity) findings, all verified in code (three earlier scratchpad_write calls failed at turn end; this consolidates them):

a) NO TESTS. Nothing in tests/ references --request-context, context_target or prepared_context (search_code over tests/ returns no matches). The PR adds a CLI flag, a dataclass field, a property, a validation and a rewritten error with no test. AGENTS.md "Require focused, meaningful validation" ("Tests must exercise the affected behavior or contract"); charter "Bring real evidence". #454 (same author, same feature) was rejected partly for exactly this and it is unchanged. Smallest proving test, using the fixture recipe in tests/cli/test_planning.py (context=262144, prefill_chunk=4096, page_tokens=64): (i) planning.fit(..., context=65536).prepared_context == 65536; (ii) omitting context gives prepared_context == recipe.context and is == the stock plan — this is the PR's loudest claim ("omitting the flag is a no-op, byte-equivalent to stock") and is currently only asserted by prose; (iii) common_preparation_kwargs(plan, ...)["context"] == 65536 (ignition/preparation/bootstrap.py:58), which is the one line that makes the cap reach the core; (iv) planning.plan(..., context=2048) raises the new default-chunk error, and with an explicit --prefill-chunk-size above the cap raises the other arm.

b) THE POSITIVE-TARGET CHECK IS IN THE WRONG PLACE, and can be deleted from fit. fit validates at ignition/planning.py:459-460, but fit runs inside plan.fitted() which is called once per candidate world size (planning.py:684-690) and again for every option probe (planning.py:707-724), so a value that cannot change is re-checked many times per command. Smaller version: drop the if context is not None and context <= 0: raise ... branch from fit (planning.py:459-460) and validate once — either in the flag (type= helper on capacity.add_argument at cli/init.py:167) or with a single guard at the top of plan() beside the other flag validation (planning.py:601-619), which already carries the --max-concurrency and --image-concurrency range checks. Same message, one site, outside the candidate loop.

c) DEAD EXPRESSION. At planning.py:694, effective_context = min(result.context, result.prepared_context). prepared_context is min(recipe.context, ...), so prepared_context <= recipe.context and context == min(recipe.context, tokens): the min can never select result.context unless it equals prepared_context. Write if chunk > result.prepared_context: and use result.prepared_context in both message arms; delete the local.

d) FAT ERROR TEXT (nit). planning.py:696-700, the default arm says "pass --prefill-chunk-size (a multiple of 64) below 131,072 or a larger --request-context", restating syntax the help already gives (cli/init.py:163-166 states "a multiple of 64"). The two arms can stay (the maintainer asked for the distinction in #454) but both can be one line each.

e) HELP TEXT AND DOCS ROW ARE LONGER THAN THE SETTING (nit). cli/init.py:167-170: "…Omitted flag uses the recipe's max context (the pool fills the free VRAM)" — the parenthetical explains sizing nobody asked about and duplicates the docs. Sibling --prefill-chunk-size uses one clause plus a default. Suggested: help="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 clause ("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 duplicates the Configuration-table row at :1443 and the KV section at :829-841; keep the convention used by neighbours ("Command line only; a core's catalog is fixed at export, so changing it requires re-export"), drop the rationale to the PR description.

f) NOT A FINDING: the flag's placement in the capacity and compression argument group (cli/init.py:156) is right; Plan.context_target as an optional field is the minimal change and needs no enum or config key; prepared_context returning the recipe max when unset (planning.py:371-372) is a deliberate no-op that keeps the existing recipes unchanged, so it should stay rather than be folded into context.

#5 [high] Report of 2026-11-26 (head de1b5b5) — lens D]

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

Diff re-read at de1b5b5 (9 files, +98/−18).

Resolved since my 2026-11-25 report (entry #4)

Findings

1. Should fix — prepared_context can be collapsed so the duplicate clamp disappears

ignition/planning.py:371-375 returns the recipe max when unset and min(recipe.context, target, tokens) otherwise; callers then re-clamp at :696. Smaller version:

@property
def prepared_context(self) -> int:
    """The context the prepared core serves per request."""
    return self.context if self.context_target is None else min(self.context, self.context_target)

(self.context already is min(recipe.context, self.tokens), :368.) Then planning.py:696-700 uses result.prepared_context directly and the local effective_context goes away. Behaviour identical, 6 lines → 3, and no reader has to prove prepared_context <= context.

2. Should fix — the test proves the property's own arithmetic, not the behaviour that matters

tests/cli/test_planning.py:220-232,247 asserts e.g. capped.prepared_context == min(recipe.context, 131072, capped.tokens) and capped.context == min(recipe.context, capped.tokens) — restatements of planning.py:368,375. The one seam the PR actually depends on, ignition/preparation/bootstrap.py:58 ("context": plan.prepared_context), is never asserted, so nothing pins "the cap reaches max_sequence_tokens". The established pattern is tests/cli/test_commands.py:88-91. Add two lines:

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   # no-op path

and drop the mirrored min(...) assertions that only restate the property.

3. Should fix — recorded measurements still omit the prepared context

ignition/cli/bench.py:243-248 hand-picks the preparation record's keys and contains no context key at all, so a benchmark result records neither context_target nor the prepared context; Plan.to_dict (planning.py:432) publishes the stock "context" beside "context_target" but not the prepared value. AGENTS.md:454-456 requires the plan's recorded measurements to describe what was prepared. Fix: add "prepared_context": self.prepared_context next to "context_target" and add "context_target", "prepared_context" to the bench key tuple.

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

ignition/planning.py:461-462 runs once per candidate world size and once per shortfall option probe (planning.py:664-692, :707-724); every other CLI range check sits once in plan() (:623-625). Move the identical guard beside the chunk check.

5. Nit — the new default-chunk error is one long line that restates the fix twice

ignition/planning.py:699 is ~170 characters and spells both the constraint and the remedy; both arms say the same thing and differ only in naming the default. One arm suffices, e.g.

raise UsageError(f"--prefill-chunk-size {chunk:,} exceeds the {result.prepared_context:,}-token prepared context")

plus, only when prefill_chunk is None, a ; the default chunk is {chunk:,} clause. The (a multiple of 64) hint belongs to --prefill-chunk-size's own help (cli/__init__.py:163-166).

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

ignition/cli/__init__.py:167-170 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") where the neighbour's pattern is one clause plus a default: "cap the prepared per-request context at N tokens; longer requests are rejected (default: the recipe's maximum)". docs/cli-design.md:446 carries a rationale sentence ("With --kv-cache-limit concurrency, shortening … frees VRAM") that repeats the KV-limit section (docs/cli-design.md:828-833) and the two owner rows this PR edits (:1443, :1493); keep the tabular behaviour and the existing "Command line only" clause, move the rationale to the PR description (repo-prose skill: documentation is a present-state spec, not an argument; AGENTS.md:43-50).

Checked and deliberately not reported

#6 [high] Research summary

Reviewed PR #533 at head de1b5b5 through lens D (simplicity). The three findings from my previous pass are gone: multi-host export now forwards context= (serve.py:206), the page-multiple validation sits in Plan.__post_init__ (planning.py:289), and to_dict/reproduction_arguments/from_plan all record the setting, with one test in tests/cli/test_planning.py:211-265. I also corrected my own earlier nit: the min(result.context, result.prepared_context) at planning.py:696 is not dead, because with no target prepared_context is the recipe max, which can exceed the pool-bound context — the real simplification is to fold the clamp into the accessor.

Remaining, minor: (1) collapse prepared_context to self.context if self.context_target is None else min(self.context, self.context_target) and drop the local effective_context, which keeps stock semantics with three lines; (2) the new test asserts restatements of the property's own min(...) expressions and never asserts common_preparation_kwargs(...)["context"], the one seam that makes the cap reach max_sequence_tokens — two lines in the existing test_commands.py:88 pattern would pin it; (3) bench's hand-picked preparation record (bench.py:243-248) and to_dict still never state the prepared context, so the recorded measurement does not describe what was prepared (AGENTS.md:454-456) — add prepared_context to both; (4) the positive-target check belongs beside the other CLI range checks in plan() rather than in fit, which runs per candidate and per shortfall probe; (5) nits: the ~170-character two-arm default-chunk error and the three-line help entry plus the rationale clause in the docs row (docs/cli-design.md:446), both longer than the setting they describe.

Full detail, with the smaller version of each change, is in scratchpad entry #5.

#7 [high] Lens-D verdict and exact citations for the final report

Verdict and citation sheet (head de1b5b5, 2026-11-26)

Verdict for lens D: no blocking issues. The feature is already minimal; what remains is three small simplifications/fixes and three nits. Detail and smaller versions are in entry #5; this note adds the citations the report must carry.

Resolved since my 2026-11-25 report (entry #4) — verified in the code

Citations per finding

  1. Should fix — collapse the duplicate clamp. ignition/planning.py:371-375 (accessor) and :696-700 (caller). Smaller version: return self.context if self.context_target is None else min(self.context, self.context_target); then the caller uses result.prepared_context and the local effective_context goes away.
  2. Should fix — test proves arithmetic, not the seam. tests/cli/test_planning.py:220-232 and :247 restate planning.py:368,375 (min(recipe.context, 131072, capped.tokens), min(recipe.context, capped.tokens)). ignition/preparation/bootstrap.py:58 ("context": plan.prepared_context) is unasserted. Pattern to copy: tests/cli/test_commands.py:88-91 (common_preparation_kwargs → BasePreparationConfig). Rule: AGENTS.md:194-199 ("Require focused, meaningful validation … Tests must exercise the affected behavior or contract").
  3. Should fix — recorded measurement omits the prepared context. ignition/cli/bench.py:243-248 hand-picks the preparation keys and has no context key at all; ignition/planning.py:432 publishes stock "context" beside "context_target" but not prepared_context. Rule: AGENTS.md:454-456 ("the plan, its printed report, and its recorded measurements describe what was prepared"). Fix: "prepared_context": self.prepared_context in to_dict, and add "context_target", "prepared_context" to the bench tuple.
  4. Nit — validation placement. ignition/planning.py:461-462 inside fit, re-entered per candidate and per shortfall probe via fitted/candidates/attempt (planning.py:664-692, :707-724); every other CLI range check is once in plan() — --prefill-chunk-size at planning.py:623-625.
  5. Nit — two-arm chunk error too long. ignition/planning.py:697-700; the first arm is reachable only via an explicit target below the default 4096-token chunk (pool floor is 8192 tokens: MINIMUM_REQUEST_TOKENS at planning.py:32, minimum_pages at :336), so keep one arm plus an optional "; the default chunk is N" clause. (a multiple of 64) already lives in --prefill-chunk-size help (ignition/cli/__init__.py:163-166).
  6. Nit — help and docs prose longer than the setting. Help: ignition/cli/__init__.py:167-170 (three lines) against neighbour style at :163-166. Docs row: docs/cli-design.md:446; its rationale duplicates the KV-limit section docs/cli-design.md:828-841 and the two owner rows this PR edits (:1443, :1493). Rules: AGENTS.md:43-50 (required prose review) and the prose skill's "documentation is a present-state specification, not a changelog" (.agents/skills/repo-prose/SKILL.md:26-29).

Checked and not reported