Conventions report · NVIDIA/hyperflare-inference #518

Raw Markdown for agents: https://autobot.eidonix.com/p/2d6a18cf-6fff-429e-bccd-9a7568248ea8.md

Review of PR #518 — Add recipe-declared --target-head-quantization preparation flag

Lens: conventions and duplication — compare each new construct with its closest precedent in the repository, and flag any existing helper, abstraction or mechanism it duplicates.

Key findings

Nothing found that warrants blocking. Details, precedent citations and fixes follow, most important first.


Nit 1 — getattr where every sibling flag uses direct attribute access

Severity: nit Files and lines (verified):

The precedent it departs from. In each of these four calls the immediately surrounding arguments are read directly from the namespace:

Why the getattr is unnecessary, not merely inconsistent. The flag is registered once inside _preparation_arguments at ignition/cli/__init__.py:212-214, and that group is attached to all three commands that reach these handlers: export (__init__.py:50), bench (:53) and debug-serve (:60). The attribute therefore always exists on the namespace these functions receive.

Why it matters. getattr(..., None) converts a broken parser wiring into "the user did not request the flag" — a silent wrong-precision export instead of a crash. That is exactly the regression the new test test_target_head_quantization_flag_is_model_agnostic (tests/cli/test_commands.py:102-113) exists to catch, so the two artifacts are pulling in opposite directions: the test asserts the attribute is always present, while production code defends against its absence.

Fix. Use args.target_head_quantization at all four sites, matching the neighbouring arguments.

Contrast — where getattr is the established pattern. The repository uses getattr(args, ...) only where the attribute can genuinely be missing from some command's namespace: getattr(args, "dcp_size", None) (serve.py:197 and :283), and the draft-head flags read inside preparation.speculation (ignition/cli/preparation.py:169-171), which not all of export/bench/debug-serve define. --target-head-quantization is in none of those categories.


Nit 2 — two access styles for the same field in rebuild_manifest.py

Severity: nit File and lines (verified):

The precedent. In reproduction_arguments, real Plan fields are accessed directly: if plan.force_moe_decode_a16: (:300, immediately above the new line), if plan.shard_hyperconnections: (:306), if plan.row_shard_prefill: (:308), if plan.joint_tuning: (:310). getattr appears only for attributes that may not exist on older/foreign plan-like objects — getattr(plan, 'prompt_logprobs', False) (:266), getattr(plan, 'native_dense_activations', False) (:304), getattr(plan, 'autotune_effort', '') (:314), getattr(plan, 'lock_gpu_clocks', False) (:316).

Why it is wrong here. target_head_quantization is a declared dataclass field of Plan with a default (ignition/planning.py:199), and the new line at :363 already reads it directly, so the defensive access at :302 protects nothing and makes two lines of the same PR disagree about whether the field is reliable.

Fix. Make :302 if plan.target_head_quantization is not None: and keep the extend body unchanged; the emitted argument pair stays identical, so the new manifest round-trip test is unaffected.

Note on the shape of the branch itself (no finding). The new :302-303 branch is structurally identical to its neighbours at :290-291 and :300-301, i.e. it follows the local pattern; only the access style is off.


Nit 3 — format allowlist duplicated as a third literal, and declaration-time validation is asymmetric with the other head tuples

Severity: nit Locations (verified):

Part A — the literal is now in three places. Supporting a second target-head format (say nvfp4) requires editing the argparse choices at __init__.py:212, the Recipe.__post_init__ tuple at declaration.py:328, and pairing it with the plan-time branch that validates against the declared tuple; nothing ties them together, so they can silently disagree. In fairness, duplication between argparse choices and Speculation.__post_init__ already exists for draft/markov/body (__init__.py:204/declaration.py:141, __init__.py:207/declaration.py:135), so the PR is following a pre-existing (if imperfect) convention rather than inventing one — hence nit, not should-fix. The incremental cost is one more unlinked literal.

Part B — the placement departs from precedent. The comparable recipe-level tuples are not validated in Recipe.__post_init__; membership in them is enforced where a request is checked against the declaration:

target_head_quantizations instead gets validated twice: at declaration time (declaration.py:328-329) and again at plan time (planning.py:289-293). Consequences: (a) inconsistent failure modes — a typo'd draft_head_quantizations=("nvfp5",) is accepted at import and simply never matchable, whereas target_head_quantizations=("nvfp4",) fails loudly; (b) a recipe author cannot express a target-head format the recipes package knows about but this core release does not, and gets a hard import error instead of an unreachable declaration; (c) the plan-time message ("--target-head-quantization {x}: {alias} does not prepare this target head format", planning.py:290-293) already covers the user-facing case, so the declaration-time check is defence in depth with no precedent behind it.

Fix (either is acceptable; the asymmetric version is the one to avoid):

Counter-consideration, stated honestly: the new check is arguably better behaviour than the draft/markov path, since it fails at recipe load rather than at plan build. If the maintainers prefer it, the right resolution is to make the draft/markov/body tuples consistent with it later, not to reject this PR.


Conventions the PR gets right (checked, no finding)

Open questions / could not verify