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:
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 itsid()is inguard_tree_values; returns the 3-tuple(_guard_object, (type(obj),), state).DetectedDeviceis special-cased torestore_prepared_device(aot.py:163-164).ignition/preparation/forward_metadata.py:277-278—_ForwardPickler.reducer_override, gated additionally onhasattr(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:
pickle.Pickler.reducer_overrideis consulted before__reduce_ex__, so a matched recipe class's own__getstate__/__reduce__is never used. Any__getstate__workaround a recipe author had already written (the kind this PR says it obviates) is silently replaced byvars()stripping.- Because there is no state_setter, pickle's default BUILD runs:
load_buildcallsinst.__setstate__(state)when the class defines one, handing it a plainvars()dict containing_Missing('unguarded attribute')placeholders — a shape the class's own__getstate__never produced. That is a load-timeKeyError/TypeErrorinstead of a clean strip. - The same file's tensor branch deliberately avoids exactly this:
aot.py:148-151returns the 6-tuple with_set_state(forward_metadata.py:164-165,value.__dict__.update(state))._ForwardPicklerdoes the same atforward_metadata.py:213and:278. The object branch ataot.py:165is the only one in either pickler without a setter. - The predicate requires
hasattr(value, '__dict__')(forward_metadata.py:41), so a__slots__-only recipe class holding aCompiledKernelis never matched and its handle still raises. A mixed dict+slots class silently loses slot state on reload. object.__new__(aot.py:98-99) raisesTypeError: object.__new__(X) is not safefor subclasses of C types whosetp_newis not object's._NON_OBJECT_NEW_TYPES(forward_metadata.py:33-36) coversTensor/Module/Enum/int/float/str/bytes/dict/list/tuple/set/frozensetbut not e.g.bytearrayorExceptionsubclasses, so a matched external class of those shapes turns the strip into a hardTypeErrorat serialization.
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
ignition/preparation/rebuild_manifest.py:365still readstype(value).__module__.startswith(('b12x.', 'ignition.')). After this PR ahyperflare_recipes.*owner is guard-serializable but the weight-view walk (:338-374→rebuild_weights_metadata:441-459→runtime_core.py:130,367-369→ native bundle viaheliopause/src/export/binding.rs:467-522(not opened) /validate_rebuild_weights) still stops at it, so its tensors are silently omitted fromBundleIndex.rebuild_weights(docs/runtime-core-design.md:423 (not opened),454). The omission is silent becausevalidate_weights(rebuild_manifest.py:462-491) only checks entries that are present. Mitigated by the declared alternative:WeightDeclaration(weight_payload_request:418-422,_declared_metadata:425-438) anddeclare_container_fields/weight_container/declare_module_buffers(:41-71). The PR description already discloses this site. Fix: share the prefix tuple/predicate between the two sites, or state thatWeightDeclarationis the only supported path for recipe-owned weights.tests/preparation/test_guard_code.py:283assigns_RecipeKernelOwner.__module__process-globally while onlysys.modulesis restored (:285), leaving an imported class pointing at a module that no longer exists after the test; usemonkeypatch.setattr(_RecipeKernelOwner, '__module__', module_name). The class-body__module__at:258is dead code, overwritten on:283. The neighbouring test (:204-219) already uses monkeypatch correctly.tests/preparation/test_guard_code.py:252-254raisesTypeErrorfrom_UnpicklableHandle.__reduce__, whereas the field report isPicklingErrorfromtriton.compiler.compiler.CompiledKernel; raisingpickle.PicklingErrorwould make the regression signature match.tests/preparation/test_guard_code.py:298-302assertsguard_check(...) is True/False(bool identity), while the rest of the file asserts truthiness (:50-51,:248-249).guard_checkis torch's and cannot be typed from this repo; if it returns a non-bool truthy value the assertion is brittle.- No
__slots__coverage: the predicate'shasattr(value, '__dict__')(forward_metadata.py:41) is the reason slots-only recipe objects are not fixed, and no test exercises that shape.
Verified positives (checked, not assumed)
- No format change for existing owners.
ignition./b12x.objects satisfy the prefix before and after, so their reductions are byte-identical; onlyhyperflare_recipes.*objects change path. No persisted guard or core-data-format change, hence no compatibility-with-existing-persisted-state issue. - The new test is discriminating. Without the prefix,
_RecipeKernelOwnerfalls through toGuardsStatePickler.reducer_override, whose default reduction picklesvars(obj)including_UnpicklableHandle(test_guard_code.py:252-262), so the test fails onmain. It also goes through a realtorch.compile(..., aot_compile)+serialize/deserialize(:288-296), which is the meaningful-validation shapeAGENTS.md:194-199asks for. - Core boundary intact.
tests/preparation/test_core_boundary.py:28-47walks AST imports only, so a string literal cannot violate it;AGENTS.md:385-393("Coreignitionmust never importhyperflare_recipes") still holds, and the change adds no import. - No stale-guard hazard. The guard-code cache keys on-disk binaries by
sha256ofpickle.dumps((tuple(code_parts), closure_args))(aot.py:206-210) with an atomicos.replace(:213-220), so changed pickled bytes for recipe objects are a cache miss and a new file, never a stale guard. - Exactly two consumers, confirmed by grep (
aot.py:157,forward_metadata.py:277); the prefix tuple appears twice in the tree (forward_metadata.py:42,rebuild_manifest.py:365). - PR description has the four required parts (why / what changed / benefit & evidence / caveats), honestly discloses that the pytest run predated the rebase onto #509 (
167f22c8), and discloses therebuild_manifest.py:365site it deliberately left out.
Open questions / not verifiable here
- No
hyperflare_recipessource in this repo (test_core_boundary.py:40asserts the directory is absent), so I could not determine whether any real recipe class uses__slots__, defines__getstate__/__setstate__, or relies on object identity across a guard round trip. That is exactly what decides whether should-fix items 2 and 3 are already live or only latent. A single recipe-side test class with__slots__and a__setstate__, run through_guard_serialization()and a serialize/deserialize cycle, would settle both. - Validation gap (not a code defect). Grepping
.github/forpytestreturns no matches; the only workflows arehelios-lifecycle.yml(not opened),native-serving.yml(cargo only) andrelease.yml(not opened), and head16ffc6fhas no checks.AGENTS.md:294-307tells contributors to run the relevant pytest themselves, anddocs/design-review.md:247-251says disclosure does not excuse skipping runnable CPU checks. Sopytest tests/preparation/test_guard_code.py tests/preparation/test_core_boundary.pyshould be recorded as run on16ffc6f(the author's caveat says the original run predated the rebase). - No blocking issue was found in the change itself: the reported
PicklingErroris resolved forhyperflare_recipes.*objects that have a__dict__, the reduction of pre-existing owners is unchanged, and nothing in the repository demonstrates a current regression. Items 2 and 3 are contract risks created by extending an ignition-internal convention to another repository's classes, which is why they are "should fix" and not "blocking".