Recommendation: Ready To Merge
All prior blockers and earlier review items are resolved at 503a438: the change cleanly adds --request-context via one declarative RecipeParameters field, one Plan.prepared_context accessor, and one preparation seam (ignition/preparation/bootstrap.py:132), with full parity across single-host export, multi-host export, ignition bench, and --direct serving, no Helios changes, and exact no-op behavior when unset. No blocking defects remain; one non-blocking display mismatch introduced during the rebase onto #212 (status_parts using context.recipe.context instead of _declared_context_limit) and two small simplifications are noted below for an optional quick follow-up.
Merge Risk
Level: Low
- 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-contextleavesPlan.prepared_context == Plan.declared_context(ignition/planning.py:375), keeping default planning, preparation kwargs, manifest entries, andreproduction_argsequivalent tomain. - 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.
Walkthrough
ignition/parameters.py: Addscontext_target: int | None(--request-context,min_value=1) toRecipeParameters(:1344-1352), emits--request-context Ninreproduction_args()when set (:1529-1530), and appends a summary fragment instatus_parts()(:1606-1607).ignition/planning.py: AddsPlan.prepared_context(:373-375), validates page-size alignment for in-range targets inPlan.__post_init__(:198-200), wires cap-aware checks for benchmark workloads (:222) and prefill chunks (:626-629), and updatesdemand_pages(:331),guaranteed_tokens(:380), andPlan.to_dict()(:409, retainingcheckpoint_contextbesideprepared_context).ignition/preparation/bootstrap.py: Routesplan.prepared_contextinto the sharedcontextentry ofcommon_preparation_kwargs()(:132), carrying the cap into all recipes (and thusserver_config["max_sequence_tokens"]for both Helios and--direct).ignition/cli/serve.py&ignition/cli/help.py: Sizesmax_body_bytesfromplan.prepared_context(serve.py:71), appends the--request-contextnote tocontext_hintonly when the cap is active (serve.py:73-74), and notes inmodel_epilogthat--request-contextcan lower the recipe maximum (help.py:46).docs/&tests/cli/test_planning.py: Documents--request-contextindocs/cli-design.md(:458,:1445) anddocs/direct-execution.md(:55), replaces verbose inline universal-field enumerations indocs/cli-design.md(:448-450) anddocs/preparation-development.md(:17-19) with pointers toRecipeParameters, and addstest_request_context_target_prepared_context_and_manifest(tests/cli/test_planning.py:298-329).
Pre-merge Checks
- [PASS] Security / malicious screen: No prompt injection, covert execution, or unsafe I/O found in the diff, docs, or PR thread.
- [PASS] 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 concurrencywithout hand-tuning--memory-limit. - [PASS] Related / duplicate / conflict check: Closes #454 (addressing all prior review points); cleanly rebased onto recent
main(#545,#212,#592) with no conflicting open PRs targeting the same capability. - [WARN] Tests & verification evidence: All assertions in
tests/cli/test_planning.py:298-329and existing planning/help tests verify statically, and Qwen3.8-27B VRAM measurements under--kv-cache-limit concurrencyare provided, but no pytest / CI run output (.github/workflows/python-cpu.yml(not opened)) is shown at head503a438yet.
Blockers
None.
Should Fix
ignition/parameters.py:1606-1607—status_parts()ignores checkpoint-declared /adjust_context-scaled ceilings (rebase mismatch with#212) and lacks acontext.recipe is Noneguard:- Currently:
if self.context_target is not None: parts.append(f"request context {min(self.context_target, context.recipe.context):,} tokens") - After
#212,Plan.declared_contextresolves viaadjust_context(recipe.base_context(checkpoint), ctx)(ignition/planning.py:363-365, mirrored by_declared_context_limitatignition/parameters.py:1299-1304). For a checkpoint with a largercheckpoint.context(e.g., 1,048,576 over a 262,144 recipe, as intests/cli/test_planning.py:462) or anadjust_contexthook (:527), passing--request-context 524288printsrequest context 262,144 tokensin theSelect GPUsstatus line even thoughprepared_contextand the exported core serve524,288tokens. In addition,ParameterContext.recipedefaults toNone(ignition/parameters.py:126), so direct calls without a recipe raiseAttributeError, and oversized no-op targets still print even thoughignition/cli/serve.py:74suppresses the cap hint when inactive. - Fix: Reuse
_declared_context_limit(self, ctx)and only emit when the cap is active (or recipe is absent):if self.context_target is not None: declared = _declared_context_limit(self, ctx) if declared is None or self.context_target < declared: parts.append(f"request context {self.context_target:,} tokens")
- Currently:
Subtract / Simplify
ignition/planning.py:368-370,:222,:626-629— makePlan.contextcap-aware (return min(self.prepared_context, self.tokens)):Plan.contextis documented as "The longest sequence one request may reach", yet currently ignoresprepared_context(min(self.declared_context, self.tokens)), forcing both guards at:222and:626to repeatmin(context, prepared_context)and causingPlan.to_dict()["context"](:407) to report the uncapped context even when--request-contextis active. Changing:370toreturn min(self.prepared_context, self.tokens)removes bothmin(...)wrappers and theeffectivelocal while keeping"prepared_context"into_dict()(which remains distinct from"context"wheneverself.tokens < self.prepared_context).
ignition/planning.py:198-200— checkself.prepared_context % self.page_tokensdirectly:- Replace
if target is not None and target <= self.declared_context and target % self.page_tokens:withif target is not None and self.prepared_context % self.page_tokens:(formattingself.prepared_contextin the message). Keeps thetarget is not Noneguard so an unset flag never emits a--request-contexterror, drops the redundant range comparison, and validates the exact value passed tocommon_preparation_kwargsand Helios (helios/src/model/catalog.rs:48-55).
- Replace
Nits
ignition/parameters.py:1344-1352: Adddefault_label="the recipe's maximum context"(matchingcompile_workersat:1373) so generated--helpdoes not renderdefault: none(:303-304) contrary todocs/cli-design.md:458.docs/cli-design.md:458: Clarify the clamp-before-alignment precedence (e.g., "Values at or below the recipe maximum must be a multiple of the core's page size (otherwise rejected at export); values above the recipe maximum are ignored.") so misaligned values above the recipe max (such as500001) are not described ambiguously.- PR description wording: Core planning derives
pagesandsnapshot_budget_bytesfrom GPU supply alone (ignition/planning.py:502-511,ignition/preparation/bootstrap.py:133), so the major VRAM savings occur at serve time under--kv-cache-limit concurrency|contextrather than by shrinking the exported artifact's KV pool (your Notes already explain this; aligning the opening/Result wording removes the small inconsistency). Also,checkpoint_contextis still asserted by two in-repo tests (tests/cli/test_planning.py:472,478), so retaining it was the right call.
Dropped on verification
- Correctness lens #2 / Discovery #8 (make
_declared_context_limitcap-aware for--prefill-chunk-size): Dropped — false positive with a harmful suggested fix. DuringMODEL --help,root.context_targetisNone, somax_fnstill properly advertises64..declared_context(andtests/cli/test_planning.py:494should not change). Mutating_declared_context_limitwould also corruptRecipeParameters.validate()(ignition/parameters.py:1492-1501), causing misaligned--request-contextinputs like100to fail with a"declared context ... must be a 64-aligned positive int32"error instead of the page-multiple error expected bytests/cli/test_planning.py:319-321. Runtime/export safety is already enforced atignition/planning.py:626-629. - Correctness lens #5 (alignment
UsageErrorinPlan.__post_init__aborting GPU auto-selection): Dropped — speculative and proposed fix (RecipeParameters.validate) would bypassPlan.page_tokens(adjust_page_tokens). RaisingUsageErrorwith the effective page size when a candidate world size cannot represent--request-contextis the intended behavior. - Correctness lens #3 / Discovery #5 ("exported core is byte-identical" claim): Dropped the overstatement — while
fit()pages andsnapshot_budget_bytesare cap-independent,config.context = plan.prepared_contextis passed to externalhyperflare_recipes(settingmax_sequence_tokensand potentiallypage_tableswidth). Kept only as a brief description-wording nit. - Correctness lens #4 / Discovery #6 ("evidence does not answer #454 without
--memory-limitand--kv-cache-limit contextrows"): Dropped as a blocker/should-fix — verified against#454andhelios/src/model.rs:270-274:--memory-limitalone lets a single request consume up tomin(262144, pool_tokens)and starve concurrent slots, whereas--request-contextenforces a per-request admission ceiling and cleanly scales--kv-cache-limit concurrencypools without per-GPU gigabyte math. - Subtraction S1 (dropping
target is not NoneinPlan.__post_init__): Dropped the unsafe part — removingtarget is not Nonecould raise a--request-contexterror when the flag was never passed ifadjust_page_tokensincreasespage_tokensaboverecipe.page_tokens. Kept the safe simplification (if target is not None and self.prepared_context % self.page_tokens:). - Subtraction S2 sub-claim (deleting
"prepared_context"fromPlan.to_dict()as a duplicate of"context"): Dropped — false when the export host is pool-bound (self.tokens < self.prepared_context), wherecontext == self.tokenswhileprepared_contextis the higher ceiling written to the core. - Subtraction S3 (deleting
status_partsand un-branchingcontext_hint), S4 (revertinghelp.py:46anddocs/direct-execution.md), and S5 (renamingcontext_target→request_context): Dropped — low-signal churn that directly contradicts changes requested in earlier Autobot review rounds (anti-moving-goalposts). - Correctness Open Questions #4 & #5 (lower-bound Helios compatibility and
--directparity): Verified clean acrosshelios/src/model/catalog.rs:42-69,helios/src/scheduler.rs:66-77,helios/src/runtime_core/memory.rs:308-355,704-708,ignition/cli/serve.py:401-483, andignition/direct/scheduler.py:202,561.