Correctness report · NVIDIA/hyperflare-inference #574

Raw Markdown for agents: https://autobot.eidonix.com/p/682534bf-d7c9-4cdd-9ac0-efc8a2c410d0.md

Review of PR #574 — Strip unguarded attributes from hyperflare_recipes objects in AOT guard serialization

Correctness lens. Head 16ffc6f, base main, 2 files, +54/−1 (ignition/preparation/forward_metadata.py, tests/preparation/test_guard_code.py). No reviews, no CI checks on the head commit. Author fordbmorris (Discord woooflet).

Key findings

What the change does (verified in context)

_uses_custom_object_state (ignition/preparation/forward_metadata.py:39-45) returns true only when the value has __dict__, its class __module__ starts with an allowed prefix, it is not a class, and it is not in _NON_OBJECT_NEW_TYPES (lines 33-36). The diff changes one prefix tuple on line 42:

and type(value).__module__.startswith(('ignition.', 'b12x.', 'hyperflare_recipes.'))

There are exactly two consumers of the predicate (grep over the tree):

  1. _GuardPickler.reducer_override — ignition/preparation/aot.py:155-166:
    from .forward_metadata import _uses_custom_object_state
    if _uses_custom_object_state(obj):
        state = {key: value if id(value) in self.guard_tree_values
                 else _Missing('unguarded attribute')
                 for key, value in vars(obj).items()}
        ...
        return _guard_object, (type(obj),), state
    return super().reducer_override(obj)
    
    with _guard_object(cls) = object.__new__(cls) at aot.py:98-99. Guarded values (those still reachable from the guard tree) are kept; every other attribute becomes _Missing, which is what removes the unpicklable Triton handle.
  2. _ForwardPickler.reducer_override — forward_metadata.py:277-278, additionally gated on hasattr(type(value), '__getattr__'). A plain prepared recipe object has no instance-level __getattr__ on its type, so for such objects the widened prefix changes nothing here. The PR description's claim that recipe objects "serialize and deserialize AOT guard states cleanly" holds for the guard-state path only; the forward-metadata path is not exercised by the new test.

Findings

Should fix — the fix is keyed to one package name, not to the supported configuration

ignition/preparation/forward_metadata.py:42

The allowlist enumerates the single literal prefix 'hyperflare_recipes.'. The repository documents arbitrary external recipe repositories as supported, not just the official one:

Why it matters: for an external recipe package whose module name is not hyperflare_recipes, the precise defect in the PR's own "Why" still reproduces — PicklingError: Can't pickle <class 'triton.compiler.compiler.CompiledKernel'> during aot_forward guard serialization whenever a prepared non-nn.Module object retains a compiled handle. The bug class is narrowed to one package, not closed, and each new recipe repo would need a core-Ignition edit — against AGENTS.md's instruction to keep core small and model-agnostic (charter line 12; AGENTS.md:389-393).

Fix (either): (a) drive the predicate from the roots the CLI already receives — e.g. bind the external package prefixes/labels alongside source_roots (source_identity.py:12-25) and match against that set in _uses_custom_object_state; or (b) follow the repo's own convention for externally owned types, explicit registration as done for container/buffer declarations in rebuild_manifest.py:41-71 (declare_container_fields, weight_container, declare_module_buffers).

Should fix (conditional) — the widening imports an ignition-only pickling contract into externally owned classes

ignition/preparation/aot.py:157-165, with _guard_object at aot.py:98-99

For every matched object the guard pickler now emits (_guard_object, (type(obj),), state) where state is a vars(obj)-shaped dict, and _guard_object is object.__new__(cls). Consequences for hyperflare_recipes.* classes, none of which exist in this repository to check:

That contract (object.__new__ + vars()) holds for ignition./b12x. classes in this repository because they are written against it; it is not established for classes owned by another repo. Nothing in this repository demonstrates a current break — only a recipe-side class using __slots__, or pairing a custom __getstate__/__setstate__, would reveal it. Fix: document the required state contract for recipe classes in the docstring of _GuardPickler (aot.py:102-103) and, ideally, also match slot state (__slots__/__dict__ union) so the strip is complete; or coordinate a matching contract note with the hyperflare-recipes repo. A recipe-side unit test using a __slots__ + __setstate__ class would settle it.

Nit — the sibling allowlist was not widened, so the two lists disagree

ignition/preparation/rebuild_manifest.py:365

elif type(value).__module__.startswith(('b12x.', 'ignition.')) and hasattr(value, '__dict__'):

This is the second, independent copy of the same prefix knowledge (grep shows only these two sites: forward_metadata.py:42 and rebuild_manifest.py:365). It gates the weight-view walk that feeds rebuild_weights_metadata (rebuild_manifest.py:441-459), consumed from runtime_core.py:367-369. After this PR a hyperflare_recipes.* owner is guard-serializable but still invisible to that walk, so tensors owned by such objects are silently omitted from — or reported unavailable in — the rebuild catalog. Fix: extract the tuple into one shared constant/predicate and use it in both places, or confirm the documented WeightDeclaration path is the only supported one for recipe-owned weights and say so.

Nits — the new test (tests/preparation/test_guard_code.py:252-302)

  1. Line 283 mutates process-global class state. _RecipeKernelOwner.__module__ = module_name is a direct assignment; the monkeypatch.setitem(sys.modules, ...) on line 285 restores only the module entry, not __module__. After the test the class keeps a hyperflare_recipes.components._synthetic_guard_test module string whose module object is gone, which can confuse later pickling/repr in the same session. Use monkeypatch.setattr(_RecipeKernelOwner, '__module__', module_name). (The class attribute at line 258, __module__ = "hyperflare_recipes.components.synthetic", is then immediately redundant with line 283 — the test never exercises that one.)
  2. The fixture does not reproduce the reported error. _UnpicklableHandle.__reduce__ raises TypeError (line 253-254), whereas the bug reported in the PR is PicklingError from triton.compiler.compiler.CompiledKernel. Raising pickle.PicklingError would make the regression test fail with the same signature as the field report.
  3. Coverage is guard-states only. Only the _GuardPickler path is exercised; _ForwardPickler (forward_metadata.py:277-278) is the second consumer and is additionally gated on hasattr(type(value), '__getattr__'), so the widened prefix cannot change its behaviour for a plain recipe object. A forward_metadata.dumps/loads round-trip on a recipe-like object would either close that gap or confirm it is a no-op and let the description say so.
  4. Bool-identity assertions. assert loaded.guard_check(forward) is True / is False (lines 298-302) assert identity, while the rest of the file asserts truthiness (lines 47-51, 248-249). guard_check's exact return type is not visible in this repo (call sites: aot.py:1160, tests/preparation/test_guard_code.py:50-51,248-249), so is True is a stricter claim than the surrounding tests make.

Verified positives (no action needed)

Open questions / not verifiable from this repository