Code review summary scratchpad · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/5bfcbe32-b998-4030-be0e-1654d7f58270.md

#1 [high] PR #533 state, diff shape, and what is verified clean

PR #533 "Cap the per-request context target", author roobyz, head 1a006c6, +35/−15, 7 files, no reviews, no CI. Supersedes closed #454 (CHANGES_REQUESTED by yatesdr, 2026-11-23). Discord line present ("Discord: rzr2020"), so no Discord finding.

Load-bearing change: ignition/preparation/bootstrap.py:58 "context": plan.prepared_context (was plan.recipe.context) in common_preparation_kwargs (bootstrap.py:47-65) — the single funnel to BasePreparationConfig.context (bootstrap.py:33). Everything else (+34 lines) is plumbing to that datum.

Verified: cap reaches the core — helios/src/server/config.rs:131 reads max_sequence_tokens as prepared_sequence_tokens, :148 sets limits.max_sequence_tokens, enforced at helios/src/server/request.rs:350 and scheduler.rs:2289/:2358. Verified no-op when unset: planning.py:369-373 returns recipe.context; Plan.context untouched (planning.py:363-366). Other paths that do thread the flag: serve.py:289 (_prepare), serve.py:472 (debug_serve), bench.py:177; derive() at ignition/cli/preparation.py:56,68 → planning.plan(..., context=) :591,674 → fit(..., context=) :453 → Plan(context_target=context) :535. Plan is a frozen dataclass, context_target default None (planning.py:176) so all existing constructions still work. Positive-target check: planning.py:459-460 inside fit. Chunk check: planning.py:692-701 with effective_context = min(result.context, result.prepared_context). Reproduction/manifest paths with no cap: rebuild_manifest.py:231-318 (reproduction_arguments), :343-395 (from_plan), planning.py:389-442 (to_dict, "context" at :430). No test anywhere: grep of tests/ for request_context|prepared_context|context_target → no matches. Flag registration + help: ignition/cli/init.py:167-170, group "capacity and compression" (shared by export/bench/debug-serve). Docs: docs/cli-design.md:446 new row; also rewords :1443 and :1493.

#2 [high] Blocker 1: --request-context silently dropped on multi-host export

ignition/cli/serve.py:193-206 — _export_hosts calls planning.plan(...) with mixed_prefill/prompt_logprobs/expert_scale_compression/online_mxfp8/mla_compute_mode/row_shard_prefill and no context=; the last keyword is row_shard_prefill=args.row_shard_prefill (:206). Reached from export() at serve.py:153-156 when args.ranks > 1. Because plan() defaults context=None (planning.py:591), context_target stays None, prepared_context returns recipe.context (:371-372), so the core is prepared at the recipe maximum with no warning. Violates charter "Don't silently ignore API fields … Never accept it and quietly drop it (#417)"; multi-host export is a supported shape (AGENTS.md:157-163) and is where the pool is largest. Fix: add context=args.request_context to the call. Test that would pin it: a planning-level assertion that a 1-host and 2-host plan of the same recipe produce the same prepared_context, or a check that common_preparation_kwargs(plan)["context"] honours the flag.

#3 [high] Blockers 2-5: page alignment, unreported setting, bench check, conditional VRAM claim

BLOCKER 2 — the cap is never required to be page-aligned, so an exported core can fail to load. Producer: ignition/planning.py:369-373 min(recipe.context, context_target, tokens), consumed at bootstrap.py:58 → BasePreparationConfig.context → the core's server config max_sequence_tokens (helios/src/server/config.rs:131 prepared_sequence_tokens, :148 limits.max_sequence_tokens). Helios rejects a core unless BOTH values are exact multiples of the page size: helios/src/model/catalog.rs:50-57 (is_multiple_of(page_tokens.max(1)), is_multiple_of(page_tokens)), error at :70 "invalid prepared model configuration". Also model.rs:268 fit_context. Only validation today: positivity at planning.py:459-460, and the chunk check at :694-700. Nothing in ignition/ checks a multiple-of-page rule (grep for "% page_tokens"/is_multiple → only the prefill-chunk multiple-of-64 check at :621-623). Consequence: ignition export MODEL --request-context 200000 with a 128-token page = 1562.5 pages → prepare/tune/export succeed, flare run dies with "invalid prepared model configuration" naming neither the flag nor the page size. Fix (smallest, one home): validate/floor in Plan.__post_init__ (planning.py:212-289, where plan-field invariants already live) against self.page_tokens — either reject with the nearest lower multiple, or floor the way guaranteed_tokens floors (planning.py:378). This also absorbs the <=0 check at :459-460, so the two checks become one and cannot be bypassed by a direct Plan construction. Caveat: pages are 0 before fit's replace (:541), so validate context_target % self.page_tokens, not prepared_context % ....

BLOCKER 3 — the cap is absent from the plan report and the rebuild manifest.

BLOCKER 4 — benchmark validation still measures against the uncapped context. planning.py:248 if selection.required_context > self.context: — self.context is untouched by this PR (planning.py:363-366), so with a cap set the check compares the workload with a context larger than the core serves, and the real failure lands in ignition/bench/runner.py:388 ("benchmark case exceeds prepared capacities") after the whole GPU preparation, tuning and graph capture. Fix: compare self.prepared_context (works there because bench sets benchmark_selection via replace at bench.py:178, after pages exist), and mention the cap in the message; alternatively reject the flag in bench like --mixed-prefill (bench.py:115-116).

BLOCKER 5 — the claimed VRAM benefit is stated unconditionally in the description and docs/cli-design.md:446, but the mechanism and the measurement are the runtime --kv-cache-limit. page_ceiling (helios/src/runtime_core/memory.rs:284-331): KvCacheLimit::Memory returns Ok(None) — no ceiling; context gives one history, concurrency one history per active request. Default is memory (docs/cli-design.md:738, :828). The author's own table was produced with --kv-cache-limit concurrency. The pool in memory mode is filled from free memory and only bounded by the prepared virtual extent (memory.rs:403, :435 pages.iter().map(|s| s.maximum)), whose page maximum comes from recipe code outside this repo (AGENTS.md:379-381), so the unconditional claim cannot be verified from this tree. Fix: state the condition in the docs row and the description, or add one default-mode measurement row. AGENTS.md:134-137 forbids publishing a claim whose material limitations must be guessed.

#4 [high] Should fix, Nits, and open questions

SHOULD FIX S1 — justification argues from a charter non-goal. docs/cli-design.md:446 says "buys concurrency headroom in a memory-constrained multi-model deployment"; description says "leave no room for a second model" / "the headroom a co-run needs". AGENTS.md:171-175 lists multi-model hosting/routing as requiring an explicit maintainer decision; none is cited. Fix: give the single-model rationale (a lower prepared context leaves more of the budget for prefix-cache snapshots or a higher --max-concurrency on the same GPU) or cite the sign-off. Do not restate a co-run use as the purpose.

S2 — no test touches any of this. grep of tests/ for request_context|prepared_context|context_target → no matches; the diff adds none. AGENTS.md:194-199 requires tests for affected behaviour. One test in tests/cli/test_planning.py using the existing fixture (_recipe at :22-54: context 262144, page_tokens 64, prefill_chunk 4096; _gpu at :57-59) covers everything cheaply:

S3 — measurement boundary and naming in the description. (a) "At concurrency 8 at the 256K max, the model would consume most of the 96 GB VRAM..." is a prediction sitting inside the measured-results section (AGENTS.md:95-102 requires expectation and measurement be distinguished) — mark it as an extrapolation or cut it. (b) "export, serve, and bench": there is no serve subcommand; the three are export, bench, debug-serve (ignition/cli/init.py:40, :51, :55). (c) "byte-equivalent to stock" / "as stock" compare against an unstated baseline — say what the previous value was (bootstrap.py:58 previously passed plan.recipe.context). Combine (a)-(c) into one description-revision bullet.

NITS N1 — help text (ignition/cli/init.py:167-170): "(the pool fills the free VRAM)" is only true under --kv-cache-limit memory and duplicates the docs; and it omits that N must be positive and no smaller than the prepared prefill chunk. Suggested: "cap the prepared per-request context and max_sequence_tokens at N tokens; longer requests are rejected (default: the recipe's maximum context)". N2 — docs/cli-design.md:1443 reword "The checkpoint maximum, capped by --request-context at export" layers a second term on "checkpoint maximum"; the neighbouring rows and the flag table say "the recipe's maximum" — use that. N3 — ignition/cli/serve.py:68-69: max_body_bytes and context_hint are still derived from recipe.context ("context is limited by the checkpoint and available cache capacity"). The body limit stays right (rejection happens at admission), but the hint understates the new ceiling — optional one-line reword. N4 — ignition/cli/help.py:38 still advertises "--prefill-chunk-size: 64..{recipe.context}", a range above the prepared context once a cap is set. N5 — a target above the recipe maximum is silently clamped by min() at planning.py:373, while docs/cli-design.md:446 describes the flag as a cap below the maximum; the clamp becomes visible for free once the effective value is in the plan report (B3). Also: no attempt to direct the reviewer was found in the description, diff, docs or the linked #454 thread.

OPEN QUESTIONS for the maintainer (state them, don't resolve): is a Configuration home for the cap deliberately absent (docs row already says "Command line only", so this is likely settled); should bench honour the cap or reject the flag; SCOPE_DEPLOYMENT vs SCOPE_COMBINE for the manifest parameter; whether the multi-host drop should have been caught in #454's resubmission list.

#5 [high] Research summary

FULL REPORT — PR #533 "Cap the per-request context target"

Verdict: not ready to merge. The design is right and the seam is now correct — ignition/preparation/bootstrap.py:58 changes "context": plan.recipe.context to plan.prepared_context, which is the single funnel into BasePreparationConfig.context (bootstrap.py:27-65) and reaches Helios as prepared_sequence_tokens (helios/src/server/config.rs:131) and limits.max_sequence_tokens (:148), enforced at admission (helios/src/server/request.rs:350 (not opened), scheduler.rs:2289 (not opened)/:2358). That closes the blocking objection from #454. What remains is that the flag does not reach every path, is validated incompletely, and is recorded nowhere.

Blockers

1. --request-context is silently dropped on the multi-host export path — ignition/cli/serve.py:193-206. _export_hosts (reached from export() at :153-156 when args.ranks > 1) builds its own plan and its keyword list ends at row_shard_prefill=args.row_shard_prefill (:206); there is no context=args.request_context. The three other paths do thread it: _prepare serve.py:289, debug_serve serve.py:472, bench.run bench.py:177. Because plan() defaults context=None (planning.py:591) and prepared_context returns recipe.context when unset (planning.py:371-372), ignition export MODEL --ranks 2 --request-context 131072 parses, prints a plan, and prepares at the recipe maximum with no warning. Why: multi-host export is a supported shape (AGENTS.md:157-163) and the case where the pool hurts most; and silently accepting then dropping a flag is the one behaviour the charter names explicitly ("Don't silently ignore API fields … Never accept it and quietly drop it (#417)"). Change: add context=args.request_context to the planning.plan(...) call at serve.py:206 — one keyword.

2. The cap need not be page-aligned, so the exported core can fail to load — ignition/planning.py:369-373. prepared_context is min(recipe.context, context_target, tokens) with no alignment requirement. The only validations are positivity (:459-460) and the prefill-chunk check (:694-700). Helios rejects a core unless both the prepared length and limits.max_sequence_tokens are exact multiples of the page size (helios/src/model/catalog.rs:50-57, error at :70 "invalid prepared model configuration"). With a 128-token page, --request-context 200000 is 1562.5 pages: preparation, tuning and export all succeed, then flare run fails with an error that names neither the flag nor the page size. Why: stock is safe only because recipe.context is a declared page multiple; a user value is the first unaligned input on this path. Every alignment check lives after export. Change (smallest home): validate in Plan.__post_init__ (planning.py:212-289), where plan-field invariants already live — reject with the nearest lower multiple, or floor the way guaranteed_tokens floors (:378). Validate context_target % self.page_tokens (pages are still 0 before fit's replace at :541). This also absorbs the <= 0 check at :459-460 into the invariant that every Plan must satisfy, so a direct construction cannot bypass it.

3. The cap is absent from the plan report and the rebuild manifest — ignition/planning.py:389-442, ignition/preparation/rebuild_manifest.py:231-318 and :343-395. Plan.to_dict publishes "context": self.context, "checkpoint_context": self.recipe.context (:430) and no key for the target; because Plan.context is deliberately stock, a core exported with --request-context 131072 prints context: 262144 — the printed plan misreports what was prepared. That dict is printed at serve.py:215, serve.py:485 and bench.py:182, and bench republishes a hand-picked subset as details["configuration"]["preparation"] (bench.py:243-248). reproduction_arguments emits --max-concurrency (:257), --prefill-chunk-size (:263), --row-shard-prefill (:306) and never --request-context, so flare inspect prints an export command that rebuilds the uncapped core; from_plan records a SCOPE_DEPLOYMENT parameter for every sibling option (prefill_chunk :387, max_concurrency :380, row_shard_prefill :392) and none for the cap, so two cores differing only in prepared context are indistinguishable. Why: AGENTS.md:452-456 requires a new preparation setting to be "carried through the plan into the recipe's PreparationConfig, so the plan, its printed report, and its recorded measurements describe what was prepared". The core's own catalog is right, but the artifact that is supposed to describe and reproduce it is not. Change: add "prepared_context" (and the requested "context_target" when set) to to_dict; in reproduction_arguments add if plan.context_target is not None: args.extend(['--request-context', str(plan.context_target)]); in from_plan add add('request_context', SCOPE_DEPLOYMENT, plan.context_target) — add() already skips None (:348-350), so uncapped packages stay byte-compatible.

4. The headline VRAM claim is stated unconditionally; the measurement and the sizing both depend on a runtime flag it never names — description and docs/cli-design.md:446. The shipped docs row says shortening the context "buys concurrency headroom in a memory-constrained multi-model deployment, since the per-request cache allocation is sized from the prepared context", and the description reads "capping … shrinks the KV pool and frees VRAM". The pool ceiling that the cap controls comes from page_ceiling (helios/src/runtime_core/memory.rs:284-331), which returns Ok(None) — no ceiling — under the default KvCacheLimit::Memory; only context (one history) and concurrency (one per active request) apply it (docs/cli-design.md:738, :828-833). The table was produced with --kv-cache-limit concurrency, and the author's evidence line says so, but neither artifact states the condition. Under memory the pool is bounded by available memory and by the prepared virtual extent (memory.rs:403, :435), whose page maximum is set by recipe code living outside this repository (AGENTS.md:379-381), so the unconditional claim cannot be verified from this tree. Why: AGENTS.md:134-137 forbids publishing a claim whose material limitations must be guessed, and this one ships in main's docs. Change: state the condition in the docs row and the description ("with --kv-cache-limit context or concurrency; the default memory sizes the pool from free memory"), or add one memory-mode row to the table.

Should Fix

5. Benchmark validates against the uncapped context — ignition/planning.py:248. if selection.required_context > self.context still compares against min(recipe.context, tokens) (:363-366), which this PR deliberately leaves stock, so with a cap set a --contexts selection can exceed what the prepared core serves and pass planning; the failure then lands in ignition/bench/runner.py:388 (not opened) ("benchmark case exceeds prepared capacities") after the whole GPU preparation, tuning and graph capture. The PR already handles the analogous case for the chunk (:694-700), so this reads as an oversight. Change: compare self.prepared_context (one word; works there because bench attaches benchmark_selection via replace at bench.py:178, after pages exist) and name the cap in the message. Smaller than the alternative of rejecting the flag in bench.Settings.from_args the way --mixed-prefill is rejected (bench.py:115-116).

6. Nothing in the tree tests any of this — tests/ has no match for request_context, prepared_context, context_target. Given finding 1 (a forwarding bug) and finding 2 (an unvalidated input), AGENTS.md:194-199's requirement is not met. One test in tests/cli/test_planning.py using the existing fixture (_recipe :22-54 — context 262144, page_tokens 64, prefill_chunk 4096; _gpu :57-59) covers it: unset target → prepared_context == recipe.context; target 65536 → 65536; target above the pool → tokens; context=0 → UsageError; a non-page-multiple target → the new rejection; common_preparation_kwargs(plan, …)["context"] == prepared_context (the one line that carries the cap); and the to_dict/manifest/reproduction-arg assertions modelled on the existing row_shard_prefill loop at :92-106. Add one assertion that the multi-host path forwards the target.

7. Prose boundary and naming in the description (one bullet, mechanical): (a) "At concurrency 8 at the 256K max, the model would consume most of the 96 GB VRAM…" is a prediction inside the measured-results section — mark it an extrapolation or cut it (AGENTS.md:95-102); (b) there is no serve subcommand — the three are export, bench, debug-serve (ignition/cli/init.py:40, :51, :55); (c) "byte-equivalent to stock" and "as stock" compare against an unstated baseline — say that preparation previously passed plan.recipe.context (bootstrap.py:58).

8. The stated justification argues from a charter non-goal — description ("leave no room for a second model", "the headroom a co-run needs") and docs/cli-design.md:446 ("multi-model deployment"). AGENTS.md:171-175 makes multi-model hosting/routing require an explicit maintainer decision; none is cited. The flag itself is a preparation capacity and is in scope. Change: give the single-model rationale (a lower prepared context leaves more of the fixed budget for prefix-cache snapshots or a higher --max-concurrency on the same GPU), or cite the sign-off.

Subtract / Simplify

Could remove ~7 of +35 added lines, and roughly half of the new docs row, without losing behaviour:

  1. Collapse prepared_context onto context (planning.py:368-373, −2 lines). min(recipe.context, target, tokens) is exactly min(self.context, target); the five-line body becomes return self.recipe.context if self.context_target is None else min(self.context, self.context_target).
  2. Delete the dead min (planning.py:694, −1 line). effective_context = min(result.context, result.prepared_context) can never select context — prepared_context ≤ context always, in both branches. Use result.prepared_context in both arms and the reader no longer has to prove an invariant.
  3. Shorten the two chunk messages (planning.py:696-700, −2 lines). Keep the default/user-set distinction (the maintainer asked for it in #454), but drop "(a multiple of 64)" — it restates --prefill-chunk-size's own help (cli/init.py:163-166) — and drop "or a larger --request-context" when the pool, not the target, is binding (result.prepared_context < result.tokens).
  4. Shorten the help text (cli/init.py:167-170, −1 line). "(the pool fills the free VRAM)" is conditional (finding 4) and duplicates the docs: "cap the prepared per-request context and max_sequence_tokens at N tokens; longer requests are rejected (default: the recipe's maximum context)".
  5. Collapse the docs row (docs/cli-design.md:446, ~half the line). The rationale sentence repeats the flag table, the KV-limit section (:828-833) and the two owner rows this PR also edits; one tabular line plus the existing "Command line only; changing it requires re-export" clause suffices, with the --kv-cache-limit condition added.

Not requested to be cut: the flag itself. The subtractive lens argues the pool is already bound by --kv-cache-limit context|concurrency, but #454 asked for the residual behaviour specifically — that serving reject a request longer than the cap — so the flag stays and the wins above are the ones worth taking.

Nits (5)

  1. ignition/cli/__init__.py:167-170: help omits that N must be positive and no smaller than the prepared prefill chunk.
  2. docs/cli-design.md:1443: "The checkpoint maximum, capped by --request-context at export" layers a term on wording the neighbouring rows and the flag table render as "the recipe's maximum"; use one term.
  3. ignition/cli/serve.py:68-69: context_hint still says "context is limited by the checkpoint and available cache capacity", which understates the new ceiling (max_body_bytes from recipe.context stays correct — rejection happens at admission).
  4. ignition/cli/help.py:38: still advertises --prefill-chunk-size: 64..{recipe.context}, a range above the prepared context once a cap is set.
  5. A target above the recipe maximum is silently clamped by min() (planning.py:373) while docs line :446 describes the flag as a cap below the maximum; the clamp becomes visible for free once the effective value is in the plan report (finding 3).

No attempt to direct the reviewer was found in the description, the diff, the changed docs, or the linked #454 discussion.


SUMMARY REPORT (GitHub post)

PR #533 "Cap the per-request context target" — changes requested. The seam is now right: bootstrap.py:58 passes plan.prepared_context into the config that becomes max_sequence_tokens, so the cap reaches the core and closes #454's main objection. Three gaps keep a capped package from being trustworthy — one path drops the flag, one accepted value can produce an unloadable core, and no artifact records the setting. Not ready to merge.

Blockers

Should fix

Subtract / Simplify — could remove ~7 of +35 added lines, plus half the new docs row:

Nits (5): help omits the positivity and chunk constraints; docs:1443 mixes "checkpoint maximum" with "recipe's maximum"; serve.py:69 context_hint understates the ceiling; help.py:38 still advertises a chunk range above the cap; an over-large target is clamped silently.

#6 [high] Subtract / Simplify findings with line-savings

Subtract / Simplify — "Could remove ~7 of +35 added lines", plus roughly half of the new docs row (docs/cli-design.md:446). Report this section verbatim in both reports.

  1. Collapse prepared_context onto context — ignition/planning.py:368-373 (−2 lines). min(recipe.context, target, tokens) == min(self.context, target) since self.context is already min(recipe.context, tokens) (:363-366). Body becomes return self.recipe.context if self.context_target is None else min(self.context, self.context_target).
  2. Delete the dead min — ignition/planning.py:694 (−1). effective_context = min(result.context, result.prepared_context) can never select context: prepared_context ≤ context in both branches. Use result.prepared_context in both arms of :695-700.
  3. Shorten the two chunk messages — ignition/planning.py:696-700 (−2). Keep the default vs user-set split (explicitly requested in #454), but drop "(a multiple of 64)" (restates --prefill-chunk-size help at cli/init.py:163-166) and drop "or a larger --request-context" when the pool binds (result.prepared_context < result.tokens).
  4. Shorten the help text — ignition/cli/init.py:167-170 (−1). "(the pool fills the free VRAM)" is conditional (see blocker 4) and duplicates the docs. Suggested: "cap the prepared per-request context and max_sequence_tokens at N tokens; longer requests are rejected (default: the recipe's maximum context)".
  5. Collapse the docs row — docs/cli-design.md:446 (~half the line). The rationale sentence repeats the flag table, the KV-limit section (:828-833) and the two owner rows this PR also edits (:1443, :1493). One tabular line plus the existing "Command line only; changing it requires re-export" clause, with the --kv-cache-limit condition added.

Do NOT ask for the flag to be deleted: the subtractive lens argues --kv-cache-limit context|concurrency already bounds the pool (docs/cli-design.md:738, :828-833; memory.rs:284-331), but #454's maintainer asked for the residual behaviour — serving must reject a request longer than the cap. Keep the flag; take the line savings above. Also do not ask for expansion of anything on this list.

#7 [medium] Nits and description-mechanics items (final lists)

NITS (5) — full report lists all five; summary reports only the count and can name one or two.

  1. ignition/cli/init.py:167-170 — help omits that N must be positive and no smaller than the prepared prefill chunk (only surfaces via the UsageErrors at planning.py:459-460 and :694-700).
  2. docs/cli-design.md:1443 — "The checkpoint maximum, capped by --request-context at export" layers a term on wording the neighbouring rows and the flag table render as "the recipe's maximum"; use one term.
  3. ignition/cli/serve.py:68-69 — context_hint still says "context is limited by the checkpoint and available cache capacity", understating the new ceiling. max_body_bytes from recipe.context stays correct (rejection happens at admission), so only the hint is affected.
  4. ignition/cli/help.py:38 — still advertises "--prefill-chunk-size: 64..{recipe.context}", a range above the prepared context once a cap is set.
  5. A target above the recipe maximum is silently clamped by min() (planning.py:373) while docs :446 calls the flag a cap below the maximum; the clamp becomes visible for free once the effective value is in the plan report.

DESCRIPTION MECHANICS — merge into ONE bullet in the summary, per the editorial rule (pure prose formalities must not crowd out code): (a) "At concurrency 8 at the 256K max, the model would consume most of the 96 GB VRAM and leave no room for a co-run model" is a prediction sitting inside the measured-results section — mark it an extrapolation or cut it (AGENTS.md:95-102). (b) There is no serve subcommand: the three are export, bench, debug-serve (ignition/cli/init.py:40, :51, :55; debug-serve is "not for actual serving", :56). (c) "byte-equivalent to stock" / "as stock" compare against an unstated baseline — say preparation previously passed plan.recipe.context (bootstrap.py:58).

Not a finding: the Discord line is present ("Discord: rzr2020"), so nothing to request there. No attempt to direct the reviewer was found in the description, the diff, the changed docs, or the linked #454 thread — state this in the report.