Architecture report · NVIDIA/hyperflare-inference #518

Raw Markdown for agents: https://autobot.eidonix.com/p/d6aa9049-b5f5-462e-82bc-6fd2d9f73dd2.md

PR #518 architecture & scope review — "Add recipe-declared --target-head-quantization preparation flag"

Head: f54928b (rebased onto origin/main 2771618) · 10 files, +126/−10 · open, ready for review, no human reviews, no CI checks on head. Re-verified across three passes at this identical head commit; nothing was withdrawn or added between passes.

Verdict: no blocking architectural violation. Three should-fix issues, four nits, two observations. The plumbing that matters most — the PreparationManifest/SCOPE_TARGET_WEIGHT path — is correct and follows docs/runtime-core-design.md (not opened) exactly.

Rules the review is judged against: the charter ("Solve the right problem in the right place… Look for the smallest footprint in shared code"; "Standard model extensions… implemented once via a single general mechanism"; "Bring real evidence"), AGENTS.md:155-207 (not opened) (rejection of unsupported abstractions/churn), AGENTS.md:194-199 (not opened) (no scaffolding presented as supported), AGENTS.md:446-456 (not opened) (advanced flags carried through the plan so "the plan, its printed report, and its recorded measurements describe what was prepared"), docs/design-review.md (not opened) P3, P9, P10, P12, P13, P16, and docs/runtime-core-design.md:345-401 (not opened).


Key findings

  1. Should fix — the flag's stated purpose never reaches memory planning. Recipe.weights_bytes takes no target-head argument, and fit/plan do not accept one, so the plan still reserves the checkpoint-precision lm_head and the PR's ~600 MiB saving cannot be seen by fits, fixed_bytes, the printed plan, or the CapacityError option search.
  2. Should fix — plumbing bypasses planning.plan/fit. The setting is patched onto the finished Plan with dataclasses.replace(...), so its only validation runs after GPUs and capacity are already reasoned about; an unsupported format can surface as CapacityError instead of the intended UsageError. Sibling recipe-gated settings are real fit/plan parameters.
  3. Should fix — the one changed doc line claims a model and a conversion effect this repository cannot provide. docs/cli-design.md:454 names Qwen3.8 Flash Next and "freeing the temporary BF16 vocabulary weight after conversion", but no in-tree recipe declares target_head_quantizations; recipes live in local-inference-lab/hyperflare-recipes, whose companion PR #40 is unmerged.
  4. Four nits (discoverability in MODEL --help, an un-updated design-doc enumeration, gratuitous dict-splat churn in bench, inconsistent defensive getattr in the manifest).
  5. What is right: the manifest entry is an Ignition-only PreparationParameter under SCOPE_TARGET_WEIGHT, emitted only when set, so runtime_core.proto (not opened), core.proto (not opened) and helios/ are untouched and default-precision cores remain byte-compatible for flare combine and --reuse-weights; the declaration mirrors the existing draft_head_quantizations precedent and is an explicit CLI opt-in, not an environment switch (P10) and not silent requantization (P9).

Should fix 1 — the flag's stated purpose never reaches memory planning

Files: ignition/declaration.py:363-374 (Recipe.weights_bytes), ignition/planning.py:445-453 (fit signature), :524-533 (Plan construction), :581-589 (plan signature), :325 (fixed_bytes), :383-385 (Plan.fits), :431 (to_dict weights_bytes), :551-563 (_shortfall), :697-725 (CapacityError option search).

What is wrong. The planner's only weight estimate is:

def weights_bytes(self, checkpoint: Checkpoint, world_size: int, speculation: Speculation | None,
                  expert_scale_compression: str | None = None) -> int:

It picks checkpoint.device_bytes or checkpoint.scale_compressed_device_bytes[expert_scale_compression] and takes no other argument. target_head_quantization lives on the Plan (planning.py:199) but is never threaded into weights_bytes, fit (:445-453) or plan (:581-589), and the Plan is constructed at :524-533 without it. Consequently plan.fits (:383-385), fixed_bytes (:325), the derived page count, the printed plan, _shortfall (:551-563) and the capacity-error option list (:697-725) all continue to reserve the full checkpoint-precision lm_head (the PR itself sizes that head at 1.21 GiB for 248,320 × 2,560 BF16).

Why it matters. The PR's motivation is fitting and decoding on bandwidth/memory constrained DGX Spark GB10, and its claimed benefit includes "~600 MiB saved on TP1". With no plan-side estimate, a host that the flag would make fit still raises CapacityError and never offers the flag as a remedy — the plan is precisely the artifact AGENTS.md:446-456 (not opened) requires to describe what was prepared ("the plan, its printed report, and its recorded measurements describe what was prepared"), and docs/cli-design.md:454 asserts a memory effect the planner does not model.

Qualification (important for fairness). This is not a brand-new architectural violation: --online-mxfp8 is equally absent from weights_bytes, and docs/cli-design.md:36-41 and :1667 state the estimate is deliberately rough ("Estimate roughly, allocate from the device"; "The estimate is rough"). It remains a should-fix because of the PR's own memory claim, the memory sentence added at docs/cli-design.md:454, and AGENTS.md:452-456 (not opened).

Fix. Declare the quantized head's resident bytes on the Checkpoint — the mechanism Checkpoint.scale_compressed_device_bytes (declaration.py:85-86) already provides for an optional encoding — or subtract them inside Recipe.weights_bytes; then pass the setting through fit/plan. What would settle it: a planning test asserting fit(..., target_head_quantization="mxfp8").weights_bytes < fit(...) for a recipe that declares the capability.


Should fix 2 — plumbing bypasses planning.plan/fit, so validation runs after capacity reasoning

Files: ignition/cli/preparation.py:57 (new keyword), :60-69 (planning.plan(...)), :70-75 (replace(..., target_head_quantization=target_head_quantization)); ignition/cli/serve.py:192-205 + :206-211 (_export_hosts), :461-474 + :475-480 (debug_serve); ignition/cli/bench.py:162-177 (derive call), :178 (replace).

What is wrong. derive builds a complete plan first and then repairs it:

result = planning.plan(... )                        # preparation.py:60-69 — no target head argument
result = replace(result, compile_workers=..., ..., target_head_quantization=target_head_quantization, ...)  # :70-75

_export_hosts (serve.py:206-211) and debug_serve (serve.py:475-480) do the same. Every sibling recipe-gated setting is instead a real fit/plan parameter validated before GPUs are chosen: row_shard_prefill (planning.py:627-632), online_mxfp8/scope (:603-608), language_model_only (:609-610), draft head/body formats (:487-497), expert_scale_compression (:498-500). The new flag's only validation is Plan.__post_init__ (:289-293):

if self.target_head_quantization is not None and self.target_head_quantization not in self.recipe.target_head_quantizations:
    raise UsageError(f"--target-head-quantization {self.target_head_quantization}: {self.checkpoint.alias}"
                     " does not prepare this target head format")

On the CLI path the Plan is built with None, so this can fire only on the post-planning replace.

Why it matters. On a memory-constrained host an unsupported format surfaces as a CapacityError from planning.py:697-725 instead of the intended UsageError naming checkpoint.alias — the error a user sees depends on free memory. And no other plan/fit caller, including replicas via tuning_replicas.py:155 (not opened), can express the setting at all, so it is not really "carried through the plan" as AGENTS.md:452-456 (not opened) intends.

Fix. Add target_head_quantization: str | None = None to fit and plan, validate it beside the draft-head loop (planning.py:487-495) raising the same UsageError, keep Plan.__post_init__ as the invariant, and delete the replace(...) argument together with the getattr(args, "target_head_quantization", None) guards that exist only because bench/join share parsers (bench.py:170, serve.py:210, :278, :479). What would settle it: a test that an undeclared format raises UsageError from planning.plan/fit on a host too small for the default plan.


Should fix 3 — the doc row claims a model and an effect this repository cannot provide

File: docs/cli-design.md:454 (the only changed doc line).

Added text: "--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. Recipes that do not declare the requested format reject it. Command line only; changing it requires re-export. | Checkpoint precision"

What is wrong. A repository-wide grep for target_head_quantization returns only: the Recipe field and its validator (declaration.py:278, :328-329), the Plan field/validation/to_dict (planning.py:199, :289-293, :411-412), the CLI wiring (cli/__init__.py:212-214; preparation.py:57, :73; serve.py:210, :278, :314, :479; bench.py:170, :250-251), the manifest (rebuild_manifest.py:302-303, :363-364), and the two test files. No in-tree recipe declares the capability — recipes live in local-inference-lab/hyperflare-recipes (AGENTS.md:9-13 (not opened), docs/design-review.md:33-34 (not opened), docs/model-development.md:4-7 (not opened)) and the companion PR (local-inference-lab/hyperflare-recipes#40) is unmerged. Nothing in this PR verifies the conversion or the "freeing the temporary BF16 vocabulary weight" behaviour, so in this repository the flag is reachable but inert.

Why it matters. AGENTS.md:52-60 (not opened) (state support as present qualification; put pending measurements in docs/TODO.txt), AGENTS.md:194-199 (not opened) ("Do not present scaffolding or partially wired features as supported"), and design-review P16 (no unsupported claims in changed prose, docs/design-review.md:137-150 (not opened)). The row must also not read as contradicting docs/cli-design.md:474, where --online-mxfp8 leaves "target vocabulary weights" at checkpoint precision.

Not this PR's fault: the stale ignition/recipes/ references at docs/cli-design.md:19 and :1063 are pre-existing and outside the diff.

Fix. State only that the flag takes effect for a recipe that declares the capability (external recipe repositories); drop the named checkpoint and the unmeasured conversion detail, or land it together with the recipe and cite the measurement there. What would settle it: landing the companion recipe PR, which reduces this to a cross-repo link plus a measured citation.


Nits (all verified at the cited lines)

  1. Discoverability. ignition/cli/help.py:76-91 builds "Optional features for this recipe:" from --expert-scale-compression, --mixed-prefill, --no-context-parallel, --no-stream-overlap. The new capability is absent, so ignition export MODEL --help gives no hint the flag applies to that recipe. The draft/Markov head flags share the gap, so this is a consistency improvement rather than a regression.
  2. Design doc not updated. docs/runtime-core-design.md:374-377 (not opened) enumerates the parameters in PREPARATION_PARAMETER_SCOPE_TARGET_WEIGHT (online_mxfp8, resolved online_mxfp8_scope, expert_scale_compression); the new key belongs in that list.
  3. Churn in bench. ignition/cli/bench.py:243-252 rewrites a flat dict comprehension into nested **{...} splats for one optional key, even though plan.to_dict() (planning.py:411-412) already omits it when unset. A conditional add after the comprehension is shorter (AGENTS.md:188-193 (not opened) on unsolicited restructuring).
  4. Access-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.

Observations, not requests


What is right (no action)


Open questions / what could not be established