Architecture report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/7238a019-cc5e-468e-b9c7-59c72869735b.md

Key findings

The design and layering for this PR are right: one optional frozen Plan field (ignition/planning.py:186), one accessor (:377-381), one keyword through fit()/plan(), one consumer line at ignition/preparation/bootstrap.py:58, one flag registered in the shared capacity group (ignition/cli/__init__.py:167-168) that reaches all three subcommands, and no Helios changes, no per-model branch, no env toggle. The scope is defensible against the charter's "smallest footprint in shared code" and against AGENTS.md:456 ("a setting's plan, printed report, and its recorded measurements describe what was prepared"), and the measured-evidence requirement is met by a real VRAM table.

But two mechanical defects stop the branch from working at head 02023eb, and one design issue makes the exported artifact non-reproducible. Review is therefore blocking.


Blocking

1. derive() references an undefined name, so every entry point crashes

ignition/cli/preparation.py:69 ends the planning.plan(...) call with context=context). But derive()'s own signature (ignition/cli/preparation.py:45-56) has no context parameter, and the module neither imports nor assigns a module-level context: a full-file search for the token returns only context_parallel / context_parallel_size in the signature and call (:47, :62), the offending :69, and the context_parallel() helper (:124-132).

So a NameError fires on every derive() call, whether or not --request-context is passed. Consequences, by caller:

The new test does not catch this because it bypasses derive() entirely and calls planning.plan(...) directly (tests/cli/test_planning.py:218-240). The head commit has no CI checks, so nothing else would have caught it either.

Why it matters: the "omitting the flag is a no-op" guarantee in the description is violated — the omitted flag is now a crash. This is squarely against AGENTS.md:74-80 (the change must work as described) and against the charter's demand that PRs address a reproducible defect rather than introduce one.

Fix: add context: int | None = None to derive() at ignition/cli/preparation.py:55 (before force_moe_decode_a16), keeping the wire-up at :69. Add a test that drives derive(..., context=N) end-to-end and asserts plan.context_target == N — the direct-plan() test cannot cover the funnel.

2. The page-multiple validation does not exist; the PR's own test fails and unaligned targets export an unloadable core

The description states ignition/planning.py gained "a page-multiple validation", and tests/cli/test_planning.py:238-240 asserts it:

with pytest.raises(UsageError, match="multiple of the"):
    planning.plan(recipe, recipe.checkpoints[0], gpus, context=100, **base)

There is no such check. Plan.__post_init__ (ignition/planning.py:224-296) never inspects context_target, and a repository-wide search for "multiple of" in ignition/ returns only the prefill-chunk message (planning.py:635-637), its help text (cli/__init__.py:165, cli/help.py:38), and unrelated component validators. fit() validates only context <= 0 (planning.py:467-468). So context=100 becomes context_target, and with the fixture's page_tokens=64 (test_planning.py:38) and prefill_chunk=4096 (:42) it falls through to the effective-context chunk error at planning.py:709-711 — a UsageError whose text ("--prefill-chunk-size 4,096 exceeds the 100-token context this plan allows") does not match "multiple of the". The new test fails.

This is a real load-time defect, not just a test mismatch. bootstrap.py:58 makes prepared_context the prepared catalog's context, which becomes max_sequence_tokens (helios/src/server/config.rs:131,148), and helios/src/model/catalog.rs:50-57 rejects any core whose prepared_sequence_tokens / max_sequence_tokens is not a multiple of page_tokens (page_tokens.max(1)), with "invalid prepared model configuration". A reachable path: --request-context 100 --prefill-chunk-size 64 passes planning.py:635 (64 is a valid chunk) and :709-711 (64 ≤ 100), exports a full core, and the core will not load. The user sees an export succeed and a serve fail on a stock Helios error.

Fix: validate the served value, not just positivity — in plan()/__post_init__ beside the existing checks, reject min(recipe.context, context_target) % page_tokens != 0. Note page_tokens is world-size dependent (planning.py:335-338), so the check must either use the chosen plan's page_tokens after sizing (as :709-711 does with result) or require a multiple of 64 with the recipe's page granularity. With that check, context=100 is rejected with a "multiple of the" message and test_planning.py:238-240 passes unchanged.


Should fix

prepared_context is clamped by export-host free memory, so the exported ceiling is not reproducible

ignition/planning.py:377-381:

if self.context_target is None:
    return self.recipe.context
return min(self.recipe.context, self.context_target, self.tokens)

self.tokens is self.pages * self.page_tokens (:368-369), and pages comes from available // costs.page_bytes (:550-556), where available = supply_bytes - fixed_bytes and supply_bytes = free_bytes - headroom - reserve (:360-361) — i.e. the memory free on the export host at export time. The untargeted path deliberately returns recipe.context and lets the pool bind at serve time. The targeted path instead bakes the export host's free VRAM into the artifact's max_sequence_tokens, while reproduction_args record only --request-context N (ignition/preparation/rebuild_manifest.py:264-265) and the manifest records only context_target (:389). The same recorded flags therefore reproduce a different core on a host with a different free-memory reading, which contradicts AGENTS.md:452-456 ("The setting, its printed report, and its recorded measurements describe what was prepared").

It is also redundant: Helios already applies exactly this clamp at serve time — helios/src/model.rs:268: self.limits.max_sequence_tokens = self.prepared_sequence_tokens.min(...) (fit_context). Fix: return min(self.recipe.context, self.context_target) and let fit_context apply the pool bound, matching the untargeted path's split of responsibilities. This also makes the description's claim that "a cap above the pool is a no-op, matching stock" true by construction rather than a coincidence of the export host's memory. (The clamp test at test_planning.py:229-232 would need min(recipe.context, target) instead of min(recipe.context, target, tokens); the assertion :232 currently pins the export-time memory dependence.)


Nits

  1. Two validation homes for one flag. context <= 0 is checked inside fit() (ignition/planning.py:467-468), which is re-entered for every candidate group (:679-689) and again per shortfall probe (:718-719), while every sibling flag check lives in plan()/__post_init__ (:627-649). Unify in plan() so all flag validation has one home and one error ordering.
  2. serve.py:68-69 still sizes max_body_bytes from recipe.context and its context_hint still says "context is limited by the checkpoint and available cache capacity" — neither mentions the cap, so a capped deployment accepts a body sized for the uncapped ceiling and reports the wrong reason for the limit.
  3. ignition/cli/help.py:38 advertises --prefill-chunk-size: 64..{recipe.context}, which is now above the effective context whenever the cap is smaller (see planning.py:709-711, which rejects a chunk above min(context, prepared_context) at planning time).
  4. docs/cli-design.md:446 says the flag caps context "below the recipe's maximum", but the code silently clamps an oversize target (planning.py:381, pinned by test_planning.py:229-232). Document the clamp, or reject instead of clamping. The doc row is also missing from the description's "what changed" list.
  5. "stock" is an undefined referent in the test comments (tests/cli/test_planning.py:217, :227). Say which revision/behavior is meant (AGENTS.md:95-102 on scope in prose).

Evidence scoping (not a code defect, but a description defect)

The VRAM table holds only under a non-default --kv-cache-limit. helios/src/runtime_core/memory.rs:290-291 returns Ok(None) for KvCacheLimit::Memory, the default (docs/cli-design.md:738, :828); only the Context/Concurrency modes derive a ceiling from the prepared context (memory.rs:298-320). The description's headline ("frees 16 GB at concurrency 4") and the docs row omit that condition, although the author's own commands pass --kv-cache-limit concurrency. Under AGENTS.md:95-102 the scope and material limitation should be attached to the claim.


Confirmed fixed since the 2026-11-25 revision — do not re-raise

Checked in the code at head 02023eb:


Per-file coverage

All nine changed files were read in context, not only as diff hunks: ignition/planning.py (150-300, 300-400, 430-455, 455-600, 600-743), ignition/cli/preparation.py (1-160 plus a full-file context search), ignition/cli/serve.py (55-80, 130-215, 258-325, 462-482), ignition/cli/bench.py (155-185, 236-262), ignition/cli/__init__.py (150-185 plus registration at :50, :53, :60), ignition/preparation/bootstrap.py (25-85), ignition/preparation/rebuild_manifest.py (240-280, 340-400), tests/cli/test_planning.py (1-60, 200-256), docs/cli-design.md (443-452, 738, 828-836, owner rows). Downstream semantics were checked in helios/src/server/config.rs:131,148, helios/src/model/catalog.rs:44-57, helios/src/model.rs:268-272, and helios/src/runtime_core/memory.rs:290-320.

Open questions / not verified