Architecture report · NVIDIA/hyperflare-inference #574

Raw Markdown for agents: https://autobot.eidonix.com/p/f549fcb2-d4a1-447f-846a-d0aa888a6ca6.md

Architecture & scope review — PR #574 "Strip unguarded attributes from hyperflare_recipes objects in AOT guard serialization"

2 files, +54/−1, head 16ffc6f, base main. Reviewed against the repository's own rules (AGENTS.md:72-113, :374-396, :497-518; docs/design-review.md:116-123, :180-190, :243-251; docs/cli-design.md:19-20; docs/preparation-development.md:372-388; docs/runtime-core-design.md:422-433) and against the code paths the one-line change reaches (ignition/preparation/aot.py:98-166, forward_metadata.py:33-45,172-279, rebuild_manifest.py:352-371, ignition/cli/__init__.py:367-373, ignition/preparation/source_identity.py:12-49).

Key findings

Verdict: blocking (evidence), should fix (keying). The change is in the right repository and the right layer — it adds no flag, no Protobuf/wire field, and no Helios code — so scope is acceptable. Two things stand between it and merge:

  1. Blocking B1 — the runnable CPU checks were never executed on the rebased head, and repository CI cannot run them either.
  2. Should fix S1 — the predicate it widens still answers "is this a prepared object?" by package name, so the defect stays reachable for every recipe repository that is not literally hyperflare_recipes, even though this repository already has a declared-root mechanism.

Plus four nits (a second stale allowlist, a test-hygiene issue, an undocumented new contract over recipe classes, and unreproducible evidence).

Scope: right repository, right layer (no finding)

The defect is in core Ignition. _GuardPickler (ignition/preparation/aot.py:102-166) and _ForwardPickler (ignition/preparation/forward_metadata.py:172-279) decide which prepared non-nn.Module objects are reconstructed as object.__new__ + _set_state with _Missing for unguarded values; docs/preparation-development.md:372-388 assigns that work to Python preparation. Recipes own composition, not the guard serializer, and AGENTS.md:389-393 keeps hyperflare_recipes out of core ignition ("Core ignition must never import hyperflare_recipes"). So the fix belongs here rather than in the external package, and the string literal is not a boundary violation.

No core-format or runtime compatibility surface is touched: the guard payload is preparation-time metadata, not a wire field (docs/design-review.md:116-123). The PR description follows the four required parts of AGENTS.md:72-113 and carries the Discord line required by AGENTS.md:142-153.

Blocking B1. The post-rebase CPU checks were never run, and CI cannot run them

File: tests/preparation/test_guard_code.py:277-302

test_guard_pickler_strips_unguarded_attributes_from_recipe_objects is new and has never been executed on head 16ffc6f. The description says the unit-test verification "ran prior to rebasing onto #509's extraction of _uses_custom_object_state (167f22c8); please run CI on test_guard_code.py and test_core_boundary.py". There is no CI to run: .github/workflows/ contains only native-serving.yml (cargo build/test; its sole Python step is pip install huggingface-hub), helios-lifecycle.yml (TLA+/Kani) and release.yml, and pytest appears nowhere under .github/. The PR shows no checks on the head commit.

Why it matters (rules): docs/design-review.md:180-190 lists pytest on tests/preparation as layer 1 of the mandatory testing hierarchy, and docs/design-review.md:247-251 is explicit: "Disclosure does not excuse skipping runnable CPU checks. All three layers run without a GPU or model checkpoint. Leaving an applicable crate test … unrun blocks commit and PR acceptance; noting it as a limitation does not make the omission acceptable." The suite is runnable without a GPU — #509 ran tests/preparation/test_guard_code.py with CUDA_VISIBLE_DEVICES="" (327 passed, 2 skipped) on this same file.

Fix: run pytest tests/preparation/test_guard_code.py tests/preparation/test_core_boundary.py on 16ffc6f and paste the result into the description. Nothing else is required for this item.

Should fix S1. Keying on a third package literal leaves the defect reachable for every other recipe repository

File: ignition/preparation/forward_metadata.py:39-45 (changed line 42)

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

What is wrong: this fixes one package name, not the class of failure the PR describes. AGENTS.md:379-384 states that "external recipe repositories can pass their own Recipe tuples directly to ignition.cli.main(...)", and docs/model-preparation.md:328 (not opened) says such repositories "do not need to merge into either repository". Any such package that is not literally hyperflare_recipes.* and holds an unpicklable compiled handle reproduces exactly the PicklingError this PR removes; the next recipe repository means a fourth literal. docs/cli-design.md:19-20 puts per-repository knowledge in external packages, "never in core ignition" — the coupling here is a bare string, so tests/preparation/test_core_boundary.py (which collects only ast.Import/ImportFrom names) cannot see it and passes.

A general mechanism already exists in this repository, which is why the literal reads as a stopgap rather than a design: the CLI binds declared source roots per invocation — ignition/cli/__init__.py:367-373 (def main(argv=None, *, recipes=(), prog="ignition", source_roots=()), then with active_recipes(recipes), bind_source_roots(source_roots)), backed by ignition/preparation/source_identity.py:12-25 (_EXTRA_ROOTS contextvar, source_roots(roots) normalizing (label, path) pairs) and merged at :43. The label is the external package name, so _uses_custom_object_state could test the value's top-level module against those declared labels (keeping the ignition./b12x. core prefixes) and would need no edit per new repository. The PR description itself floats this as the alternative in its rebuild_manifest.py:365 caveat.

Honest limitation of the alternative, for the record: the other obvious option — deciding by membership in _GuardPickler.guard_tree_values (aot.py:127,148,158) — is not free, because _GuardPickler also serializes functions, modules and bound methods and must keep pickling those by reference, so extra type exclusions would be needed. The declared-root route is the cheaper general fix.

Fix: either take the declared-root route, or keep the literal and state in the description that it is an explicit stopgap with the follow-up recorded somewhere sanctioned (AGENTS.md:512-518, docs/TODO.txt).

Nits

N1. The same "prepared object" question is now answered twice, differently. ignition/preparation/rebuild_manifest.py:365 still tests type(value).__module__.startswith(('b12x.', 'ignition.')). That walk feeds BundleIndex.rebuild_weights, and a hyperflare_recipes.* container that is neither an nn.Module (:358) nor a dataclass (:362-364) has its weight tensors skipped, landing in neither tensors nor unavailable. AGENTS.md:497-500 asks that a deficiency seen in one model be traced through equivalent paths. This is a follow-up, not a defect introduced by this PR (and it is outside a guard-serialization change) — but it should be recorded in docs/TODO.txt rather than only in the PR body.

N2. Two literals for one prefix and one unrestored class attribute. tests/preparation/test_guard_code.py:252-302: _RecipeKernelOwner.__module__ = "hyperflare_recipes.components.synthetic" at :258, then :281-285 creates the module hyperflare_recipes.components._synthetic_guard_test, assigns _RecipeKernelOwner.__module__ = module_name in place, and never restores it. The monkeypatch.setitem(sys.modules, ...) at :285 is load-bearing (the class is pickled by reference through _guard_object, (type(obj),) at aot.py:165, so unpickling must find it) — but the in-place attribute rewrite is not: using one name for the class literal and the synthetic module would let :283 go, or use monkeypatch.setattr(..., raising=False). The neighbouring test at :204-218 is the pattern to follow. The test is not vacuous: without the source change the object falls through to super() (aot.py:166) and _UnpicklableHandle.__reduce__ raises. What it does not pin is which package is in the tuple; a contrasting case with __module__ outside the allowlist would.

N3. A new contract on classes this repository does not own, documented nowhere. The same widened line reaches two serialization paths. _GuardPickler (aot.py:155-165) rebuilds any hyperflare_recipes.* instance with _guard_object (object.__new__, :98-99) plus _set_state, bypassing any __getstate__/__setstate__/__reduce__ the class defines, and turns unguarded attributes into _Missing('unguarded attribute') — state that previously round-tripped by value is gone after restore. _ForwardPickler (forward_metadata.py:277-278) takes the same path for such objects whose type has __getattr__, across the compiler-worker IPC boundary. That widening is only half-effective: an object without __getattr__ still pickles by default and still fails — fine for this PR's guard scope, but worth stating. Recipe authors must now keep serializable state in __dict__; one sentence in docs/preparation-development.md:372-388 (which already says what guards retain) or in the test docstring makes the contract discoverable.

N4. Evidence cannot be reproduced as written. "Verified … end-to-end 4-Spark TP4 Inkling 2 Small exports" names no command, core revision or configuration; AGENTS.md:103-112 requires reproduction inputs directly or by precise reference. Separately, the hasattr(value, '__dict__') guard at forward_metadata.py:41 leaves __slots__-declaring recipe classes on the default pickling path, so the same crash is still reachable for them — another argument for S1 rather than a separate defect.

Verified and deliberately not reported

Open questions / not verifiable from this repository