Correctness review — PR #518, "Add recipe-declared --target-head-quantization preparation flag"
Head reviewed: f54928b (base main; open, ready for review, no reviews yet, no CI checks on this commit). Lens: correctness. Every changed file was read in its surrounding code, together with the callers and consumers the new Plan field can reach: derive, _export_hosts, _prepare, debug_serve, bench, planning.plan/fit/automatic/attempt/candidates, rebuild_manifest.reproduction_arguments/from_plan, and the Helios-side scope comparison that reads the manifest.
Key findings
- No blocking defect. The declaration → CLI → plan → manifest chain is internally consistent, and the PR's central compatibility claim ("omitting the flag leaves plans,
to_dict(), manifests, exports and checkpoint precision unchanged") is true in the code, not just asserted: the manifest helper skipsNonevalues, so no new default-valued parameter can appear. - Should fix — planning 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 memory-constrained DGX Spark GB10 target the PR motivates, that can reject a preparation that would have fit. - Should fix —
--draft-head-quantizationand--target-head-quantizationare combinable whiledocs/cli-design.md:453still says the draft head "retain[s] 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 check, while draft/markov heads are validated only infit(planning.py:487-491) with a near-identical message; the"mxfp8"literal is written in three places. - Cross-repo residual risk to state plainly: nothing in this repository reads
plan.target_head_quantizationexceptto_dict, the startup summary and the manifest, and nothing forwards it to peer ranks on multi-host export.
Verified-correct behaviour
Recipe declaration (ignition/declaration.py:276-278, 328-329)
target_head_quantizations: tuple[str, ...] = ()sits with the sibling head-format tuples (:277-280) and defaults empty, so every existing recipe declaration and everyRecipeconstructed positionally/by keyword in tests is unaffected.- The
__post_init__guardif any(name not in ("mxfp8",) for name in self.target_head_quantizations): raise ValueError(...)(:328-329) mirrors the neighbouringrow_shard_prefill_world_sizescheck (:325-327) and fires at recipe construction, before any plan exists.tests/cli/test_planning.py:217-218covers rejection of an unknown format. - The tuple-level comment was widened from "used only by proposals" to "vocabulary and transition projections" (
:276), which is correct now that a target head is in the list.
CLI surface (ignition/cli/__init__.py:212-214)
--target-head-quantizationis registered in the shared_preparation_argumentsadvanced group, which is attached to theexport,benchanddebug-serveparsers; there is no separateservesubcommand, so the PR's stated scope is complete.choices=("mxfp8",)makes argparse reject unsupported values before any recipe is consulted — the model-agnostic requirement. The help text names no model;tests/cli/test_commands.py:103-113asserts this by slicing--helpoutput and checking for the absence of "Qwen".- Default is
None(nodefault=, nostore_true), matchingPlan.target_head_quantization: str | None = None(planning.py:199).
Forwarding (ignition/cli/preparation.py:50-76, serve.py:210, 278, 479, bench.py:170)
derive(...)gains a trailing keywordtarget_head_quantization: str | None = None(preparation.py:57) and applies it in the existingreplace(...)on the plan (:70-75). Because it is keyword-only and the field defaults toNone, no existing positional or keyword call site changes behaviour.- Ordering matters and is correct: the
replacethat sets the field happens beforereturn tuning_devices(result, host, tuning_gpus)(preparation.py:76), so every tuning replica derived from the finished plan inherits it;tuning_replicasre-validates it because it reconstructs viaPlan(recipe=..., **values), which runs__post_init__again. - All four call sites use
getattr(args, "target_head_quantization", None). The guard is defensive but harmless — every parser reaching them builds on_preparation_arguments, so the attribute always exists and no path silently drops the flag. _prepare's status summary appends· target head mxfp8only when set (serve.py:314), so the default summary line is unchanged.
Validation (ignition/planning.py:289-293)
- The check lives in
Plan.__post_init__, so 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 (:286,:472,:490,:494).tests/cli/test_commands.py:132-138asserts theUsageErrorthroughderive.
Reporting (ignition/planning.py:411-412, ignition/cli/bench.py:250-251)
to_dict()mergestarget_head_quantizationonly when notNone, so anything diffing plan dictionaries 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"]conditionally merges the key only if it is present inpreparation, soto_dict()'s omission propagates and noKeyErroris possible.
Manifest (ignition/preparation/rebuild_manifest.py:302-303, 363-364)
from_planaddstarget_head_quantizationunderSCOPE_TARGET_WEIGHT(:363-364) only when set;add()returns early onNone(:350-352). Omitting the flag therefore produces a manifest byte-identical to the pre-PR one — no new parameter, so existing cores andflare combine/--reuse-weightsmetadata comparisons are untouched.SCOPE_TARGET_WEIGHT(:325) is the right scope: the target head is target-model weight semantics, so cores prepared with different target-head formats must not combine. The comparison runs on the generic parameter map Helios already compares per scope, so no Protobuf schema change is needed — consistent withhelios/and*.protobeing absent from the diff.reproduction_argumentsappends['--target-head-quantization', plan.target_head_quantization]after--force-moe-decode-a16(:300-303), so reproduction re-derives the same plan.tests/cli/test_planning.py:230-236asserts the flag/value pair inreproduction_args;:243-246asserts the manifest key and scope.- Round-trip determinism:
_preparation_value(:329-342) already handlesstr, and the test serialises into the ProtobufPreparationManifestand back, so the value survives generic-parameter encoding.
Documentation (docs/cli-design.md:454)
- The new row sits 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. Its stated benefit ("freeing the temporary BF16 vocabulary weight after conversion") is exactly the saving the planner does not model (finding 1).
Findings
1. Should fix — plan sizing and capacity errors ignore target_head_quantization
Where: ignition/planning.py:526 (the only weights_bytes call), with ignition/declaration.py:363-374 (Recipe.weights_bytes).
What is wrong. Plan gains target_head_quantization (planning.py:199) and validates it (:289-293), but the value never reaches sizing:
recipe.weights_bytes(checkpoint, len(gpus), speculation, expert_scale_compression), costs.graph_bytes, # planning.py:526
weights_bytes(checkpoint, world_size, speculation, expert_scale_compression=None) returns (device_bytes + expansion_bytes - draft_bytes + (draft_bytes if learned else 0)) // world_size — the stored, full-precision total. It has no head-quantization parameter, and fit has no such parameter either.
Why it matters. The flag's whole purpose, 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 at TP1. Using the pre-conversion estimate:
Plan.fits(planning.py:382-385) comparesfixed_bytes + page_bytesagainstsupply_byteswherefixed_bytesincludesweights_bytes, so a plan can be reported as not fitting when the prepared model would fit._shortfall(planning.py:551-563) then printsneeds X GiB weightswith 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.automatic()(planning.py:674-680) uses the samefits, so it can fall back to "the GPUs with the most free memory" or choose a larger TP size than necessary.- The reported
weights_bytesinplan.to_dict(), inbenchdetails and in the startup summary is likewise larger than what is actually prepared.
This lands on precisely the hardware the PR cites (DGX Spark GB10, TP1), not an exotic configuration.
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 the value through fit/fitted/automatic/attempt/candidates. If conservative sizing is deliberate, 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 failing fits under BF16 passes under MXFP8. The numeric saving itself lives in the companion recipe's declared costs, not in this diff.
2. Should fix — draft-head and target-head quantization can be combined, contradicting the documented contract
Where: docs/cli-design.md:453 versus ignition/planning.py:212-293 and :487-491.
What is wrong. Plan.__post_init__ rejects several conflicting pairs explicitly — --row-shard-prefill + --joint-tuning (planning.py:282-283), --force-moe-decode-a16 + --mixed-prefill (planning.py:262-263) — but nothing rejects --draft-head-quantization mxfp8 together with --target-head-quantization mxfp8. The draft row (cli-design.md:453) documents the draft-head option as preparing "a separate proposal vocabulary head while retaining target-head precision", and names Flash Next with "a BF16 target vocabulary head" as a supported case; the new target row (:454) also names Flash Next. Both flags are therefore individually documented as applying to the same recipe, with no statement about their combination.
Why it matters. Either the pair is legal (both heads quantized, two distinct weight scopes in the manifest) — in which case the draft row's "retaining target-head precision" sentence is now wrong and should be qualified — or it is not intended, in which case export should fail fast instead of silently producing a core whose two head scopes were never designed to coexist. As written, a user following the docs can reach a state the docs say is impossible.
Fix. Qualify the draft row to say the target-head sentence applies only when --target-head-quantization is omitted, or add a UsageError in Plan.__post_init__ next to the existing pair checks.
How to settle. The recipe declaration in local-inference-lab/hyperflare-recipes#40 settles intent; the code here settles that no validation exists.
3. Nit — duplicated and differently worded validation 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 phrased check in Plan.__post_init__ ("does not prepare this target head format"). Behaviour is fine — both raise UsageError naming the alias — but one rule now lives in two places with two phrasings, inviting drift when a second target-head format is added. The "mxfp8" literal appears in three places: declaration.py:328, the CLI choices at cli/__init__.py:212, and implicitly the plan check. Consider a single module-level constant, as AUTOTUNE_EFFORTS is imported for --autotune-effort (cli/__init__.py:224-226).
4. Nit — docs row could name the BF16-source-checkpoint precondition
Where: docs/cli-design.md:454.
The new row says "such as Qwen3.8 Flash Next with a BF16 checkpoint head", but the neighbouring draft row is explicit that "the packed NVIDIA head cannot be converted through this option" (:453). Stating the same precondition for the target head — a packed/non-convertible head must be rejected rather than silently left in its packed precision — would make the rejection contract unambiguous, and is the natural place to record it 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, the plan field, the CLI, bench, the rebuild manifest and the tests. That 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.
Two ways that ownership can go wrong:
- Declared but not acted on. If the companion recipe declares
target_head_quantizations=("mxfp8",)without its loader reading the plan field, export accepts the flag, recordstarget_head_quantizationunderSCOPE_TARGET_WEIGHT, prints "target head mxfp8", and produces a core whose head is still BF16. That is a silently accepted no-op, and its manifest now claims a weight layout different from a genuinely MXFP8-prepared core, so the two would be refused byflare combineand--reuse-weights. The direction of error is safe (refused rather than mixing wrong bytes), but the failure is silent at export time. - Multi-host peer propagation. In multi-host export (
--ranks > 1) the plan object stays on rank zero:HostRendezvous.preparesends peers only the recipe-supplied preparation config plus the prepare callable (ignition/preparation/host_ranks.py:348-353, peers consume it at:633-656).plan.target_head_quantizationtherefore reaches peer ranks only if the companion recipe copies it into that config. If it does not, rank zero and peers prepare different target-head precision while the manifest records MXFP8 underSCOPE_TARGET_WEIGHT(rebuild_manifest.py:363-364) — a divergence that is invisible to the manifest and that no test in this repository can cover. The TP2 RoCE validation the PR reports depends entirely on the recipe PR doing that translation.
Only a test in the recipes repository — prepare with the flag, then assert the target head's resident dtype/bytes on both rank zero and a peer — settles either case.
Open questions
- Does local-inference-lab/hyperflare-recipes#40 declare both
draft_head_quantizationsandtarget_head_quantizationsfor Flash Next, and does its loader readplan.target_head_quantization(including for peer ranks)? This decides finding 2 and both residual risks 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.
What I could not verify
- No CI checks ran on
f54928b. The PR reports 144 local tests passing on Linux ARM64 DGX Spark withtest_preparation_manifest_resolves_scopes_and_dflash2_inheritancedeselected for a prebuiltflare_heliopausewheel predating2771618. That deselected test is the one that would exercise manifest scope resolution against the wheel-based Helios code, so theSCOPE_TARGET_WEIGHTaddition is covered here only by the generic-path test (tests/cli/test_planning.py:230-248). - 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.
- The DGX Spark end-to-end numbers in the PR description (
+7.5–9.0%C1 decode, ~600 MiB saved at TP1,44/44quality gate, TP2 RoCEabbenchfigures) cannot be reproduced or checked from the code; they are attributed to the combined core + recipe stack, and the PR says so.
Note on review material
Nothing in the pull request description, its diff or its comments attempted to direct my behaviour; the description's statements about scope and validation were treated as claims to verify, and each was checked against the code above.