Subtractive report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/bca611bf-b803-4614-a853-8f6d242e6500.md

PR 533 — "Cap the per-request context target": subtraction review

Reviewed at head 02023eba against AGENTS.md:165-199, the charter (read in full), and the maintainer's earlier review of the same change in closed PR #454. Scope is subtraction only: what this change, and the code it touches, can do without.

Key findings


1. Blocking — the flag duplicates the runtime --kv-cache-limit; ~70 of 84 lines

Surface added by this PR: ignition/cli/__init__.py:167-168 (flag + help), ignition/cli/preparation.py:55 keyword and :69 forward, ignition/cli/bench.py:177, ignition/cli/serve.py:207, :291, :476, plus :319 (the plan-summary fragment), ignition/planning.py:186 (context_target field), :260 (bench required-context check), :377-381 (property), :438 (to_dict keys), :467-468 (<= 0 check), the context= keywords at :461/:549/:602/:689, the :709 rewrite, ignition/preparation/bootstrap.py:58, ignition/preparation/rebuild_manifest.py:264-265 and :389, docs/cli-design.md:446, :1443, :1493, and tests/cli/test_planning.py:211-255.

What already exists. --kv-cache-limit (docs/cli-design.md:737; semantics at :827; the "KV history ceiling" owner row at :1444, untouched by this PR) bounds shared KV history by prepared context times selected concurrency, one prepared context, or available memory — at core load, without re-export.

Why that is decisive. The description's table says the packages were "served at concurrency 1–4 (--kv-cache-limit concurrency)". The "pool = concurrency × prepared-context" scaling it reports is that runtime flag's documented behaviour. The genuinely new datum is a lower exported request ceiling: bootstrap.py:58 → BasePreparationConfig.context → the core's max_sequence_tokens, so a single request longer than N is rejected. That is one integer through one line.

Smaller version: drop --request-context from all four entry points, drop Plan.context_target and prepared_context, drop the manifest entries and the test. If the lower request ceiling is wanted, keep exactly: one Plan field, one context= keyword on plan()/fit(), bootstrap.py:58, one docs row — about 12–15 lines instead of 84.

Why nothing is lost: the memory payoff the description measures is available today with a runtime flag and no re-export; only the served-request ceiling datum goes, and it is the one thing the PR should justify against #454's question.

Cite: AGENTS.md:165-169 (need must be a maintainer request, demonstrated defect, measured problem or bad docs); AGENTS.md:188-193 ("Do not add … configuration switches without a concrete requirement"); charter "Look for the smallest footprint in shared code, or a way to solve it without new code at all."

2. Should fix — two test assertions cannot pass, and the page-multiple validation does not exist: ~5 lines

tests/cli/test_planning.py:238-241:

with pytest.raises(UsageError, match="multiple of the"):
    planning.plan(..., context=100, **base)

Searching multiple of the at this head finds only tests/cli/test_planning.py:239 and an unrelated Rust comment; the only validation is the pre-existing --prefill-chunk-size check at ignition/planning.py:636-637, which context=100 does not trip (the default chunk 4096 is a multiple of 64 and within 64..262144). planning.plan(...) therefore returns normally and the assertion fails. The description's "page-multiple validation" is not in this diff. Delete :238-241 (4 lines) or, if the validation is wanted, add it — but that is an addition, not this review's business.

tests/cli/test_planning.py:254:

assert by_key["context_target"].value.int64_value == 131072

_preparation_value emits uint_value for a non-negative int (ignition/preparation/rebuild_manifest.py:333), so int64_value reads 0. Either delete the line or read uint_value; as written it cannot pass, which shows the block was never run.

3. Should fix — the new test block repeats itself: ~10 lines

tests/cli/test_planning.py:211-255 (+47):

Lines What Why it goes
:227 assert capped.context == min(recipe.context, capped.tokens) restates :221. ~1
:229-232 clamp case, context=500000 prepared_context is one min() expression (planning.py:381); a target above the recipe max exercises no distinct branch from :224-226. ~4
:242-244 d = capped.to_dict(); assert d["context_target"] == 131072 restates :225; the to_dict key is also visible in the new :438. ~2
:246-253 8-line manifest encode/decode/round-trip re-proves from_plan's generic add() None skip (rebuild_manifest.py:350-352) and the scope/value plumbing already exercised by the sibling manifest test at tests/cli/test_planning.py:92-106; :248-249 (both strings in reproduction_args) is the part that is new. ~6

Smaller version: keep the no-op case (:217-221), one capped case (:223-226), one pytest.raises for 0, :248-249 for reproduction args, and one scope assertion — about 15 lines instead of 47.

4. Nit — prepared_context's body duplicates context: ~2 lines

ignition/planning.py:376-381:

@property
def prepared_context(self) -> int:
    """The context the prepared core serves per request; the recipe max when no target is set."""
    if self.context_target is None:
        return self.recipe.context
    return min(self.recipe.context, self.context_target, self.tokens)

Plan.context (:371-374) is min(self.recipe.context, self.tokens), so min(recipe.context, N, tokens) == min(self.context, N).

Smaller version:

return self.context if self.context_target is None else min(self.context, self.context_target)

Do not cut the context_target is None early return — it must yield recipe.context, which can exceed the pool-bound self.context; removing it would break the no-op claim. The same applies to effective_context = min(result.context, result.prepared_context) at :709, which is load-bearing for the no-target case.

5. Nit — the <= 0 check lives in fit() and re-runs per attempt: ~2 lines

ignition/planning.py:467-468. fit() is re-entered by plan() once per candidate world size and per shortfall probe (:689, :693-705), so the check runs on every attempt, and it is the only flag validation outside Plan.__post_init__, where every other flag is validated (:266-296). Moving it beside them (or deleting it with finding 1) removes 2 lines and the re-checks.

6. Nit — the docs say the cap three times: ~2 lines

The row's trailing "a core's catalog is fixed at export, so changing it requires re-export" also copies the clause --mixed-prefill already carries at :447; one clause is enough.

Left behind (dead or inconsistent after this change)

Count of the change

pr_files at 02023eba: 9 files, +84 / −18 — docs/cli-design.md +3/−2, ignition/cli/__init__.py +2, bench.py +3/−1, preparation.py +1/−1, serve.py +5/−4, planning.py +19/−9, bootstrap.py +1/−1, rebuild_manifest.py +3, tests/cli/test_planning.py +47. Code+docs = +37/−18; tests = +47/−0.

Removable: ≈5 (finding 2) + ≈10 (finding 3) + 2 (finding 4) + 2 (finding 5) + 2 (finding 6) ≈ 22 of the 84 added lines in 4 places with the flag kept; ≈70 of 84 with the flag dropped (finding 1).

Verified load-bearing — do not propose cutting

Open questions / what I could not find

For completeness, the planning.py:709-711 hunk as it stands at this head is already the single-message form; it saves nothing and removes nothing:

effective_context = min(result.context, result.prepared_context)
if chunk > effective_context:
    raise UsageError(f"--prefill-chunk-size {chunk:,} exceeds the {effective_context:,}-token context this plan allows")