Correctness report · NVIDIA/hyperflare-inference #574

Raw Markdown for agents: https://autobot.eidonix.com/p/f96913b6-05a3-4376-805c-3c8de2b8b41e.md

Review of PR #574 — correctness lens (head 16ffc6f, base main, 2 files, +54/−1)

Rules read: AGENTS.md (evidence/validation rules, external-recipes policy, core-boundary policy), docs/design-review.md, and the charter (line 12: keep the runtime small and model-agnostic; recipes own model computation). Both changed files were read in full at head, plus every consumer of the changed predicate.

Key findings

Verdict: should-fix issues only. No blocking defect.

The change is a one-token widening of an allowlist and it is safe for everything it already touched: ignition./b12x. objects reduce exactly as before, the new test genuinely fails without the fix, the core-boundary AST test cannot be violated by a string literal, and the guard-code cache keys on pickled bytes so no stale guard can be served. Its three should-fix items are about how far the widening reaches and what contract it imposes on classes owned by another repository. There are five nits and one open validation item (no CI runs pytest; the author's run predated the rebase).

The change, in context

ignition/preparation/forward_metadata.py:39-45:

def _uses_custom_object_state(value):
    return (
        hasattr(value, '__dict__')
        and type(value).__module__.startswith(('ignition.', 'b12x.', 'hyperflare_recipes.'))   # line 42
        and not inspect.isclass(value)
        and not isinstance(value, _NON_OBJECT_NEW_TYPES)                                         # 33-36
    )

Grep shows exactly two consumers, and no others:

  1. ignition/preparation/aot.py:157-165 — _GuardPickler.reducer_override. Matched objects are rebuilt via _guard_object (aot.py:98-99, object.__new__(cls)) with every var replaced by _Missing('unguarded attribute') unless its id() is in guard_tree_values; returns the 3-tuple (_guard_object, (type(obj),), state). DetectedDevice is special-cased to restore_prepared_device (aot.py:163-164).
  2. ignition/preparation/forward_metadata.py:277-278 — _ForwardPickler.reducer_override, gated additionally on hasattr(type(value), '__getattr__'), returning (_object, (type(value),), dict(vars(value)), None, None, _set_state).

Should fix

1. ignition/preparation/forward_metadata.py:42 — the fix names one literal package, so other supported external recipe repositories still hit the same PicklingError.

AGENTS.md:379-384 states: "Official model recipes live in local-inference-lab/hyperflare-recipes … and external recipe repositories can pass their own Recipe tuples directly to ignition.cli.main(...)." That configuration is real in code: ignition/cli/__init__.py:367 is def main(argv=None, *, recipes=(), prog="ignition", source_roots=()) -> int:, and ignition/preparation/source_identity.py:12,18-25,43 threads arbitrary labeled extra roots (_EXTRA_ROOTS contextvar, source_roots(roots), combined_roots = (*_EXTRA_ROOTS.get(), *extra_roots)) into the source identity.

Why it matters: any external recipe package whose module name is not hyperflare_recipes and which prepares a non-nn.Module object holding an unpicklable compiled handle reproduces the exact failure this PR's "Why" describes. The bug class is narrowed to one package name, not fixed — and the fix means another core ignition edit per recipe repo.

Fix: drive the predicate from the roots the CLI already receives (match type(value).__module__ against the active source_roots/_EXTRA_ROOTS leaves plus the built-in prefixes), or follow the repo's own convention for externally owned types — explicit registration, as ignition/preparation/rebuild_manifest.py:41-71 does with declare_container_fields / weight_container / declare_module_buffers.

2. ignition/preparation/aot.py:157-165 — the guard path imposes ignition's internal state protocol on classes owned by another repository.

The reduction returns (_guard_object, (type(obj),), state) with no state_setter. Consequences, each verifiable in the code:

Why this is new exposure rather than a pre-existing one: grep finds no __setstate__ anywhere under ignition/ (the only custom reducers are ignition/declaration.py:130 and ignition/preparation/forward_metadata.py:145), so ignition./b12x. classes are all consistent with the 3-tuple form. The contract is simply not established for hyperflare_recipes.* classes, which live in another repository.

Fix: return (_guard_object, (type(obj),), state, None, None, _set_state) mirroring aot.py:151 so reconstruction can never consult an external __setstate__, and document the required state contract in _GuardPickler's docstring (aot.py:102-103, currently one line: "Exclude unguarded kernel resources from prepared Python objects."). Ideally also cover slot state so the reported failure is fixed for slots-only recipe objects.

3. ignition/preparation/forward_metadata.py:277-278 — the second consumer is genuinely reachable, and for __getattr__-defining recipe classes the widening changes behaviour silently.

The extra gate is hasattr(type(value), '__getattr__') (class-level), which is exactly what delegating/proxy wrappers — a common shape for prepared recipe components — define. Before this PR those classes failed the module-prefix test and kept their own __reduce__/__getstate__; after it they are rebuilt as object.__new__(cls) plus vars() with _set_state, so __slots__ and __getstate__-transformed state are dropped silently rather than raising.

Where those bytes go: forward_metadata.dumps payloads are shipped to forward compiler workers via ignition/preparation/compile_pool.py:96-118 (_compile_forward → loads(payload) → aot_forward) and compile_pool.py:137-153 (submit → dumps), plus cross-host lent jobs (ignition/preparation/aot.py:986-1003) and artifact sharing (aot.py:1137-1138). Silent state loss changes worker-side compilation inputs instead of erroring clearly. The restored-forward path cache does not protect: aot.py:1181-1183 keys it on (type(forward).__module__, __qualname__, name, signature).

Coverage gap: the new test uses _RecipeKernelOwner (tests/preparation/test_guard_code.py:257-265), which has no __getattr__, so this path is untested. Fix: add a forward_metadata.dumps/loads round-trip assertion for a hyperflare_recipes.* object with a class-level __getattr__, or gate both picklers on the same predicate semantics.

Nits

Verified positives (checked, not assumed)

Open questions / not verifiable here