Conventions report · NVIDIA/hyperflare-inference #518

Raw Markdown for agents: https://autobot.eidonix.com/p/f411ca09-c49e-4cf4-bda0-6e01701b8cd1.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 where it departs from the established pattern or duplicates an existing helper, abstraction or mechanism.

Key findings

Details, precedent citations and fixes follow, most important first.


What the PR gets right (precedents it follows)


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 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 (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 args namespace these functions receive.

Why it matters. getattr(..., None) converts a broken parser wiring into "the user did not request the flag" — a silent default-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 pull 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: getattr(args, "dcp_size", None) (serve.py:197, :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 neither category.


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 or 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 inconsistent. target_head_quantization is a declared dataclass field of Plan with a default (ignition/planning.py:199), and the new line at :363 in the same PR reads it directly, so the defensive access at :302 protects nothing and makes two lines of one change disagree about whether the field is reliable.

Fix. Make :302 if plan.target_head_quantization is not None:, leaving the extend body unchanged; the emitted argument pair is identical, so the new manifest round-trip test (tests/cli/test_planning.py:212-253 (not opened)) is unaffected.

No finding on the branch shape itself. :302-303 is structurally identical to its neighbours (:290-291, :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 asymmetric with the other head tuples

Severity: nit Locations (verified):

Part A — the allowlist literal is now in three places. Supporting a second target-head format (say nvfp4) requires editing the argparse choices (__init__.py:212), the Recipe.__post_init__ tuple (declaration.py:328), and pairing both with the plan-time membership check (planning.py:289-293); nothing ties them together, so they can silently drift. Mitigating fact: the choices/__post_init__ duplication already exists for draft/markov/body, so the PR follows 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 is enforced where a requested value is checked against the declaration inside fit():

target_head_quantizations is instead validated twice: at declaration.py:328-329 and again at planning.py:289-293. Consequences:

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

  1. Match the draft/markov/body precedent — delete declaration.py:328-329 and rely on planning.py:289-293; or
  2. Keep it and hoist a single module-level constant (e.g. TARGET_HEAD_FORMATS = ("mxfp8",) in ignition/declaration.py) shared by Recipe.__post_init__ and the CLI choices= registration.

Honest counter-consideration: failing at recipe-load time is arguably better than failing at plan build, in which case the right follow-up is to bring draft/markov/body into line later, not to reject this PR.


Open questions / could not verify