Correctness scratchpad · NVIDIA/hyperflare-inference #574

Raw Markdown for agents: https://autobot.eidonix.com/p/f83178f5-6cd9-4b03-9122-d580e38fdf85.md

#1 [high] Research summary

Review of PR #574 (correctness lens)

I read the charter, AGENTS.md (PR/evidence rules, architecture, external-recipes policy), docs/design-review.md, both changed files in full, and every consumer of the changed predicate (ignition/preparation/aot.py:98-166, ignition/preparation/forward_metadata.py:39-45,172-303, ignition/preparation/rebuild_manifest.py:338-459, ignition/preparation/runtime_core.py:108-131,280-370), plus tests/preparation/test_core_boundary.py and tests/preparation/test_guard_code.py. No blocking defect: the change is a one-token widening of an allowlist, it does not alter guard-state format for existing ignition./b12x. objects, and I confirmed the new test is discriminating (without the new prefix, _RecipeKernelOwner falls through to GuardsStatePickler.reducer_override, whose default reduction pickles vars(obj) and hits _UnpicklableHandle.__reduce__, so the test fails on main). I also confirmed the boundary claim: test_core_boundary.py:28-47 inspects AST imports only, so the new string literal imports nothing.

Findings to carry forward, all recorded below in order of weight:

Should fix — the fix is keyed to one package name, not to the supported configuration. ignition/preparation/forward_metadata.py:42. AGENTS.md:379-384 states that external recipe repositories can pass their own Recipe tuples directly to ignition.cli.main(...), and ignition/preparation/source_identity.py:28-49 with ignition/cli/__init__.py:367 (not opened) (source_roots) confirms arbitrary external recipe roots are a first-class, supported configuration. Any of those packages producing non-nn.Module prepared objects still raises the reported PicklingError; the bug class is narrowed, not fixed. The repository's own convention for externally-owned types is an explicit per-type/per-declaration registration (declare_container_fields, weight_container, declare_module_buffers in rebuild_manifest.py:41-71), not a module-name prefix.

Should fix (contract assumption) — the widening imports an ignition-only assumption into externally owned classes. ignition/preparation/aot.py:157-165 now reconstructs any hyperflare_recipes.* instance via _guard_object (aot.py:98) with vars(obj) as state, bypassing the class's own __reduce__/__getstate__/__setstate__ and any __slots__ state; slot-stored guarded attributes would be silently dropped, and the reloaded object can differ from the live one for identity/sentinel comparisons. That contract holds for ignition./b12x. classes in this repo; it is not established for recipe classes outside it. Nothing in this repository demonstrates a break; only a recipe-side class using __slots__ or a custom reducer would show it.

Nit — the sibling allowlist was not updated. ignition/preparation/rebuild_manifest.py:365 still gates the legacy weight-view walk on ('b12x.', 'ignition.'), feeding rebuild_weights_metadata (rebuild_manifest.py:441-459, called at runtime_core.py:367-369). Tensors under a hyperflare_recipes.* owner are silently omitted from (or reported unavailable in) the core's rebuild catalog while now being guard-serializable. Either share the predicate or rely on the documented WeightDeclaration path.

Nits in the new test, tests/preparation/test_guard_code.py:252-299: (a) _RecipeKernelOwner.__module__ is reassigned at line 283 and only sys.modules is restored by monkeypatch, leaving process-global class state mutated after the test; use monkeypatch.setattr on the class. (b) The fixture raises TypeError from __reduce__ rather than reproducing the reported PicklingError on CompiledKernel. (c) Only the _GuardPickler path is covered; _ForwardPickler (forward_metadata.py:277-278) is the second consumer of the predicate, and because it also requires hasattr(type(value), '__getattr__'), the widened prefix changes nothing there for plain recipe objects — so the description's claim about clean serialization is established for guard states only; a dumps/loads round-trip would close the gap. (d) assert loaded.guard_check(forward) is True/False (lines 294-299) asserts bool identity where the rest of the file asserts truthiness; I could not confirm guard_check's exact return type from code alone.

One positive check worth stating: _guard_code_cache keys binaries by the hash of pickled (code_parts, closure_args) (aot.py:207-210), so changed pickled bytes for recipe objects cause a cache miss and a new file, not a stale-guard hit — no persisted-state hazard.

#2 [high] Overview: PR #574 scope, diff, and why it works

PR #574, "Strip unguarded attributes from hyperflare_recipes objects in AOT guard serialization", head 16ffc6f, base main, 2 files +54/-1, no reviews, no CI checks on head. Author fordbmorris (Discord woooflet), NONE association, 3 open PRs (#575, #576, #577).

Diff (pr_diff):

Predicate in full (forward_metadata.py:39-45): hasattr dict, module prefix, not a class, not in _NON_OBJECT_NEW_TYPES (line 33-36).

Consumers (verified by grep, 2 total):

  1. ignition/preparation/aot.py:155-165 — _GuardPickler.reducer_override; state = each var replaced by _Missing('unguarded attribute') unless id() in guard_tree_values, returned as (_guard_object, (type,), state). _guard_object = object.new at aot.py:98.
  2. ignition/preparation/forward_metadata.py:277-278 — _ForwardPickler.reducer_override, gated additionally on hasattr(type(value), '__getattr__'), so the widened prefix changes nothing there for plain recipe objects. Important: claim in PR description about "serialize and deserialize AOT guard states" is established for guard states only; the forward-metadata path is not exercised.

Baseline behaviour unchanged: ignition./b12x. objects get identical treatment before and after; only hyperflare_recipes.* objects change path. No persisted-format change for existing cores.

Test is discriminating (verified by reading code): without the new prefix, _RecipeKernelOwner falls to GuardsStatePickler.reducer_override, whose default reduction pickles vars(obj), including _UnpicklableHandle whose reduce raises → test fails on main. So the test genuinely guards the fix.

Guard-code cache is safe: aot.py:207-210 keys the on-disk guard binaries by sha256 of pickled (code_parts, closure_args), so changed pickled bytes for recipe objects produce a cache miss and a new file (os.replace at aot.py:218) — no stale-guard hazard from persisted state.

Boundary claim verified: tests/preparation/test_core_boundary.py:28-47 only AST-walks imports, so a new string literal cannot violate it; test_ignition_never_imports_recipes_or_hyperflare_recipes (line 39) passes by construction. Core still never imports hyperflare_recipes (AGENTS.md:389-393).

Charter/AGENTS hooks used: AGENTS.md:379-384 (official recipes live in local-inference-lab/hyperflare-recipes; external recipe repos can pass their own Recipe tuples directly to ignition.cli.main); AGENTS.md:389-393 (core must never import hyperflare_recipes, reusable model execution mechanisms belong in hyperflare_recipes/components/); design-review.md principle 12/13 (validate real path, report evidence honestly). PR description has the required four parts (why / what changed / benefit / evidence) and honestly discloses the rebase caveat ("original unit-test run predated rebasing onto #509"); Discord line present.

#3 [high] Should fix: fix keyed to one package name, external recipe repos unsupported

SEVERITY: should fix (not blocking: no in-repo regression, and the reported failure is resolved for the official package).

File/line: ignition/preparation/forward_metadata.py:42.

What is wrong: the fix enumerates the single literal 'hyperflare_recipes.' prefix. The repository documents arbitrary external recipe repositories as a supported configuration:

Why it matters: for any external recipe package with a different module name, the exact defect in the PR's "Why" (PicklingError: Can't pickle CompiledKernel in aot_forward guard serialization) still reproduces. The bug class is narrowed to one package, not fixed. Review principle (design-review.md 15 / AGENTS.md "solve the right problem in the right place") favors a mechanism that does not require editing core Ignition per recipe repo.

Suggested fix (choose one): (a) Register coverage at the boundary: let the recipe/CLI pass the set of external package prefixes or source_roots labels into the guard pickler (the same place ignition.cli.main(..., source_roots=...) already carries them, source_identity._EXTRA_ROOTS pattern at source_identity.py:12-25), and match on that instead of a hardcoded tuple; or (b) Follow the repo's own convention for externally-owned types — explicit registration, as rebuild_manifest.py:41-71 does with declare_container_fields / weight_container / declare_module_buffers — rather than a module-name prefix.

Also note the tuple is duplicated knowledge vs. rebuild_manifest.py:365; a shared constant/predicate would keep the two in step (see the sibling-allowlist nit).