Correctness review — PR #518, "Add recipe-declared --target-head-quantization preparation flag"
Scope: correctness lens. Every changed file was read in its surrounding code, together with the callers/consumers of Plan that the new field can reach: derive, _export_hosts, _prepare, debug_serve, bench, planning.plan/fit/automatic, rebuild_manifest.reproduction_arguments/from_plan, and the Helios-side scope comparison that consumes the manifest generic parameters.
Key findings
- No blocking defect. The declaration → CLI → plan → manifest chain is consistent, and the "omitted ⇒ byte-identical behaviour" claim holds in the code.
- Should fix — plan sizing never credits the flag (
ignition/planning.py:526,ignition/declaration.py:363-374).Recipe.weights_bytesstill counts the full-precision vocabulary head, soPlan.fits(planning.py:382-385),_shortfall(planning.py:551-563), the automatic GPU search (planning.py:674-680) and the suggested-options list (planning.py:697-725) describe a model larger than what MXFP8 preparation allocates. On the DGX Spark GB10 target the PR motivates, that can reject a preparation that would have fit. - Should fix —
--draft-head-quantizationand--target-head-quantizationcan be combined whiledocs/cli-design.md:453still states the draft head retains target-head precision. Nothing inPlan.__post_init__(planning.py:212-293) orfit(planning.py:445-540) rejects the pair. - Nit — validation drift: the target head is validated in
Plan.__post_init__(planning.py:289-293) and implicitly byfit's recipe membership, while draft/markov heads are validated only infit(planning.py:487-491) with a near-identical message. Two wording sites for one rule. - Cross-repo residual risk to state plainly: nothing in this repository reads
plan.target_head_quantizationother thanto_dict, the startup summary and the manifest.
Verified-correct behaviour
Recipe declaration (ignition/declaration.py:273-329)
target_head_quantizations: tuple[str, ...] = ()is appended next to the other head-format tuples and defaults to empty, so every existing recipe declaration is unaffected.- The
__post_init__checkif any(name not in ("mxfp8",) for name in self.target_head_quantizations)(declaration.py:328-329) mirrors the sibling validations forrow_shard_prefill_world_sizesand speculative methods and runs before any plan is built.tests/cli/test_planning.py:217-218covers rejection of an unknown format. - The comment above the tuple was widened from "used only by proposals" to "vocabulary and transition projections" (
declaration.py:276), which is now accurate since the target head is not a proposal projection.
CLI surface (ignition/cli/__init__.py:212-214)
--target-head-quantizationis registered in the shared_preparation_argumentsadvanced group, which is invoked forexporting(__init__.py:50),benchmarking(:53) andserving(:60) — henceexport,bench,debug-serve(andserve) all accept it.choices=("mxfp8",)means argparse rejects unsupported values before any recipe is consulted, consistent with the "model-agnostic" requirement; the help text names no model, whichtests/cli/test_commands.py:103-113asserts by slicing help between--target-head-quantizationand--markov-head-quantizationand checking for the absence of "Qwen".- Default is
None(nodefault=argument plus nostore_true), matchingPlan.target_head_quantization: str | None = None.
Forwarding (ignition/cli/preparation.py:53-74, ignition/cli/serve.py:207-210, 275-278, 476-479, ignition/cli/bench.py:167-170)
derive(...)gains a trailing keywordtarget_head_quantization: str | None = Noneand applies it withreplace(...)on the plan returned byplanning.plan, in the samereplacethat already carriesforce_moe_decode_a16etc. SincePlanis a dataclass with the new field defaulting toNone, adding it toreplacecannot change any other field; existing positional call sites are unaffected because the parameter is keyword-only after*._export_hosts,_prepare,debug_serveandbenchall usegetattr(args, "target_head_quantization", None). Thegetattrguard is defensive but harmless: the attribute exists on every parser that calls them (they all build on_preparation_arguments), so no path silently drops the flag.- Tuning replicas:
derivereturnstuning_devices(result, host, tuning_gpus). The flag is applied before that call, so any replica derived from the finished plan inherits the field; nothing intuning_devicesrebuilds a plan fromfields(...)without target-head, so no divergence. _prepare's status summary (serve.py:314) appends· target head mxfp8only when set, so the default summary line is unchanged.
Validation (ignition/planning.py:289-293)
- The check is in
Plan.__post_init__, which means it fires for every construction path —plan(),fit(),derive()'sreplace,tuning_devices,bench,debug_serve— not just the CLI. The message namesself.checkpoint.alias, matching the house style of the sibling messages (planning.py:472,:490,:494).tests/cli/test_commands.py:132-138asserts theUsageErrortext viaderive.
Reporting (ignition/planning.py:411-412, ignition/cli/bench.py:240-252)
to_dict()includestarget_head_quantizationonly when notNone. Anything that diffs plan dictionaries (config output,benchdetails, tests) therefore sees exactly the pre-PR dictionary when the flag is omitted — this is the mechanism that makes the compatibility claim true rather than merely asserted.bench'sdetails["configuration"]["preparation"]builds the fixed key list and conditionally mergestarget_head_quantizationfrompreparationonly if the key is present, soplan.to_dict()'s omission propagates correctly and noKeyErroris possible.
Manifest (ignition/preparation/rebuild_manifest.py:300-303, 357-364)
from_planaddstarget_head_quantizationunderSCOPE_TARGET_WEIGHTonly when set. Becauseadd()returns early onNone(rebuild_manifest.py:350-352), omitting the flag produces a manifest identical to the pre-PR one — no new default-valued parameter appears, so existing cores,flare combinecomparisons across cores, and--reuse-weightsmetadata matching are unchanged.SCOPE_TARGET_WEIGHTis the correct scope: the head is a target weight, so cores prepared with different target-head formats must not combine, and the comparison is on the generic parameter map that Helios already compares per scope — no Protobuf schema change is needed, which the diff confirms (helios/and*.protountouched).reproduction_argumentsappends['--target-head-quantization', plan.target_head_quantization]guarded bygetattr(..., None) is not None, placed after--force-moe-decode-a16. Reproduction therefore re-derives the same plan; the test attests/cli/test_planning.py:230-236asserts the flag/value pair insidereproduction_argsandtests/cli/test_planning.py:243-246asserts the manifest parameter key and scope.- Round-trip determinism:
_preparation_value(rebuild_manifest.py:329-342) already handlesstr, and the test serialises into the ProtobufPreparationManifestand back, so the value survives the generic parameter encoding.
Documentation (docs/cli-design.md:454)
- The new row sits in the preparation-flag table between the draft-head and markov-head rows, states the default (checkpoint precision), states that undeclared recipes reject it, and states "Command line only; changing it requires re-export" — the same contract as the neighbouring weight-precision flags. The stated reason ("freeing the temporary BF16 vocabulary weight after conversion") is consistent with the sizing gap below: the saving is real at preparation time, but the planner does not model it.
Findings
1. Should fix — plan sizing and capacity errors ignore target_head_quantization
Where: ignition/planning.py:526 (the only weights_bytes call in fit), with ignition/declaration.py:363-374 (Recipe.weights_bytes).
What is wrong: Plan gains target_head_quantization (planning.py:199) and validates it (planning.py:289-293), but the field is never passed into sizing:
recipe.weights_bytes(checkpoint, len(gpus), speculation, expert_scale_compression), costs.graph_bytes, # planning.py:526
and weights_bytes(checkpoint, world_size, speculation, expert_scale_compression=None) computes device_bytes + expansion_bytes - draft_bytes (+ draft_bytes) divided by the world size — the stored, full-precision weight total. It has no head-quantization parameter, and fit has no target_head_quantization parameter either (signature at planning.py:445-453).
Why it matters: the flag's whole point, per the PR description and the docs row, is to free the BF16 target head: 1.21 GiB for a 248,320 × 2,560 head, ~600 MiB resident on TP1. Using the pre-conversion estimate:
Plan.fits(planning.py:382-385) comparesfixed_bytes + page_bytesagainstsupply_bytes, wherefixed_bytesincludesweights_bytes. A plan can be reported as not fitting when the prepared model would fit._shortfall(planning.py:551-563) then prints "needs X GiB weights" with X overstated, andplan()'s repair search (planning.py:697-725) may suggest--max-concurrency N,--no-mtp,[memory] reserve = "0"or--language-model-onlyfor a configuration that already fits — or raiseCapacityErroroutright (planning.py:725).automatic()(planning.py:674-680) uses the samefits, so it can fall back to "the GPUs with the most free memory" or pick a larger TP size than needed.- The reported
weights_bytesinplan.to_dict()(planning.py:431), inbenchdetails, and in the startup summary is likewise larger than what is prepared.
This is precisely the memory-constrained configuration the PR cites (DGX Spark GB10, 273 GB/s LPDDR5X, TP1), so the misestimate lands on the target hardware rather than an exotic one.
Fix: give weights_bytes (or a wrapper used by fit) the target-head format and subtract the target vocabulary head's BF16 bytes — or add a per-format resident-bytes contribution — when target_head_quantization is not None, and thread target_head_quantization through fit/fitted/automatic/attempt/candidates in plan. If the estimate is deliberately kept conservative, the flag must at least be documented as not affecting fit, because otherwise an advertised-fitting configuration can fail planning.
How to settle: a test asserting replace(plan, target_head_quantization="mxfp8").weights_bytes < plan.weights_bytes (or that a plan which fails fits under BF16 passes under MXFP8) would fail today; a per-format saving constant requires the companion recipe to state the actual reduction, so the building blocks are in local-inference-lab/hyperflare-recipes#40.
2. Should fix/verify — draft-head and target-head flags can be combined against documented semantics
Where: docs/cli-design.md:453 and the new row at docs/cli-design.md:454; validation sites ignition/planning.py:212-293 (Plan.__post_init__) and ignition/planning.py:487-491 (fit).
What is wrong: --draft-head-quantization is documented as preparing "a separate proposal vocabulary head while retaining target-head precision", and the draft row explicitly says "Flash Next supports both with --speculative-method dflash2 and a BF16 target vocabulary head" — the same Flash Next recipe the new row names. Nothing rejects the combination: Plan.__post_init__ checks heads individually, fit checks draft/markov membership in the recipe's declared tuples (planning.py:487-491), and the draft-head path in ignition/cli/preparation.py:209-220 builds Speculation without consulting the target-head flag. Because the CLI accepts both on the same command line and both are recorded (draft under SCOPE_DRAFT_WEIGHT at rebuild_manifest.py:418-419, target under SCOPE_TARGET_WEIGHT at rebuild_manifest.py:363-364), a user can prepare a core whose draft head and target head are both MXFP8 while the documentation they read says the draft option preserves target precision.
Why it matters: correctness of the documented contract, and of the two distinct weight scopes that flare combine compares. If combining is legal and intended (a Flash Next core with both heads quantized), the draft row's "retaining target-head precision" sentence is now wrong and should be qualified; if it is not intended, Plan.__post_init__ should reject the pair with a UsageError, as it already does for --row-shard-prefill + --joint-tuning (planning.py:282-283) and --force-moe-decode-a16 + --mixed-prefill (planning.py:262-263).
How to settle: the recipe declaration in local-inference-lab/hyperflare-recipes#40 settles whether Flash Next declares both draft_head_quantizations and target_head_quantizations; the code here settles that no validation exists.
3. Nit — duplicated validation wording for the target head
Where: ignition/planning.py:289-293 versus ignition/planning.py:487-491.
fit already validates draft and markov heads against recipe.<head>_head_quantizations with the message --{head}-head-quantization {value}: {alias} does not prepare this proposal head format. The target head gets an equally correct but separately worded check in Plan.__post_init__ ("does not prepare this target head format"). Behaviour is fine — both raise UsageError naming the alias — but the same rule now lives in two places with two phrasings, which invites drift when a second target-head format is added (the "mxfp8" literal appears in three places: declaration.py:328, planning.py:289 via the recipe tuple, and the CLI choices at __init__.py:212). Consider deriving the choices tuple from a single module-level constant, as AUTOTUNE_EFFORTS is imported for --autotune-effort (__init__.py:224-226).
4. Nit — docs row could name the BF16 source-checkpoint precondition
docs/cli-design.md:454 says "such as Qwen3.8 Flash Next with a BF16 checkpoint head". The neighbouring draft-head row is explicit that "the packed NVIDIA head cannot be converted through this option" (:453). Stating the same precondition for the target head row (a non-convertible packed head must be rejected, not silently left in its packed precision) would make the rejection contract unambiguous — and would be the natural place to record that rejection, since the code here relies entirely on the recipe not declaring the format.
Cross-repo residual risk (not a defect in this diff)
Nothing in NVIDIA/hyperflare-inference consumes plan.target_head_quantization beyond to_dict (planning.py:411-412), the startup status string (serve.py:314) and the manifest entry (rebuild_manifest.py:363-364) — verified by searching the whole repository, where the only hits are the declaration, plan field, CLI, bench, rebuild-manifest and tests. This is by design ("core ignition stays strictly recipe-free"), but it means the flag's effect is entirely owned by local-inference-lab/hyperflare-recipes#40. If the companion recipe declares target_head_quantizations=("mxfp8",) without its loader consuming the plan field, then: export accepts the flag, records target_head_quantization under SCOPE_TARGET_WEIGHT, prints "target head mxfp8", and produces a core whose head is still BF16 — a silently accepted no-op whose manifest now claims a different weight layout from any genuinely MXFP8-prepared core, so the two would be treated as non-combinable by flare combine and as non-reusable under --reuse-weights. That direction of error is at least safe (refused rather than wrong bytes mixed), but the failure is silent at export time. Only a test in the recipes repository — prepare with the flag and assert the target head's resident dtype/bytes — settles it.
Open questions
- Does the companion recipe PR #40 declare both
draft_head_quantizationsandtarget_head_quantizationsfor Flash Next, and does its loader read the plan field? This decides finding 2 and the residual risk above. - Is the planner's omission of the head saving (finding 1) deliberate conservatism, or an oversight? The PR description cites the memory saving as the flag's benefit but never claims
Plan.weights_bytesreflects it, and no test in the diff compares sized bytes with and without the flag. - No CI checks ran on head
f54928b; the PR reports 144 local tests passing on Linux ARM64 with one test deselected for a staleflare_heliopausewheel. The deselected test (test_preparation_manifest_resolves_scopes_and_dflash2_inheritance) is the one that would exercise manifest scope resolution against the wheel-based Helios code, so theSCOPE_TARGET_WEIGHTaddition is verified here by the generic-path test instead.
What I could not verify from this repository
- The actual MXFP8 byte reduction for the target head (needed for finding 1's numeric fix) lives in the recipe's declared costs, not in this diff.
- DGX Spark end-to-end numbers in the PR description (+7.5–9.0% C1 decode, ~600 MiB TP1, 44/44 quality gate, TP2 RoCE
abbench) cannot be reproduced or checked from the code; they are attributed to the combined core + recipe stack, and the PR says so.