Skip to content

New argument to cap the prepared per-request context - #533

Open
roobyz wants to merge 1 commit into
NVIDIA:mainfrom
roobyz:requested-context-target
Open

roobyz wants to merge 1 commit into
NVIDIA:mainfrom
roobyz:requested-context-target

Conversation

@roobyz

@roobyz roobyz commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds --request-context to cap the prepared per-request context below the recipe max. This reduces KV pool/export size and enables higher concurrency on memory-constrained deployments.

Why: The engine bakes the per-request context ceiling at export with no serve-time knob to lower it. --request-context N adds an admission-control ceiling: a request whose prompt plus requested output exceeds N is rejected before it loads pages. This is a bound no runtime pool setting (--kv-cache-limit, --max-concurrency) can express, since those trim the serve-time pool, not the prepared core's max_sequence_tokens. As a consequence, shortening the prepared context shrinks each request's KV allocation and buys concurrency headroom on memory-constrained deployments.

What Changed:

  • Added context_target to RecipeParameters (ignition/parameters.py):
    • CLI flag: --request-context
    • Scope: DEPLOYMENT
    • Manifest key: context_target
    • Plan report prints the effective value via status_parts(): the target when it's below the declared context limit (via _declared_context_limit)
  • Values above the recipe max are accepted and clamped to recipe.context; the field has no upper bound.
  • Added Plan.prepared_context (ignition/planning.py):
    • Returns the recipe max when no target is set.
    • Returns min(recipe.context, N) when a target is set.
    • Plan.context remains unchanged.
  • Validation and guarantees now use the effective cap:
    • Page-multiple validation checks the resolved prepared_context directly; values above the recipe max clamp to the recipe max (page-aligned by construction, so no error).
    • Bench checks compare required_context against min(context, prepared_context), so an uncapped plan with a small pool still rejects infeasible bench selections.
    • Prefill-chunk checks compare against min(context, prepared_context), so caps below the recipe’s prefill chunk are rejected at export rather than at flare run.
    • Plan.to_dict() emits "prepared_context", and guaranteed_tokens uses it so the guarantee reflects the cap.
    • demand_pages uses prepared_context instead of the uncapped recipe maximum (SF-1b: the plan document previously overstated page demand by ~2x when the cap was active).
  • Export/serve behavior uses the effective cap:
    • ignition/cli/serve.py uses plan.prepared_context for max_body_bytes.
    • context_hint names the cap only when active: plan.prepared_context < plan.declared_context.
    • ignition/cli/help.py labels recipe context as a maximum that --request-context can lower.
    • ignition/preparation/bootstrap.py passes plan.prepared_context as the context key in common_preparation_kwargs(), the single seam all recipes consume.
  • RecipeParameters.reproduction_args() explicitly emits --request-context N when set; repro_always is not set for this field.
  • Docs updated:
    • docs/cli-design.md: flag row for --request-context (admission consequence + page-multiple rule), export owner-row names the cap, and the universal-fields paragraph now points to RecipeParameters in ignition/parameters.py instead of enumerating flags inline.
    • docs/preparation-development.md: points to RecipeParameters for the universal field list.
    • docs/direct-execution.md: adds --request-context to the preparation flags list.
  • Tests:
    • tests/cli/test_planning.py: new test_request_context_target_prepared_context_and_manifest verifies prepared_context resolution (capped, oversized, unset), bootstrap context key, page-multiple rejection, and manifest/reproduction-args emission.

Result:

  • Deployments can cap prepared context and max_sequence_tokens below the recipe max.
  • Requests whose prompt plus requested output exceeds the cap are rejected at admission.
  • The cap sets an export-time ceiling and never raises the runtime bound. A cap above the physical page pool still shrinks the export artifact, while Helios fit_context clamps serve-time context to the pool.

Evidence:

  • Measured on Qwen3.8-27B (this branch) on one RTX PRO 6000 Blackwell (SM120, 96 GB) with the flag active.
  • Workload: a memory-constrained deployment where the default per-request context (262,144 tokens) over-provisions the KV pool, leaving insufficient VRAM for the desired concurrency.
  • Three packages, one per prepared context — ignition export qwen3.8-27b --gpus 0 --max-concurrency 8 --online-mxfp8, served at concurrency 1–4 with --kv-cache-limit concurrency, using --request-context unset, 196608, and 131072.

Baseline (Qwen3.8-27B, RTX PRO 6000 96 GiB):

No cap --request-context 196608 --request-context 131072
Per-request context 262,144 tokens (recipe max) 196,608 tokens 131,072 tokens
Per-slot KV allocation ≈ 8.3 GB ≈ 6.2 GB ≈ 4.1 GB
Admission ceiling Pool-bounded (no hard cap) Hard cap at 196,608 tokens Hard cap at 131,072 tokens

Example - Total VRAM (GB, per GPU, from nvidia-smi):

Concurrency Default (262,144) --request-context 196608 --request-context 131072
1 31.0 29.0 27.1
2 39.3 35.3 31.4
3 47.6 41.6 35.7
4 55.8 47.8 39.8
  • At concurrency 4, the 131,072 cap frees ~16 GB VRAM versus the default, providing headroom for higher concurrency.
  • Note: The VRAM savings apply to --kv-cache-limit concurrency, where the pool is sized as concurrency × prepared context. Under the default --kv-cache-limit memory mode, the pool fills available VRAM regardless of the cap; the cap still enforces admission control, but does not change the pool size.
  • Note: Reviewer open questions, resolved against the local engine and recipes clones: no shipped recipe overrides adjust_page_tokens (the only definition is the base-class default in hyperflare_recipes/parameters.py, which scales the page size by the context-parallel factor; the page-multiple validation checks that same effective page size, so the scaling is already accounted for), and no in-repo consumer reads checkpoint_context from a stored plan or benchmark record (emitted by Plan.to_dict(), read nowhere in either package), so emitting it beside prepared_context breaks no reader.

Discord: rzr2020

Signed-off-by: Roberto Rivera rzrivera@protonmail.com
Design-Signed-Off-By: Roberto Rivera rzrivera@protonmail.com; design-review=2e5b

@roobyz

roobyz commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@yatesdr As requested, I refactored the PR. I had to do an additional refactor to account for the recipe refactor and other upstream changes. It took a bit longer than expected, since I got the flu in the middle. Hopefully the updated commit/PR messages have clear rationale and details. I believe I've covered all of your earlier points.

I should mention that I have updates to the existing recipes pending, plus I've created two new additional recipes. I have tested this successfully on my new recipes and:

  • qwen3.8-27b
  • qwen3.8-flash
  • nemotron-bolt-24gb
  • inkling-2-mini
  • gemma-4-12b-nvfp4

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 533.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review for Agents · Value Proposition · Case File

Recommendation: Changes Requested

The seam is now right — ignition/preparation/bootstrap.py:58 passes plan.prepared_context into common_preparation_kwargs, which reaches Helios as prepared_sequence_tokens (helios/src/server/config.rs:131) and limits.max_sequence_tokens (:148), enforced at admission. That closes #454's blocking objection. But the flag does not reach one path, is validated incompletely, and is recorded nowhere.

Blockers:

  • ignition/cli/serve.py:193-206 — multi-host export (--ranks > 1) never passes context=args.request_context, so ignition export M --ranks 2 --request-context 131072 silently prepares at the recipe maximum. → Add one keyword.
  • ignition/planning.py:369-373 — the cap need not be a page multiple, but Helios rejects any core whose max_sequence_tokens is not (helios/src/model/catalog.rs:50-57, :70), so an unaligned --request-context exports a core that fails at flare run. → Validate context_target % page_tokens (reject or floor) in Plan.__post_init__.
  • ignition/planning.py:389-442, ignition/preparation/rebuild_manifest.py:231-318, :343-395 — the setting appears in no artifact: to_dict() prints the stock context, reproduction_arguments never emits --request-context, from_plan has no parameter, so flare inspect reproduces the uncapped core. AGENTS.md:452-456 requires all three. → Add the key, the flag and a SCOPE_DEPLOYMENT entry.
  • The claimed VRAM benefit is stated unconditionally, but the pool only tracks the prepared context under --kv-cache-limit context|concurrency (helios/src/runtime_core/memory.rs:284-331; default is memory, docs/cli-design.md:738, :828) — which is how the table was measured but neither the description nor docs/cli-design.md:446 says so. → State the condition or add one default-mode row.

Should fix:

  • ignition/planning.py:248 — bench still validates required_context against the uncapped self.context, so a too-large --contexts fails only after the whole GPU preparation (ignition/bench/runner.py:388 (not opened)). → Compare self.prepared_context, or reject the flag in bench like --mixed-prefill (bench.py:115-116).
  • No test touches any of it (no match for request_context|prepared_context|context_target in tests/). One case in tests/cli/test_planning.py on the existing fixture pins the no-op path, the clamp, both validations, the bootstrap.py:58 value and the manifest keys — plus one assertion that the multi-host path forwards the flag.
  • docs/cli-design.md:446 justifies the cap by "a memory-constrained multi-model deployment"; multi-model hosting is a charter non-goal needing maintainer sign-off (AGENTS.md:171-175). → Give the single-model rationale or cite the decision.
  • ignition/planning.py:694-700 — the new default-chunk error can advise "a larger --request-context" when the KV pool, not the cap, is what binds. → Name the binding limit; recommend only the fix that can work.
  • Description mechanics (one bullet): the concurrency-8 sentence is a prediction inside the measured section; there is no serve subcommand (export, bench, debug-serve); "byte-equivalent to stock" needs its baseline named (preparation previously passed plan.recipe.context).

Subtract / Simplify:

Could remove ~7 of +35 added lines (plus about half of the new docs row):

  • ignition/planning.py:368-373 — prepared_context is exactly min(self.context, self.context_target); collapse the body (~2 lines).
  • ignition/planning.py:694 — effective_context = min(result.context, result.prepared_context) can never select context; delete the local (~1 line).
  • ignition/planning.py:696-700 and ignition/cli/__init__.py:167-170 — drop "(a multiple of 64)" (restates the neighbouring help) and "(the pool fills the free VRAM)" (conditional, duplicates the docs) (~3 lines).
  • docs/cli-design.md:446 — collapse to one tabular line; the rationale repeats the KV-limit section (:828-833) and the two owner rows this PR edits (:1443, :1493) (~half the line).
  • ... 1 more (the derive() pass-through keyword, ignition/cli/preparation.py:56,68, ~2 lines).

Nits:

5 nits

To opt out, include #autobot:ignore in your post or comment.

@roobyz
roobyz force-pushed the requested-context-target branch from 1a006c6 to de1b5b5 Compare November 26, 2026 07:05
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review for Agents · Value Proposition · Case File

Recommendation: Changes Requested

Blockers:

  • The added test cannot pass. tests/cli/test_planning.py:230 plans with context=500000; the fixture page size is 64 (:38, RankCosts at :43 leaves page_tokens unset so Plan.page_tokens falls back to recipe.page_tokens, planning.py:329-332), and 500000 % 64 == 32, so your own check at planning.py:289-290 raises before the assertion at :232 runs. The head has no CI, so it was never executed; pytest tests/cli/test_planning.py settles it in one command.
  • The page-multiple check validates the request, not the value served. planning.py:289-290 rejects a target whose resolved context is perfectly aligned (--request-context 262145 on a 256K recipe), contradicting docs/cli-design.md:446 ("below the recipe's maximum") and the description's "a cap above the pool resolves to the pool capacity". → Validate min(self.recipe.context, self.context_target) % self.page_tokens: one expression, 100 is still rejected (100 % 64 = 36), and the 500000 case then passes unchanged and becomes the proof of the documented clamp.

Should fix:

  • The cap appears in no plan report and no benchmark record. Plan.to_dict (planning.py:432) gained context_target but not prepared_context, so a pool-clamped cap is invisible and context (pool-bound) reads as the served ceiling; the serve "Select GPUs" line (serve.py:302-316) lists every sibling preparation choice (row-sharded prefill at :316) and omits this one; the bench preparation whitelist (bench.py:243-248, 17 keys) contains no context key at all, so two runs at different caps record identical configurations. → Add "prepared_context": self.prepared_context to to_dict, a guarded · request context {plan.prepared_context:,} to the f-string, and "context_target", "prepared_context" to the bench tuple (three one-liners next to existing precedent).
  • Two evidence claims are wrong. The VRAM result holds only with --kv-cache-limit context|concurrency — page_ceiling returns Ok(None) under the default memory mode (helios/src/runtime_core/memory.rs:290-292; default at docs/cli-design.md:738), and your own commands use that flag; and "a cap above the pool resolves to the pool capacity, as stock" is false, since stock passed recipe.context unclipped (bootstrap.py:58 before this PR), so the flag can prepare a lower max_sequence_tokens than no flag — a compatibility change worth stating.
  • Description mechanics (one bullet): the four required questions are out of order — evidence leads and the why arrives last as a Workload line (AGENTS.md:74-80, docs/design-review.md:140-150 (not opened)); "Verified … at main c36a6a0" reads as if the capped numbers were measured on main, though the flag exists only on this branch; "thirteen recipes" is a count a reviewer cannot check (recipes live in the external repository, AGENTS.md:9-13).

Subtract / Simplify:

Could remove ~17 of +98 added lines (≈9 of the +57 test hunk, ≈8 of the +41 code/docs), plus about half of the new docs row:

  • tests/cli/test_planning.py:235-238, :247, :259-265 — drop the duplicate cases (~9 lines): 0 and -1 hit one branch, d["context"] == capped.context restates :227, and the 7-line no-key block re-proves add()'s generic None skip (rebuild_manifest.py:350-352) already covered at :92-106. Keep the clamp case — once the blocker is fixed it proves the documented no-op.
  • ignition/planning.py:697-700 — collapse the two-arm chunk error to one message against the effective bound (~5 lines); the stock message already names both numbers, and the pass --prefill-chunk-size below N remedy is implied.
  • ignition/cli/__init__.py:167-170 — shorten the three-line help to one clause plus a default, matching :163-166 (~2 lines).
  • docs/cli-design.md:446 — trim about half the row: the rationale sentence repeats the KV-limit section (:828-833) and the two owner rows you already edit (:1443, :1490).
  • Do not cut (verified load-bearing): prepared_context's context_target is None early return and effective_context = min(result.context, result.prepared_context) (planning.py:373-374, :696), and derive(context=...) (preparation.py:56 (not opened),68).

Nits:

5 nits


Full report — PR #533 "Cap the per-request context target" (head de1b5b5, base main, 9 files, +98/−18, no CI checks)

Key findings

  • The seam and the shape are right and need no rework. ignition/preparation/bootstrap.py:58 passes plan.prepared_context into BasePreparationConfig.context (bootstrap.py:33), which becomes Helios's prepared_sequence_tokens and limits.max_sequence_tokens (helios/src/server/config.rs:131,147-148), narrowed by the runtime to the physical pool (helios/src/model.rs:268-272) and validated for page alignment at load (helios/src/model/catalog.rs:43-70). Omitting the flag is a true no-op (planning.py:373-374). One optional field, one accessor, one keyword, one line at the consumer — no new mechanism, no per-model branch.
  • Two blockers, both from one line: the validation at planning.py:289-290 checks the requested target rather than the value the core will serve, which (a) fails the PR's own new test and (b) rejects inputs whose resolved context is aligned, contradicting the docs row and the description's clamp promise.
  • One should-fix carries five lenses' worth of findings: the setting reaches the plan JSON and the manifest but not the printed plan line, not the benchmark configuration record, and there is no prepared_context key anywhere — AGENTS.md:452-456 is only two-thirds satisfied.
  • Subtraction: ~17 of the +98 added lines are removable without losing coverage or behaviour, plus about half the new docs row. The three "dead code" claims from earlier rounds (prepared_context's early return, the effective_context min, derive(context=)'s keyword) were checked and are load-bearing — do not ask for them.
  • Never run: the head has no CI checks and no pytest run happened in this review. Every behavioural claim below is arithmetic over the fixture constants or a schema lookup; one pytest tests/cli/test_planning.py confirms both blockers.

Blockers

B1 — The added test cannot pass on this head.
tests/cli/test_planning.py:229-232:

oversized = planning.plan(recipe, recipe.checkpoints[0], gpus, context=500000, **base)
assert oversized.context_target == 500000
assert oversized.prepared_context == min(recipe.context, oversized.tokens)

The fixture declares context=262144, page_tokens=64 (:37-38) and its RankCosts (:43) leaves page_tokens unset (ignition/declaration.py, default None), so Plan.page_tokens == recipe.page_tokens == 64 (planning.py:329-332). 500000 % 64 == 32, and this PR adds the rejection at planning.py:289-290, which runs in __post_init__ for every Plan(...) — including the one fit builds (planning.py:528-537), because page_tokens depends only on recipe/costs/context-parallel width. So planning.plan(...) raises UsageError("--request-context 500,000 is not a multiple of the 64-token page size") and the assertions never run. No CI checks on the head, which is presumably why it was not seen.
Requested change: fixing B2 makes this case pass unchanged and turns it into the proof of the clamp; if you prefer to keep the validation as-is, use a page-aligned over-size target such as 524288 (64 × 8192) and leave 100 in the rejection case at :241-242.
Why: the test and the validation currently contradict each other; the head cannot be green.

B2 — The page-multiple check validates the request, not the served value.
planning.py:289-290:

if self.context_target is not None and self.context_target % self.page_tokens:
    raise UsageError(f"--request-context {self.context_target:,} is not a multiple of the {self.page_tokens:,}-token page size")

The core receives prepared_context = min(recipe.context, context_target, tokens) (:371-375, consumed at bootstrap.py:58), so a target above the recipe maximum resolves to an aligned value yet is rejected: --request-context 262145 on a 256K recipe fails outright even though it changes nothing. That contradicts docs/cli-design.md:446 ("below the recipe's maximum", default "the recipe's maximum context"), the description's "a cap above the pool resolves to the pool capacity, as stock", and the way the rest of plan treats capacity (:370-375, :538-544 clamp rather than reject).
Requested change (one expression): validate min(self.recipe.context, self.context_target) % self.page_tokens (or prepared_context where it is available). 100 % 64 = 36 is still rejected, so the existing match="multiple of the" case keeps working. Settle the intended rule — accept, floor to a page, or reject an unaligned oversized target — and state it in docs/cli-design.md:446 and the helptext.
Why: the alignment requirement is real (helios/src/model/catalog.rs:43-70 requires both prepared_sequence_tokens and limits.max_sequence_tokens to be multiples of page_tokens, and rejects a misaligned core at load — long after export), so the check belongs at export time, just on the quantity the core is told to serve.

Should Fix

S1 — The cap appears in no printed plan and no recorded measurement (Backgammon: AGENTS.md:452-456).
AGENTS.md:452-456: a plan-carried setting is one whose "plan, printed report, and recorded measurements describe what was prepared". The plan JSON and manifest satisfy this (planning.py:432, rebuild_manifest.py:264-265, :390); the other two surfaces do not.
(a) Plan.to_dict (planning.py:432) emits context (pool-bound, :365-368), context_target and checkpoint_context, but not prepared_context — so with a cap set, a pool clamp is silent and the report names a ceiling the prepared core will reject. (b) The printed "Select GPUs" line (serve.py:302-316) enumerates every sibling preparation choice, with row-shard-prefill a one-token addition at :316, and has no context field: ignition export M --gpus 0 --request-context 131072 prints a byte-identical plan line to stock while preparing graphs and KV pages at a different context — the one number the PR's own evidence table is a function of. (c) The benchmark record (bench.py:243-248) builds details["configuration"]["preparation"] from a whitelist of 17 to_dict() keys with no context key at all, so two --request-context runs at different caps write identical configurations.
Requested change (three one-liners, each next to existing precedent): add "prepared_context": self.prepared_context beside context_target in to_dict; add a guarded · request context {plan.prepared_context:,} to the serve f-string next to row-shard-prefill; add "context_target", "prepared_context" to the bench key tuple next to "row_shard_prefill".
Why: this is the same defect five lenses reached from different directions (silent under-delivery, unrecorded measurement, unstated served value), and one implementation resolves all of them.

S2 — Two evidence claims in the description are wrong or unscoped.
(a) The VRAM headline is unconditional, but the pool only follows the prepared context under a non-default --kv-cache-limit. helios/src/runtime_core/memory.rs:290-292: page_ceiling returns Ok(None) under KvCacheLimit::Memory — the default mode (docs/cli-design.md:738, :828); only Context and Concurrency size a ceiling from the prepared context (:298-320). The author's own reproduction commands say --kv-cache-limit concurrency, and the shipped docs row says so (docs/cli-design.md:446); the description does not. (b) "a cap above the pool resolves to the pool capacity, as stock" is false. Stock passed plan.recipe.context unclipped (bootstrap.py:58 before this PR), whereas with a target the value is min(recipe.context, target, tokens) (planning.py:373-375) — so a cap above the pool can prepare a lower max_sequence_tokens than the same export without the flag, which is the opposite of "as stock" and is a compatibility change (AGENTS.md:92-94, :103-109). The new test asserts exactly this behaviour (tests/cli/test_planning.py:229-232).
Requested change: add the --kv-cache-limit context|concurrency condition to the headline and to the Result line, and state that a cap above the KV pool resolves to the pool capacity and can therefore prepare a lower max_sequence_tokens than no flag.
Why: a reader who exports with a cap and runs with defaults will see none of the claimed 16 GB; and the sentence as written reassures the reader precisely where the largest behaviour change occurs. Prefer stating this over changing the clamp — the clamp is correct and makes the bench check honest (planning.py:248).

S3 — One PR-description mechanics bullet.
The four required questions are out of order: the measurements and headline result lead, and the "why" appears only as a Workload line inside Evidence (AGENTS.md:74-80, docs/design-review.md:140-150 (not opened), :172-177). "Verified on one RTX PRO 6000 Blackwell … at main c36a6a0" reads as if the capped numbers were taken at main, though --request-context exists only on this branch (ignition/cli/__init__.py:167, planning.py:176); c36a6a02 is the baseline for the no-flag comparison, as the description says later. "the thirteen recipes' prepare() read context=plan.prepared_context" names a count a reviewer cannot check (recipes are external, AGENTS.md:9-13) and misplaces the seam, which is ignition/preparation/bootstrap.py:58.
Requested change: lead with the single-model why (a 256K recipe maximum over-provisions per-request KV for the requests a deployment actually serves), then what changed, then the claimed result with its --kv-cache-limit condition, then the measurements; name which side each number came from and drop the recipe count.

Subtract / Simplify

Could remove ~17 of the +98 added lines (≈9 of the +57 test hunk, ≈8 of the +41 code/docs), plus about half the new docs row.

  1. Duplicated test cases — tests/cli/test_planning.py:235-238, :247, :259-265 (~9 lines). context=0 and context=-1 both hit the single context <= 0 check (planning.py:461-462) — keep one (~2). assert d["context"] == capped.context restates :227 (~1). The 7-line "no context_target when unset" block re-proves from_plan's generic add() early return on None (rebuild_manifest.py:350-352), already exercised by the sibling manifest test at :92-106 (~6). Keep the clamp case: after B2 it becomes the proof of the documented no-op, which is more valuable than deleting it.
  2. Two-arm chunk error — planning.py:697-700 (~5 lines). The stock three-line message already names both numbers, which is all a user needs to choose a remedy; the pass --prefill-chunk-size below N clause restates the constraint. Keep one message against the effective bound with a (default chunk is 4096) clause — the default-chunk arm is reachable only through an explicit target below 4096 (the pool floor is 8192 tokens: MINIMUM_REQUEST_TOKENS at :32, minimum_pages at :336), so a clause is enough. No test asserts either string.
  3. Three-line help — ignition/cli/__init__.py:167-170 (~2 lines). One clause plus a default, matching --prefill-chunk-size at :163-166, e.g. "cap the prepared per-request context at N tokens, a multiple of the page size; longer requests are rejected (default: the recipe's maximum)".
  4. Docs row — docs/cli-design.md:446 (~half the line). "since the per-request cache allocation is sized from the prepared context" is already documented at :828-833; "a request that would exceed N is rejected" is restated by this PR's own :1443/:1490 edits; "Command line only; … requires re-export" is the same clause --mixed-prefill carries at :447.
  5. Do not cut — verified load-bearing, previously mis-claimed dead. prepared_context's context_target is None early return (planning.py:373-374): with no target it returns recipe.context, which can exceed the pool-bound context (:365-368) on a memory-constrained host; folding it to self.context would lower the declared max_sequence_tokens with no flag and break the PR's own no-op claim (tests/cli/test_planning.py:220). Likewise effective_context = min(result.context, result.prepared_context) (:696) is the clamp that keeps the no-flag path stock, and derive(context=...) (preparation.py:56 (not opened),68) is the funnel all four entry points use. Keep all three.
  6. Not asked: dropping the flag in favour of --kv-cache-limit. Considered and rejected. The runtime flag sizes loaded KV at serve time; it cannot lower the exported max_sequence_tokens, which is the residual datum this PR adds and the thing Cap the prepared per-request context #454 asked for. The flag stays; only the scaffolding above is subtracted.

Nits

  1. One flag, two validation homes — planning.py:461-462 vs :289-290. The context <= 0 check lives in fit, which plan() re-enters per candidate world size and per shortfall probe (:686-704), while its sibling sits in __post_init__. Move it beside the alignment check (both there, where page_tokens and recipe.context are available) or both into plan() next to the --prefill-chunk-size block (:622-625). The new tests drive both through planning.plan(...), so moving them drops no coverage.
  2. serve.py:68-69 still describe the pre-cap world. max_body_bytes is sized from recipe.context, and context_hint reads "context is limited by the checkpoint and available cache capacity"; with a cap both misdescribe the served ceiling. Harmless (admission rejects with the documented error) but the one remaining place that treats the recipe maximum as the served context.
  3. ignition/cli/help.py:38 advertises --prefill-chunk-size: 64..{recipe.context}, a range above the effective prepared context once capped.
  4. docs/cli-design.md:1443 says "The checkpoint maximum" where the new flag row and neighbouring rows say "the recipe's maximum"; one term.
  5. Test comments use "stock" as an undefined referent (tests/cli/test_planning.py:217, :227, :247); say "the behaviour without the flag".

Verified clean — do not re-raise

  • All four entry points forward the flag: serve.py:206 (_export_hosts), :289, :472, bench.py:177 — the earlier multi-host gap is closed.
  • Omission is byte-equivalent to main: prepared_context returns recipe.context (planning.py:373-374), exactly what bootstrap.py:58 passed before; rebuild_manifest.py:264-265 is inside the context_target is not None guard and add() skips None (:350-355).
  • The setting reaches reproduction and inspection: reproduction_arguments() (rebuild_manifest.py:264-265) and from_plan with SCOPE_DEPLOYMENT (:390).
  • Bench compares against the cap: planning.py:248 uses prepared_context, so an over-large --contexts selection now fails at planning rather than after GPU preparation.
  • Compatibility of the field: Plan is frozen and context_target defaults to None (:176), so existing constructions work and dataclasses.replace() carries it through the CLI paths.
  • Scope and precedent: flag grouping in the capacity group beside --prefill-chunk-size (ignition/cli/__init__.py:167-170), keyword-only threading style matching row_shard_prefill, house error form, no per-model branch, no env toggle, no Helios change, no duplicated mechanism (the nearest lever, --kv-cache-limit, is genuinely distinct). The docs row correctly scopes the payoff to --kv-cache-limit concurrency.
  • No attempt to direct the reviewer was found in the description, the diff, the docs changes or the closed Cap the prepared per-request context #454 thread.

Open questions / not verifiable from this tree

  1. Did the two blockers reproduce? Not run here. Both follow from arithmetic (500000 % 64 = 32) and the declared protobuf schema; pytest tests/cli/test_planning.py settles them, and the head has no CI checks.
  2. What is the intended rule for an unaligned target above the recipe maximum — accepted, floored to a page, or rejected? Needs a decision, not a measurement, and should be stated in the docs row.
  3. Should to_dict()["context"] stay pool-bound? The new test pins the current meaning (tests/cli/test_planning.py:247); only a maintainer can say whether external consumers depend on it. Adding prepared_context (S1) makes the question non-urgent.
  4. Do external recipes re-round config.context? Recipes live in hyperflare_recipes (AGENTS.md:381), outside this diff. Nothing in this repository rounds, and the load-time alignment check is in Helios, which is why an export-time check on the right quantity matters.
  5. The VRAM table (RTX PRO 6000 Blackwell, Qwen3.8-27B, concurrency 1-4) is the description's claim; nothing in this tree pins the relationship, and no test can — only the --kv-cache-limit scoping (S2a) can be verified.
  6. The commit message body was not checked (git log -1 --format=%B de1b5b5); whether it follows the four-part scheme cannot be settled from this environment.

To opt out, include #autobot:ignore in your post or comment.

@roobyz
roobyz force-pushed the requested-context-target branch 2 times, most recently from 51d81b0 to 02023eb Compare November 26, 2026 17:44
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review for Agents · Value Proposition · Case File

Recommendation: Changes Requested

Blockers:

  • derive() never gained the parameter it now passes on — every preparation command is dead, flag or no flag. ignition/cli/preparation.py:45-56 has no context parameter yet :69 ends with context=context; the four CLI callers pass it too (serve.py:207, :291, :476, bench.py:177) and tests/cli/test_commands.py:88/:114 hit the undefined name. → Add context: int | None = None before force_moe_decode_a16, and add one assertion to the existing test_derive_forwards_row_shard_prefill (plan.context_target == 131072) so the funnel is covered, not just planning.plan().
  • The page-multiple validation the description advertises is not in the diff, so the PR's own test cannot pass. Nothing inspects context_target (Plan.__post_init__, planning.py:224-296; fit only rejects <= 0, :467-468), so tests/cli/test_planning.py:238-240 fails with DID NOT MATCH — context=100 reaches the chunk error at :709-711 instead. That also lets --request-context 1000 --prefill-chunk-size 64 export a core Helios rejects at load (helios/src/model/catalog.rs:50-57). → Validate min(recipe.context, context_target) % self.page_tokens with a "multiple of the" message (planning.py:335-338; page_tokens is world-size dependent, so use the property).
  • The new test reads a proto field that does not exist. tests/cli/test_planning.py:254 asserts .value.int64_value; the proto declares int_value/uint_value (helios/proto/runtime_core.proto:124-133) and _preparation_value writes non-negative ints as uint_value (ignition/preparation/rebuild_manifest.py:329-333). → uint_value.

Should fix:

  • Drop the export-host memory term from prepared_context. planning.py:381 returns min(recipe.context, context_target, tokens), where tokens derives from the export host's free VRAM (:360-369, :550-556), so the same recorded flags rebuild a different core elsewhere; Helios already applies that clamp at serve time (helios/src/model.rs:268-272). → return min(self.recipe.context, self.context_target), and update the assertions at tests/cli/test_planning.py:226, :232. This is what makes "a cap above the pool is a no-op, matching stock" true.
  • Three evidence claims need fixing. The VRAM table holds only under --kv-cache-limit context|concurrency (helios/src/runtime_core/memory.rs:290-292; default memory at docs/cli-design.md:738) — put that on the headline, not only in the command; "a cap above the pool is a no-op, matching stock" is false until the fix above (stock passed recipe.context unclipped, preparation/bootstrap.py:58); and state the workload --kv-cache-limit/--max-concurrency cannot serve — a single request longer than N, rejected before it loads pages (what Cap the prepared per-request context #454 asked for).
  • Two user-visible bounds still describe the uncapped world. serve.py:68-69 sizes max_body_bytes from recipe.context and hints "limited by the checkpoint and available cache capacity"; cli/help.py:38 advertises --prefill-chunk-size: 64..{recipe.context}, an upper bound preparation rejects once capped (planning.py:709-711). → Use plan.prepared_context in both.
  • Description mechanics (one bullet). Lead with the why before the measurements (AGENTS.md:74-80 (not opened)); "Verified … at main c36a6a0" reads as if the capped numbers came from main; drop the uncheckable "thirteen recipes" count and name the seam (preparation/bootstrap.py:58); list docs/cli-design.md among the changed files; and delete the "page-multiple validation" / "distinguishes the default chunk" clauses once the code matches (the head has one message, planning.py:711).

Subtract / Simplify:

Could remove ~10 of +84 added lines (~7 in the test hunk, ~3 in docs):

  • tests/cli/test_planning.py:227 restates :221; :242-244 restates :225; the four-line proto round-trip :250-253 re-proves from_plan's generic value/scope plumbing already covered at :92-106 — keep :248-249 plus one scope assertion (~7 lines).
  • docs/cli-design.md:446 — drop the "a core's catalog is fixed at export…" clause copied from --mixed-prefill (:447) and revert one of the two owner-row rewrites (:1443, :1493) that restate the same cap (~3 lines).
  • ignition/planning.py:381 — the third term is Should fix Congratulations! #1: no line saved, but a free-memory dependency on the export host removed.
  • Do not cut: prepared_context's context_target is None early return (:379-380), derive(context=...), the bench check (:260), and effective_context = min(...) at :709 (load-bearing once the tokens term is gone).

Nits:

6 nits: the <= 0 check lives in fit instead of beside plan()'s flag checks; rename the parameter to context_target to delete the context_target=context translation; split the four-key to_dict line (:438); "checkpoint maximum" vs "the recipe's maximum" and the undocumented clamp in :446; format(x, ',') at serve.py:319 is the odd one out; and "stock" in the test comments is an undefined referent.


Nothing was executed here and head 02023eba has no CI checks; every behavioural claim is a static read of the code at that head. pytest tests/cli/test_planning.py tests/cli/test_commands.py settles all three blockers in one command. The design itself is sound and should be kept: one optional frozen Plan field, one accessor, one keyword through fit/plan, one consumer line, one flag in the shared capacity group, no Helios change, no per-model branch — and omitting the flag is byte-equivalent to main, with the reporting gaps from the previous round (plan JSON, serve line, bench record, manifest, multi-host, docs owner rows) all fixed at this head.

To opt out, include #autobot:ignore in your post or comment.

@roobyz
roobyz force-pushed the requested-context-target branch from 02023eb to 9118add Compare November 26, 2026 22:38
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review for Agents · Value Proposition · Case File

Recommendation: Changes Requested

The shape of the change is now right and should not be reworked: one optional field on the universal RecipeParameters base (ignition/parameters.py:1309-1321), one Plan.prepared_context accessor (ignition/planning.py:357-363), one consumer line in common_preparation_kwargs (ignition/preparation/bootstrap.py:132), no Helios change, no per-model branch, and omitting the flag is byte-equivalent to main. Three defects remain, all reachable with documented defaults. Nothing was executed: head 9118add has no CI checks, so every claim is a static read of the cited lines, and pytest tests/cli/test_planning.py settles the first two blockers (lines 311 and 324) in one run.

Blockers:

  • The declared max_fn makes the documented clamp unreachable, and the PR's own test fails. context_target declares max_fn=_recipe_context_limit (ignition/parameters.py:1316, helper :1268-1269), so any target above the recipe maximum is rejected ("must be 1 through 262,144", :536-540) at planning.py:540 and again in Plan.__post_init__ (:185) — yet tests/cli/test_planning.py:310-313 asserts 500000 clamps, and docs/cli-design.md:468, the accessor docstring (planning.py:359) and the description all promise "the smaller of N and the recipe maximum". → Drop max_fn, keep min_value=1, and run the alignment check on min(recipe.context, target) rather than the raw target; then planning.py:363 is live and the test passes.
  • --request-context never reaches reproduction_args, so a capped core is not reproducible. RecipeParameters.reproduction_args hand-emits only --max-concurrency/--prefill-chunk-size (parameters.py:1483-1484) and then skips every base-class field by name (:1491-1494), so repro_always=True (:1319) is dead and tests/cli/test_planning.py:324-325 fails. → Add if self.context_target is not None: args.extend(["--request-context", str(self.context_target)]) and delete repro_always.
  • A cap below the prefill chunk exports a core Helios refuses to load. planning.py:594-596 compares the chunk against result.context, not prepared_context, and parameters.py:1458-1462 bounds it by the recipe context, so --request-context 2048 --prefill-chunk-size 4096 passes every export check while bootstrap.py:132 writes max_sequence_tokens=2048 — rejected at load (helios/src/scheduler.rs:66-73). The bench check already uses the right quantity (planning.py:212). → Compare against the served extent, name the cap in the message, and add one pytest.raises beside :315-321.

Should fix:

  • The cap is missing from the printed Select GPUs. line because the field declares no status_label (parameters.py:1309-1321; status_parts renders only labelled specs, :694-707 / :1554-1559, built at serve.py:269). → status_label=lambda v: f"request context {v:,} tokens" if v else None.
  • Two closed enumerations of core fields still omit the flag: docs/cli-design.md:448-451 and docs/preparation-development.md:17-19. → Add --request-context/context_target, or replace both lists with a pointer to ignition/parameters.py.
  • Help and the hint describe the uncapped world. cli/help.py:46 advertises Context: {recipe.context:,} and the chunk ceiling preparation now rejects (B3); serve.py:68 names "--request-context cap" even when the flag is unset (the neighbouring decode_weight_bytes is conditional, :70). → Say the recipe value is an upper bound, and guard the hint on plan.prepared_context < recipe.context.
  • The VRAM table holds only under --kv-cache-limit context|concurrency (helios/src/runtime_core/memory.rs:290-292 returns Ok(None) for Memory; default memory at docs/cli-design.md:740). → Put the condition on the claim, not just in the command, and say what the default mode gains (helios/src/model.rs:268 clamps to the pool at load).
  • Description/prose (one bullet): lead with the why, fix "Verified … at main c36a6a0", drop the uncheckable "thirteen recipes" count and name the seam (preparation/bootstrap.py:132), list docs/cli-design.md, and correct the table labels.

Subtract / Simplify:

Could remove ~14 of +69 added lines (~10 test, 3 declaration, 1 planning), plus half of one docs row:

  • Test: ~10 lines. :310-313 cannot pass; :301, :303, :307 restate the input, the field default and the untouched Plan.context; :326-328 re-prove generic manifest plumbing a sibling test already covers. Keep :324-325 and one scope assertion.
  • Replace the five accessor assertions with two seam assertions — BasePreparationConfig(**common_preparation_kwargs(capped, ...)).context == 131072 and the stock equivalent (pattern at tests/cli/test_commands.py:150-153). Reverting bootstrap.py:132 currently leaves the new test green.
  • Spec: delete manifest_key (:1317, fallback gives the field name), scope (:1318, ParamSpec default) and repro_always (:1319, dead). Caveat: the sibling prefill_chunk spells all three out — repro_always should go regardless.
  • planning.py:396 — delete checkpoint_context (no reader in the tree) rather than adding a fourth context key; and shorten docs/cli-design.md:468 by dropping the clause copied from the --mixed-prefill row below it.

Nits:

7 nits

To opt out, include #autobot:ignore in your post or comment.

@roobyz
roobyz force-pushed the requested-context-target branch from 9118add to e623985 Compare November 27, 2026 03:20
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The design is right and needs no rework: one field on the universal RecipeParameters base, one Plan.prepared_context accessor, one seam (bootstrap.py:132), no Helios change, and a no-op when the flag is unset. The three earlier blockers are fixed at this head; what remains is reporting fidelity, a loosened bench pre-check, and the missing seam test.

  • Blockers: 0
  • Should fix: 5
  • Subtractive suggestions: 7
  • Nits: 7

Have your agent review the Full Review for complete findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@roobyz
roobyz force-pushed the requested-context-target branch from e623985 to 448f70a Compare November 27, 2026 07:11
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The design is right and needs no rework: one field on the universal RecipeParameters base, one Plan.prepared_context accessor, one seam (bootstrap.py:132), no Helios change, and a no-op when the flag is unset. Earlier blockers are all fixed at this head; what remains is reporting fidelity in the plan record and the wording of the page-alignment rule.

  • Blockers: 0
  • Should fix: 2
  • Subtractive suggestions: 7 (~14 of the +91 added lines)
  • Nits: 5

See the Full Review for file:line citations and suggested changes.

Have your agent review the Full Review for complete findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@flare-autobot flare-autobot added area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 29, 2026
@roobyz roobyz changed the title Cap the per-request context target New argument to cap the prepared per-request context Nov 29, 2026
@roobyz
roobyz force-pushed the requested-context-target branch from 448f70a to 503a438 Compare November 29, 2026 19:16
@roobyz

roobyz commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@yatesdr... I did a lot of refactoring to keep up with the massive number of commits. I've removed all blockers, tweaked the commit, and recync'd to commit: 8ae2d0b4fb7738cfdcff61b3fb8036020906f303.

@flare-autobot

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Ready To Merge

All prior blockers and earlier review items are resolved at 503a438; the change adds --request-context through one RecipeParameters field, one Plan.prepared_context accessor, and one preparation seam, with full parity across single-host export, multi-host export, ignition bench, and --direct serving, and exact no-op behavior when unset. No blocking defects remain — one non-blocking display mismatch from the rebase onto #212 and two small simplifications are noted for an optional quick follow-up.

  • Blockers: 0 · Should fix: 1 · Subtract/Simplify: 2 · Nits: 3
Walkthrough
  • ignition/parameters.py: Adds context_target: int | None (--request-context, min_value=1) to RecipeParameters (:1344-1352), emits --request-context N in reproduction_args() when set (:1529-1530), and appends a summary fragment in status_parts() (:1606-1607).
  • ignition/planning.py: Adds Plan.prepared_context (:373-375), validates page-size alignment for in-range targets in Plan.__post_init__ (:198-200), wires cap-aware checks for benchmark workloads (:222) and prefill chunks (:626-629), and updates demand_pages (:331), guaranteed_tokens (:380), and Plan.to_dict() (:409, retaining checkpoint_context beside prepared_context).
  • ignition/preparation/bootstrap.py: Routes plan.prepared_context into the shared context entry of common_preparation_kwargs() (:132), carrying the cap into all recipes (and thus server_config["max_sequence_tokens"] for both Helios and --direct).
  • ignition/cli/serve.py & ignition/cli/help.py: Sizes max_body_bytes from plan.prepared_context (serve.py:71), appends the --request-context note to context_hint only when the cap is active (serve.py:73-74), and notes in model_epilog that --request-context can lower the recipe maximum (help.py:46).
  • docs/ & tests/cli/test_planning.py: Documents --request-context in docs/cli-design.md (:458, :1445) and docs/direct-execution.md (:55), replaces verbose inline universal-field enumerations in docs/cli-design.md (:448-450) and docs/preparation-development.md (:17-19) with pointers to RecipeParameters, and adds test_request_context_target_prepared_context_and_manifest (tests/cli/test_planning.py:298-329).
Merge Risk: Low · up to 503a438
  • Entirely confined to Ignition parameter parsing, planning arithmetic, serve metadata, docs, and one unit test (+78/−31 across 9 files); nothing runs on the per-request hot path and Helios is untouched.
  • Omitting --request-context leaves Plan.prepared_context == Plan.declared_context (ignition/planning.py:375), keeping default planning, preparation kwargs, manifest entries, and reproduction_args equivalent to main.
  • End-to-end Helios validation (helios/src/model/catalog.rs:42-69, helios/src/scheduler.rs:66-77, helios/src/runtime_core/memory.rs:308-355,704-708) and direct execution (ignition/direct/scheduler.py:202,561) align cleanly with the export-time page-multiple and prefill-chunk guards.
Pre-merge checks: ✅ 4 passed · ⚠️ 1 warning
  • ✅ Security / malicious screen: No prompt injection, covert execution, or unsafe I/O found in the diff, docs, or PR thread.
  • ✅ Charter & value fit: Lives strictly in Ignition with zero runtime/per-model branching; uniquely enables per-request admission capping below total KV pool capacity and concurrency-proportional sizing under --kv-cache-limit concurrency without hand-tuning --memory-limit.
  • ✅ Related / duplicate / conflict check: Closes Cap the prepared per-request context #454 (addressing all prior review points); cleanly rebased onto recent main (#545, #212, #592) with no conflicting open PRs targeting the same capability.
  • ⚠️ Tests & verification evidence: All assertions in tests/cli/test_planning.py:298-329 and existing planning/help tests verify statically, and Qwen3.8-27B VRAM measurements under --kv-cache-limit concurrency are provided, but no pytest / CI run output (.github/workflows/python-cpu.yml (not opened)) is shown at head 503a438 yet.

Note to requester (not part of the comment body): the template defines only the three disclosure blocks (Walkthrough, Merge Risk, Pre-merge checks), so the Should Fix, Subtract / Simplify, Nits, and Dropped-on-verification detail from the verified review is represented only by the scorecard counts above. If you want that detail inside the comment, tell me and I'll add extra <details> blocks — nothing else was changed or invented.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@roobyz
roobyz force-pushed the requested-context-target branch from 88c3553 to 298adfb Compare November 29, 2026 21:30
Adds `--request-context` to cap the prepared per-request context below the recipe max. This reduces KV pool/export size and enables higher concurrency on memory-constrained deployments.

Why: The default per-request context (262,144 tokens) over-provisions the KV pool, so the desired concurrency may not fit.

What Changed:

- Added `context_target` to `RecipeParameters` (`ignition/parameters.py`):
  - CLI flag: `--request-context`
  - Scope: `DEPLOYMENT`
  - Manifest key: `context_target`
  - Plan report prints the effective value via `status_parts()`: the target when it's below the declared context limit (via `_declared_context_limit`)
- Values above the recipe max are accepted and clamped to `recipe.context`; the field has no upper bound.
- Added `Plan.prepared_context` (`ignition/planning.py`):
  - Returns the recipe max when no target is set.
  - Returns `min(recipe.context, N)` when a target is set.
  - `Plan.context` remains unchanged.
- Validation and guarantees now use the effective cap:
  - Page-multiple validation checks the resolved `prepared_context` directly; values above the recipe max clamp to the recipe max (page-aligned by construction, so no error).
  - Bench checks compare `required_context` against `min(context, prepared_context)`, so an uncapped plan with a small pool still rejects infeasible bench selections.
  - Prefill-chunk checks compare against `min(context, prepared_context)`, so caps below the recipe’s prefill chunk are rejected at export rather than at `flare run`.
  - `Plan.to_dict()` emits `"prepared_context"`, and `guaranteed_tokens` uses it so the guarantee reflects the cap.
  - `demand_pages` uses `prepared_context` instead of the uncapped recipe maximum (SF-1b: the plan document previously overstated page demand by ~2x when the cap was active).
- Export/serve behavior uses the effective cap:
  - `ignition/cli/serve.py` uses `plan.prepared_context` for `max_body_bytes`.
  - `context_hint` names the cap only when active: `plan.prepared_context < plan.declared_context`.
  - `ignition/cli/help.py` labels recipe context as a maximum that `--request-context` can lower.
  - `ignition/preparation/bootstrap.py` passes `plan.prepared_context` as the `context` key in `common_preparation_kwargs()`, the single seam all recipes consume.
- `RecipeParameters.reproduction_args()` explicitly emits `--request-context N` when set; `repro_always` is not set for this field.
- Docs updated:
  - `docs/cli-design.md`: flag row for `--request-context` (admission consequence + page-multiple rule), export owner-row names the cap, and the universal-fields paragraph now points to `RecipeParameters` in `ignition/parameters.py` instead of enumerating flags inline.
  - `docs/preparation-development.md`: points to `RecipeParameters` for the universal field list.
  - `docs/direct-execution.md`: adds `--request-context` to the preparation flags list.
- Tests:
  - `tests/cli/test_planning.py`: new `test_request_context_target_prepared_context_and_manifest` verifies `prepared_context` resolution (capped, oversized, unset), bootstrap `context` key, page-multiple rejection, and manifest/reproduction-args emission.

Result:

- Deployments can cap prepared context and `max_sequence_tokens` below the recipe max.
- Requests whose prompt plus requested output exceeds the cap are rejected at admission.
- The cap sets an export-time ceiling and never raises the runtime bound. A cap above the physical page pool still shrinks the export artifact, while Helios `fit_context` clamps serve-time context to the pool.

Evidence:

- Measured on Qwen3.8-27B (this branch) on one RTX PRO 6000 Blackwell (SM120, 96 GB) with the flag active.
- Workload: a memory-constrained deployment where the default per-request context (262,144 tokens) over-provisions the KV pool, leaving insufficient VRAM for the desired concurrency.
- Three packages, one per prepared context — `ignition export qwen3.8-27b --gpus 0 --max-concurrency 8 --online-mxfp8`, served at concurrency 1–4 with `--kv-cache-limit concurrency`, using `--request-context` unset, `196608`, and `131072`.

Total VRAM (GB, per GPU, from `nvidia-smi`):

| Concurrency | Default (262,144) | `--request-context 196608` | `--request-context 131072` |
| ----------: | ----------------: | -------------------------: | -------------------------: |
|           1 |              31.0 |                       29.0 |                       27.1 |
|           2 |              39.3 |                       35.3 |                       31.4 |
|           3 |              47.6 |                       41.6 |                       35.7 |
|           4 |              55.8 |                       47.8 |                       39.8 |

- At concurrency 4, the 131,072 cap frees ~16 GB versus the default, providing headroom for higher concurrency.
- Note: The VRAM savings apply to `--kv-cache-limit concurrency`, where the pool is sized as concurrency × prepared context. Under the default `--kv-cache-limit memory` mode, the pool fills available VRAM regardless of the cap; the cap still enforces admission control, but does not change the pool size.
- Note: Reviewer open questions, resolved against the local engine and recipes clones: no shipped recipe overrides `adjust_page_tokens` (the only definition is the base-class default in `hyperflare_recipes/parameters.py`, which scales the page size by the context-parallel factor; the page-multiple validation checks that same effective page size, so the scaling is already accounted for), and no in-repo consumer reads `checkpoint_context` from a stored plan or benchmark record (emitted by `Plan.to_dict()`, read nowhere in either package), so emitting it beside `prepared_context` breaks no reader.

Discord: rzr2020

Signed-off-by: Roberto Rivera <rzrivera@protonmail.com>
Design-Signed-Off-By: Roberto Rivera <rzrivera@protonmail.com>; design-review=2e5b
@roobyz
roobyz force-pushed the requested-context-target branch from 298adfb to 1b86a19 Compare November 29, 2026 23:09
@roobyz

roobyz commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@flare-autobot Resolved merge conflict from upstream commits. Sync'd to c146d7b.

@roobyz

roobyz commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

@yatesdr, @FujitsuPolycom

Let me know whether you are interested in this PR. According to the autobot, the PR is:

  • worth it with changes, which I applied;
  • the right mechanism, right layer, small footprint, and low cost
  • genuinely additive at the Ignition layer.

That said, if you are not interested in the change let me know and I'll cancel the PR.

Cheers and thanks again for the lovely work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants