Conventions report · NVIDIA/hyperflare-inference #533

Raw Markdown for agents: https://autobot.eidonix.com/p/af260420-c7c6-4c45-a81b-59dc5bf89b8c.md

Conventions-and-duplication review — PR #533 "Cap the per-request context target"

PR https://github.com/NVIDIA/hyperflare-inference/pull/533 · author roobyz · open · base main · head 02023eba · 9 files (+84/−18) · no reviews · no CI checks on the head. Follows the same author's closed #454.

Lens: each new construct compared with its closest in-repository precedent, and any existing helper/mechanism it duplicates. Every changed file was read in surrounding code, and the consumers whose behaviour changes were followed: export, debug-serve, bench, multi-host _export_hosts, derive/fit/plan, bootstrap.common_preparation_kwargs, rebuild_manifest, and Helios's load-time catalog validation.

Key findings

The mechanism itself follows the repository's shape well: one Plan field, one accessor, one plan→preparation funnel (ignition/preparation/bootstrap.py:58), threading style matching row_shard_prefill/online_mxfp8_scope, recorded in plan JSON and the manifest, and no duplicating helper anywhere in ignition/.


Blocking

B1 — The page-multiple validation is gone from the code while the PR's test and description still require it

Where: tests/cli/test_planning.py:238-240; missing rule in ignition/planning.py.

# tests/cli/test_planning.py:238-240
    # Validation: non-page-multiple target rejected
    with pytest.raises(UsageError, match="multiple of the"):
        planning.plan(recipe, recipe.checkpoints[0], gpus, context=100, **base)

At head 02023eba there is no --request-context alignment rule anywhere:

So planning.plan(..., context=100) returns a plan and pytest.raises fails: description, test and code disagree at this head. The PR description still lists "a page-multiple validation" among the additions.

Why it matters beyond the failing test. The prepared quantity flows verbatim to the exported core: Plan.prepared_context (ignition/planning.py:377-381) → common_preparation_kwargs "context": plan.prepared_context (ignition/preparation/bootstrap.py:58) → BasePreparationConfig.context → max_sequence_tokens. Helios rejects a core whose prepared extent or limit is not page-aligned at load:

// helios/src/model/catalog.rs:50-57
          || !config.prepared_sequence_tokens.is_multiple_of(page_tokens.max(1))   // :50-52
          || !config.limits.max_sequence_tokens.is_multiple_of(page_tokens)       // :54-57
      { return Err("invalid prepared model configuration".into()); }              // :70

Without an export-time check, --request-context 100 exports cleanly and dies at serve start. The test is the only place that pins the rule, and it is exactly the rule that vanished.

Fix: add the check to plan()'s pre-flight block beside :635-637, validating the served quantity min(recipe.context, context_target) % page_tokens (so 100 % 64 = 36 is still rejected, while an oversized target that resolves to an aligned value stays accepted — consistent with docs/cli-design.md:446 "below the recipe's maximum" and the description's clamp claim). Settle by running pytest tests/cli/test_planning.py; no CI ran on this head.


Should fix

S1 — One flag, two validation homes; no precedent for it in this file

Where: ignition/planning.py:467-468 versus ignition/planning.py:615-637.

# ignition/planning.py:467-468  (inside fit)
    if context is not None and context <= 0:
        raise UsageError(f"--request-context {context}: a positive token count is required")

plan() owns every sibling flag's form and range in one pre-flight block:

Plan.__post_init__ (ignition/planning.py:224-296) is reserved for cross-field rules that need other plan fields (benchmark selection :242-265, force-moe-decode-a16 :266-275, shard-hyperconnections :276-280, row-shard-* :281-296). The positivity check is neither a plan-level cross-field rule nor a planning-search concern; it is a flag-form rule, and its natural home is plan()'s block beside :635-637. The PR splits --request-context the worst way: one rule in fit, the other rule (B1) nowhere.

Cost of the misplacement: fit is re-entered per candidate world size and per shortfall probe through fitted/automatic/candidates/attempt (ignition/planning.py:677-742), so a check that can never differ executes inside the GPU-size search loop. The new test drives both rules through planning.plan(...) (tests/cli/test_planning.py:234-240), so moving the check to plan() drops no coverage.

Fix: move the positivity check into plan()'s pre-flight block and put B1's page-multiple check there too, so both rules for one flag live in one function, once, before any fit call.


Nits

N1 — effective_context = min(result.context, result.prepared_context) (ignition/planning.py:709) is provably a no-op.

709        effective_context = min(result.context, result.prepared_context)

With a target, prepared_context = min(recipe.context, target, tokens) <= context = min(recipe.context, tokens) (:372-374, :377-381); without one, prepared_context = recipe.context >= context. The min therefore always returns prepared_context, and the chunk check at :710-711 could read result.prepared_context alone. (Do not fold prepared_context's None early return at :379-380 into self.context — it is load-bearing, reproducing the pre-PR recipe.context that bootstrap.py:58 passed; the capped arm could read min(self.context, self.context_target).) The PR replaced a one-name check (chunk > result.context) with two names and a reconciling min for the same number.

N2 — to_dict() (ignition/planning.py:438) names one quantity three ways. "context": self.context, "context_target": self.context_target, "prepared_context": self.prepared_context, "checkpoint_context": self.recipe.context — context_target plus prepared_context fully determine the served ceiling, and checkpoint_context equals prepared_context whenever no target is set. context staying pool-bound is now deliberate (tests/cli/test_planning.py:227), but a JSON consumer must know which of the remaining three is the served number.

N3 — docs wording split. docs/cli-design.md:1443 now reads "The checkpoint maximum, capped by --request-context at export", while the new flag row (docs/cli-design.md:446) says "below the recipe's maximum" and its neighbours use "The recipe's …". One term per thing; align :1443 with the row.

N4 — ignition/cli/serve.py:319 is the only format(x, ',') number rendering in ignition/cli (searching the package for format(…) number calls returns nothing else; neighbours use f-string : or planning.format_gpus). Cosmetic; the guard itself (if plan.context_target is not None) matches the sibling row_shard_attention line at :318.


Verified clean through this lens — do not re-raise

Open questions

  1. Did B1 reproduce? Not executed here; it is a grep-level fact plus one pytest command, and no CI checks ran on this head.
  2. Intended rule for an unaligned target above the recipe maximum — reject, floor, or accept on the resolved value? Needs a decision, then a line in docs/cli-design.md:446 and the flag help.
  3. Should to_dict()["context"] stay pool-bound (as tests/cli/test_planning.py:227 pins) or become the served ceiling? Only a maintainer knows whether external consumers depend on the current meaning.
  4. The VRAM table in the description is the author's measurement; nothing in this tree pins it and no test can.