Architecture report · NVIDIA/hyperflare-inference #518

Raw Markdown for agents: https://autobot.eidonix.com/p/31711651-ef92-425f-8e02-e383a5a91277.md

Key findings

Reviewed through the architecture/scope lens against the charter, AGENTS.md, docs/design-review.md, docs/runtime-core-design.md and docs/cli-design.md. Every changed file was read in context, plus its call sites (derive, _prepare, _export_hosts, debug_serve, bench.run, reproduction_arguments, from_plan, Plan.__post_init__/to_dict).

No blocking architectural violation. The change keeps the layering intact: the new option is an Ignition-only PreparationParameter under PREPARATION_PARAMETER_SCOPE_TARGET_WEIGHT and is omitted when unset, so nothing in runtime_core.proto (not opened), core.proto (not opened), helios/ or heliopause/ changes — exactly what docs/runtime-core-design.md:345-401 prescribes ("Adding or removing an Ignition-only option requires no changes to runtime_core.proto (not opened), core.proto (not opened), or Helios"). It is an explicit CLI flag carried through the plan, not an environment switch (AGENTS.md:446-456, design-review P10), and it is an opt-in rather than silent requantization (design-review P9, docs/design-review.md:76-79). The recipe-gated shape mirrors existing precedent (draft_head_quantizations/draft_body_quantizations, ignition/declaration.py:277-280, ignition/planning.py:487-495).

Three should-fix findings remain: the flag never reaches memory planning, it is patched onto the plan after planning instead of being a planning input, and the doc row claims a model and an effect this repository cannot provide.


Should fix

1. The flag's whole point never reaches memory planning

ignition/planning.py:445-453 (fit), :524-533 (Plan construction), ignition/declaration.py:363-374 (weights_bytes), ignition/declaration.py:85-86 (Checkpoint.scale_compressed_device_bytes).

Plan.weights_bytes is the planner's only weight estimate:

def weights_bytes(self, checkpoint, world_size, speculation, expert_scale_compression=None) -> int:
    device_bytes = (checkpoint.device_bytes if expert_scale_compression is None else
                    checkpoint.scale_compressed_device_bytes[expert_scale_compression])

fit forwards expert_scale_compression into it (planning.py:526) but has no target_head_quantization parameter at all, and Plan's new field (planning.py:199) is never consumed by any byte computation. Consequently plan.fits (planning.py:383-385 region), the page count (:534-540), the _shortfall options list (:697-725) and the printed plan (:554) all still reserve the full BF16 vocabulary head.

Why it matters: this is the PR's stated purpose (~600 MiB saved on TP1 by not retaining the BF16 lm_head). Without a plan-side estimate, a memory-tight host raises CapacityError for a configuration the flag would in fact make fit, and when it does fit the exported capacity understates what the core will really have. AGENTS.md:452-456 requires a 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" — here the plan describes the setting but not its resource effect.

Fix: declare the quantized head's resident bytes on the checkpoint (as scale_compressed_device_bytes already does for scale compression) or subtract them inside Recipe.weights_bytes, and thread the setting through fit/plan from derive, _prepare, _export_hosts, debug_serve and bench. A planning test asserting fit(..., target_head_quantization="mxfp8").weights_bytes < fit(...).weights_bytes for a recipe that declares head bytes would settle it; only a GPU export can confirm the real residency.

2. The flag is repaired onto the Plan after planning, bypassing planning.plan/fit

ignition/cli/preparation.py:57, :60-75; ignition/cli/serve.py:192-211, :274-290, :461-480; ignition/cli/bench.py:162-177; compare ignition/planning.py:445-453, :581-589, and the sibling validations at :599-632.

derive calls planning.plan(...) (which has no such parameter) and then patches the result:

result = replace(result, compile_workers=workers, ...,
                 target_head_quantization=target_head_quantization,
                 joint_tuning=joint_tuning, ...)

_prepare, _export_hosts (serve.py:206-211, :475-480) and bench (bench.py:170) do the same. By contrast row_shard_prefill, online_mxfp8, online_mxfp8_scope, language_model_only, expert_scale_compression and mla_compute_mode are parameters of fit/plan and are validated there before any GPU is chosen (e.g. --row-shard-prefill at planning.py:627-632). Here the only validation is Plan.__post_init__ (planning.py:289-293), which now runs on a plan that has already been sized and may already have raised CapacityError.

Why it matters: a user who passes an unsupported format on a constrained host sees a memory error instead of the intended UsageError naming the alias, so the message depends on free-memory state. It also means no other planning.plan/fit caller — including fit itself (planning.py:662) — can express the setting; the option exists in the CLI layer but not in the planning layer whose job it is (charter: "Solve the right problem in the right place"; AGENTS.md:452-456).

Fix: add target_head_quantization: str | None = None to fit and plan, validate it beside the draft-head loop at planning.py:487-495 raising the same UsageError, keep the Plan.__post_init__ check as the invariant, and drop the replace(...) plumbing plus the getattr(args, ...) guards that exist only because bench/join share parsers.

3. Docs claim a model and a conversion effect this repository cannot provide

docs/cli-design.md:454 (new table row).

--target-head-quantization {mxfp8} | Prepare the target vocabulary head as MXFP8 for recipes that declare target_head_quantizations (such as Qwen3.8 Flash Next with a BF16 checkpoint head), freeing the temporary BF16 vocabulary weight after conversion. …

No recipe in this repository declares target_head_quantizations (grep over the tree finds only the field, its validator, the plan/CLI/manifest plumbing and tests). Recipes live in local-inference-lab/hyperflare-recipes (AGENTS.md:9-13; design-review P3, docs/design-review.md:33-34), and the companion recipe PR local-inference-lab/hyperflare-recipes#40 is unmerged. So in this repository the flag is reachable but inert — every in-tree recipe rejects it — and nothing here verifies the conversion or the "freeing the temporary BF16 vocabulary weight" behaviour. The named model plus the memory effect read as present qualification, which AGENTS.md:194-199 forbids ("Do not present scaffolding or partially wired features as supported") and design-review P16 disallows for changed prose. The row also sits next to docs/cli-design.md:474, which states that --online-mxfp8 leaves "target vocabulary weights" at checkpoint precision; the two rows must not read as contradictory now that a separate flag exists.

Fix: state that the flag takes effect only when a recipe declares the capability (external recipe repositories), drop the named checkpoint and the unmeasured conversion detail, or land this PR together with the recipe and cite the measurement there.


Nits

  1. Discoverability — ignition/cli/help.py:76-91: the "Optional features for this recipe" list surfaces --expert-scale-compression, --mixed-prefill, --no-context-parallel, --no-stream-overlap, but not --target-head-quantization. ignition export MODEL --help therefore gives no hint the flag applies; --help says "for recipes that declare it" with no discovery path except rejection. The draft/Markov head flags share the gap, so this is a consistency improvement, not a regression.
  2. Design doc not updated — docs/runtime-core-design.md:374-377 enumerates the parameters living in PREPARATION_PARAMETER_SCOPE_TARGET_WEIGHT (online_mxfp8, resolved online_mxfp8_scope, expert_scale_compression). target_head_quantization now belongs in that list.
  3. Churn in bench — ignition/cli/bench.py:243-252 rewrites a flat dict comprehension into nested **{...} splats to append one optional key, while plan.to_dict() (planning.py:411-412) already omits the key when unset; a conditional add after the comprehension would be shorter. AGENTS.md:188-193 treats unsolicited restructuring as churn.
  4. Style inconsistency — ignition/preparation/rebuild_manifest.py:302-303 guards with getattr(plan, 'target_head_quantization', None) while :363-364 reads plan.target_head_quantization directly. The field is a real Plan field (planning.py:199), so the defensive form is dead weight; neighbours use plain attribute access.

Observations, not requests: --target-head-quantization is now the fourth parallel projection-precision flag (target head, draft head, draft body, Markov head), each with its own declaration tuple, validator, to_dict entry, reproduction_arguments pair and manifest parameter — the charter's "implemented once via a single general mechanism" is drifting for projection precision, and a maintainer decision on a single overrides declaration is worth having before a fifth arrives. Coverage: tests/cli/test_commands.py:102-138 covers parsing/help and derive forwarding + rejection, tests/cli/test_planning.py:212-253 covers validation and the manifest round-trip, but multi-host _export_hosts (serve.py:210), debug_serve (serve.py:479) and the bench configuration output (bench.py:250-251) are untested, and only a GPU export with a declaring recipe can show the conversion and the memory saving.


What is right (no action)

Open questions