Subtraction and simplicity scratchpad · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/a0b26e93-06b1-47c2-bfa1-f7b414682721.md

#1 [high] PR #533 subtraction-lens findings (head 503a438)

Lens: Subtraction, Simplicity & Conventions. Verdict: architecture is lean (one field, one accessor, one seam at ignition/preparation/bootstrap.py:132), but the cap is re-derived in 6 places and two of the derivations are removable outright.

S1 (strongest, pure deletion, behaviour-preserving). ignition/planning.py:198-200: target = self.parameters.context_target if target is not None and target <= self.declared_context and target % self.page_tokens: raise UsageError(f"--request-context {target:,} for {self.recipe.name} is not a multiple of the {self.page_tokens:,}-token page size") The target <= self.declared_context conjunct is dead: _validate_declared_context(self.recipe, self.checkpoint, self.declared_context) at ignition/planning.py:197 already guarantees declared % recipe.page_tokens == 0 (:432-441), and prepared_context clamps an oversized target to declared (:373-375), so validating the effective value passes oversized targets anyway and rejects misaligned in-range ones as today. Replace both lines with: if self.prepared_context % self.page_tokens: raise UsageError(f"--request-context {self.prepared_context:,} for {self.recipe.name} is not a multiple of the {self.page_tokens:,}-token page size") Same behaviour whenever Plan.page_tokens == recipe.page_tokens (all shipped recipes: no adjust_page_tokens override per dossier). Deletes the second alignment rule, closes the help/code/docs contradiction (dossier item 7) at its source, and drops one branch of speculative generality ("values above the max are no-ops").

S2. Collapse the cap into Plan.context and delete both min(self.context, self.prepared_context) expressions. ignition/planning.py:367-375: @property def context(self) -> int: """The longest sequence one request may reach.""" return min(self.declared_context, self.tokens)

@property
def prepared_context(self) -> int:
    """The context the prepared core serves per request (``--request-context``); the declared context when no target is set."""
    return min(self.declared_context, self.parameters.context_target or self.declared_context)

context's docstring already claims "the longest sequence one request may reach" but ignores the cap, so every caller writes min(...) again: :222 if selection.required_context > min(self.context, self.prepared_context): and :626 effective = min(result.context, result.prepared_context). Redefine context as min(self.prepared_context, self.tokens); both call sites become self.context / result.context and the duplicated expression disappears. Then to_dict() (:407-409) need only "context": self.context plus the pre-existing "checkpoint_context", so the added "prepared_context" key can go too (its value is what context now reports). Also prefer target = self.parameters.context_target; return self.declared_context if target is None else min(self.declared_context, target) — the or idiom at :375 silently treats a 0 target as unset.

S3. Delete the third copy of the clamp in status_parts. ignition/parameters.py:1606-1607: if self.context_target is not None: parts.append(f"request context {min(self.context_target, context.recipe.context):,} tokens") This re-implements the clamp (min) with a different base (context.recipe.context rather than adjust_context-aware declared_context) where Plan.prepared_context and Plan.to_dict() already exist. AGENTS.md "Configuration": the setting is "carried through the plan into the recipe's PreparationConfig, so the plan, its printed report, and its recorded measurements describe what was prepared" — the printed plan report now carries prepared_context, so the extra status fragment is redundant. Delete the 2 lines, or express as status_label on the field (the generic mechanism at ignition/parameters.py:707-720) instead of a bespoke branch in RecipeParameters.status_parts. Same family: ignition/cli/serve.py:73-74 "context_hint": ("context is limited by the checkpoint and cache capacity" + (", and the --request-context cap" if plan.prepared_context < plan.declared_context else "")), → one unconditional string "context is limited by the checkpoint, cache capacity, and any --request-context cap" (no branch, no prepared_context < declared_context re-derivation).

S4. Delete the help-epilog clause that duplicates the flag's own help. ignition/cli/help.py:46 is now a 200-character line: f" Context: {recipe.declared_context(checkpoint):,} tokens max (page size: {recipe.page_tokens}); --request-context can lower this (a cap below --prefill-chunk-size is rejected)". The page-multiple rule is already in the flag's help (ignition/parameters.py:1351) and the chunk interaction is a plan-time error (not help text). Keep the original short line f" Context: {recipe.declared_context(checkpoint):,} tokens max (page size: {recipe.page_tokens})" and let --request-context's option help carry the cap. Related docs churn: docs/direct-execution.md:52-58 adds --request-context to a hand-maintained preparation-flag list, i.e. the enumeration this PR just removed from docs/cli-design.md:446-453 and docs/preparation-development.md:14-25; point at the flag table/RecipeParameters instead of re-listing (or leave the list alone, since the cap "applies as it does without --direct" like every other prep flag).

S5 (naming, minor). Field is context_target (ignition/parameters.py:1344) while the flag is --request-context, and with no manifest_key the manifest/plan JSON key falls back to context_target (:620-626, to_dict), so export artifacts record a name that appears in no CLI surface. Rename the field to request_context: flag, plan JSON, manifest key and reproduction_args (:1529-1530) then agree, no other code changes.

Explicitly lean / keep as is: the single Plan.prepared_context accessor, the one bootstrap seam (ignition/preparation/bootstrap.py:132), the cap-aware bench guard reusing the same accessor, and the docs paragraphs that replaced inline flag enumerations with a pointer to RecipeParameters — that last one is the subtraction this PR does right.

#2 [high] Verification notes for the subtraction findings

Verification for the five suggestions in entry 1, all at head 503a438:

#3 [high] Research summary

Subtraction/Simplicity/Conventions review of PR #533 at head 503a438 complete; five suggestions saved to the scratchpad with exact citations, verbatim quotes and replacements (entries 1–2).

Shape of the verdict: the PR's architecture is lean and idiomatic — one declarative field, one Plan.prepared_context accessor, one bootstrap seam (ignition/preparation/bootstrap.py:132), and one genuine subtraction done right (the long inline flag enumerations in docs/cli-design.md and docs/preparation-development.md replaced by a pointer to RecipeParameters). What it adds on top is redundancy: the same min(target, ceiling) clamp is re-derived in six places, and two of those derivations are removable outright.

Highest value: (1) delete the target <= self.declared_context conjunct in the alignment gate (ignition/planning.py:198-200) — it is dead given _validate_declared_context at :197 and the clamp at :375; gate on self.prepared_context % self.page_tokens instead, which also collapses the two contradictory alignment rules the correctness lens flagged; (2) redefine Plan.context as min(self.prepared_context, self.tokens) (:367-375) so the duplicated min(self.context, self.prepared_context) at :222 and min(result.context, result.prepared_context) at :626 disappear, and drop the newly printed prepared_context key; (3) delete the third clamp in RecipeParameters.status_parts (ignition/parameters.py:1606-1607), which uses a different base (context.recipe.context) than the plan report; plus two smaller ones — the help-epilog clause duplicating the flag's own help (ignition/cli/help.py:46) and re-listing --request-context in docs/direct-execution.md's hand-maintained flag list, and a context_target → request_context rename so the field, plan JSON and manifest key match the flag.

All suggestions are behaviour-preserving (or close it in the direction the code already documents); cross-checks confirming each is safe and mechanical are in scratchpad entry 2, including that context_hint and the status_parts fragment have no test coverage and that Plan.context is read only inside planning.py.

#4 [high] Report assembly: exact AGENTS.md citation and priority order

Needed to write the final report from entries 1–2.

Exact citation for the repo-convention rule behind S3, AGENTS.md:456-460 ("Configuration" section):

Also AGENTS.md:188-193 ("Reject unsupported abstractions and churn... Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement") is the general hook for S1's "values above the recipe maximum are accepted as no-ops" branch — a second alignment rule that exists only to make an out-of-range value a no-op rather than a usage error.

Ranked fix order for the report (high → low value):

  1. S1 — delete the dead target <= self.declared_context conjunct (ignition/planning.py:198-200); gate on self.prepared_context % self.page_tokens. Pure deletion, also closes the alignment-rule contradiction (help ignition/parameters.py:1351 vs code vs docs/cli-design.md:458).
  2. S2 — make Plan.context cap-aware (ignition/planning.py:367-375) and delete both min(context, prepared_context) re-derivations (:222, :626) plus the added "prepared_context" dict key (:409). Also replace the or idiom at :375 (context_target or declared_context treats a 0 target as unset).
  3. S3 — delete the status_parts clamp (ignition/parameters.py:1606-1607; base is context.recipe.context, wrong under any adjust_context hook such as tests/cli/test_planning.py:405-421) and un-branch context_hint (ignition/cli/serve.py:73-74).
  4. S4 — revert the help-epilog over-stuffing (ignition/cli/help.py:46) and remove --request-context from the hand-maintained list in docs/direct-execution.md:52-58, the enumeration the PR deletes elsewhere.
  5. S5 — rename context_target → request_context (5 source lines, 6 test lines per entry 2) so flag/plan JSON/manifest key agree.

One-line verdict to lead with: the diff's architecture is lean and idiomatic; what remains to subtract is the cap being re-derived in six places, two of which (planning.py:198-200's condition and parameters.py:1606-1607) can be deleted outright with no behaviour change on any shipped recipe.