Skip to content

Strip unguarded attributes from hyperflare_recipes objects in AOT guard serialization - #574

Closed
fordbmorris wants to merge 1 commit into
NVIDIA:mainfrom
fordbmorris:pr/aot-guard-pickler-hyperflare-recipes
Closed

fordbmorris wants to merge 1 commit into
NVIDIA:mainfrom
fordbmorris:pr/aot-guard-pickler-hyperflare-recipes

Conversation

@fordbmorris

@fordbmorris fordbmorris commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

After model recipes moved from ignition. into the external hyperflare_recipes package, _uses_custom_object_state (ignition/preparation/forward_metadata.py) still only matched ('ignition.', 'b12x.'). Any non-nn.Module object under hyperflare_recipes.* holding an unpicklable compiled handle (e.g., Triton CompiledKernel) crashes aot_forward guard serialization with PicklingError.

What Changed

  • ignition/preparation/forward_metadata.py: add 'hyperflare_recipes.' to the __module__ prefix tuple in _uses_custom_object_state (string check only; core ignition never imports hyperflare_recipes).
  • tests/preparation/test_guard_code.py: add test_guard_pickler_strips_unguarded_attributes_from_recipe_objects using a synthetic hyperflare_recipes.* module.

Benefit & Evidence

  • Allows hyperflare_recipes.* helper objects to serialize AOT guard states cleanly without per-class __getstate__ workarounds.
  • Verified with pytest tests/preparation/test_guard_code.py tests/preparation/test_core_boundary.py on ARM64 GB10 and end-to-end 4-Spark TP4 Inkling 2 Small exports.

Caveats: Original unit tests 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. Note: ignition/preparation/rebuild_manifest.py:365 has a similar ('b12x.', 'ignition.') check intentionally left out of this 1-line PR unless maintainers want it included or replaced by a declared-root mechanism.

Discord: woooflet

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 574.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@fordbmorris
fordbmorris force-pushed the pr/aot-guard-pickler-hyperflare-recipes branch from 628f361 to 16ffc6f Compare November 28, 2026 19:41
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The one-line change in forward_metadata.py is clean and scoped, but the runnable CPU tests were never executed on the rebased head (16ffc6f) and repository CI does not run pytest on tests/preparation/. Record those test results on 16ffc6f and the PR is ready to merge.

  • Blockers: 1
  • Should fix: 0
  • Subtractive suggestions: 0
  • Nits: 1

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The one-line fix in ignition/preparation/forward_metadata.py:42 is minimal and correct, but the runnable CPU tests were not executed on the rebased head (16ffc6f) and repository CI does not run pytest. Run pytest tests/preparation/test_guard_code.py tests/preparation/test_core_boundary.py on 16ffc6f, record the results in the PR description, and remove the stale Caveats / "please run CI" note.

  • Blockers: 1
  • Should fix: 0
  • Subtractive suggestions: 0
  • Nits: 2

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@flare-autobot flare-autobot added area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working model:inkling-small Affected recipe or documented reproducer: inkling-small. Impact may be broader. priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness. and removed model:inkling-small Affected recipe or documented reproducer: inkling-small. Impact may be broader. labels Nov 29, 2026
…rd serialization

Add 'hyperflare_recipes.' alongside ('ignition.', 'b12x.') in
_uses_custom_object_state() in ignition/preparation/forward_metadata.py so
objects from the external recipe package that own unpicklable CUDA kernel
handles serialize cleanly during torch.compile AOT guard pickling.

Discord: woooflet

Design-Signed-Off-By: Antigravity (Gemini-4-Neon); design-review=2e5b
Signed-off-by: woooflet <ford@fordmorris.com>
@fordbmorris

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (571a4471, cleanly across merged #648), refreshed Design-Signed-Off-By: Antigravity (Gemini-4-Neon); design-review=2e5b and Signed-off-by: woooflet <ford@fordmorris.com> (verified via .githooks/commit-msg), and verified python3 -m py_compile clean on both modified files.

Discord: woooflet

@fordbmorris
fordbmorris force-pushed the pr/aot-guard-pickler-hyperflare-recipes branch from 16ffc6f to acbab08 Compare December 2, 2026 04:47
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The 1-line fix in ignition/preparation/forward_metadata.py:42 is minimal, sound across spawned CompilePool workers, and restores pre-split guard-pickling parity for hyperflare_recipes classes without importing the package or breaking tests/preparation/test_core_boundary.py. The single blocker is unchanged on head acbab08: only py_compile (syntax-only) is recorded, with no pytest run and no approved CI run — confirm green and this is ready to merge.

  • Blockers: 1 · Should fix: 0 · Subtract/Simplify: 1 · Nits: 2
Walkthrough
  • ignition/preparation/forward_metadata.py:39-45: Extends _uses_custom_object_state's prefix tuple to ('ignition.', 'b12x.', 'hyperflare_recipes.') — string check only, no import of hyperflare_recipes. Governs _GuardPickler.reducer_override (ignition/preparation/aot.py:157-166) and _ForwardPickler.reducer_override (ignition/preparation/forward_metadata.py:282-284).
  • tests/preparation/test_guard_code.py:252-302: Adds synthetic _UnpicklableHandle / _RecipeKernelOwner / _RecipeForward plus test_guard_pickler_strips_unguarded_attributes_from_recipe_objects, registering a synthetic hyperflare_recipes.components.* module via monkeypatch.setitem and verifying end-to-end torch.compile(...).aot_compile(...) serialization, deserialization, output equality, and guard_check invalidation (True → False → True).
Merge Risk: Low · up to acbab08
  • Preparation-only, no serving hot-path impact: _uses_custom_object_state (forward_metadata.py:39-45) is a pure string-prefix predicate used only in AOT guard serialization (aot.py:157) and compiler-worker metadata pickling (forward_metadata.py:282); Helios serving, CUDA graphs, and core wire formats are untouched.
  • Restores pre-split parity, no new concurrency hazards: Before the hyperflare_recipes extraction (da037284, 4d957175) these classes lived under ignition.* and already matched the predicate; a static prefix tuple behaves identically in-process and in SubprocKind.SPAWN CompilePool workers (compile_pool.py:154-156).
  • Pre-existing twin allowlist explicitly deferred: rebuild_manifest.py:365 still matches only ('b12x.', 'ignition.') for legacy weight_views walks (bypassed by WeightDeclaration at :445-446) — pre-existing on main, disclosed by the author for maintainer preference.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings
  • ✅ Security / malicious screen: Pure string-prefix addition plus a CPU unit test; no prompt injection, unsafe execution, or boundary escape.
  • ✅ Charter & value fit: Minimal 1-line root-cause fix; literal string check complies with AGENTS.md:395-396 and tests/preparation/test_core_boundary.py:39-58; AI-tool trailer (Antigravity (Gemini-4-Neon)) is in the permitted set (AGENTS.md:474-486, docs/design-review.md:124-134).
  • ✅ Related / duplicate / conflict check: Rebased cleanly onto 571a4471 across #509 (b0d35934) and #648 (555db719); #608 added .github/workflows/python-cpu.yml (not opened) and noted #574 as a separate merge action.
  • ⚠️ Tests & verification evidence: Only python3 -m py_compile has been run on acbab08; no pytest output or approved CI run is recorded on that head.
Blockers (1)
  1. No pytest verification recorded on head acbab08 (tests/preparation/test_guard_code.py:277-302, tests/preparation/test_core_boundary.py:39-58, docs/design-review.md:106-115).
    • Verified state: The description's Caveats note the original pytest run predated the rebase onto #509, and the 2026-12-02 update on acbab08 ran only python3 -m py_compile, which checks syntax without importing forward_metadata.py or executing the new test. Merged #608 added .github/workflows/python-cpu.yml:30-33 (not opened) (CUDA_VISIBLE_DEVICES="" .venv/bin/python -m pytest tests/ -q), but first-time-contributor workflows require maintainer approval and no run is recorded on acbab08.
    • Concrete fix: Either run CUDA_VISIBLE_DEVICES="" pytest tests/preparation/test_guard_code.py tests/preparation/test_core_boundary.py on acbab08 and post the passing output in the description (removing the stale Caveats block), or have a maintainer approve .github/workflows/python-cpu.yml (not opened) on acbab08 and confirm green before merging.
Subtract / Simplify (1)
  1. Remove the redundant __module__ reassignment that leaks class state (tests/preparation/test_guard_code.py:258,281-285). Line 258 sets __module__ = "hyperflare_recipes.components.synthetic", then line 283 overwrites _RecipeKernelOwner.__module__ = "hyperflare_recipes.components._synthetic_guard_test" outside monkeypatch, leaving the class pointing at a module monkeypatch removes on teardown. Follow the existing _IgnitionInt pattern (tests/preparation/test_guard_code.py:139-140,212-214): set module_name = _RecipeKernelOwner.__module__ and delete line 283 (_RecipeKernelOwner.__module__ = module_name).
Nits (2)
  1. Incorrect commit SHA in PR description Caveats: 167f22c8 is #570 (ci: upgrade setup-java to v5 and Java 21 in helios-lifecycle); #509's extraction of _uses_custom_object_state landed in b0d35934. Update or remove when clearing the stale Caveats block.
  2. PR description completeness: Optionally mention that _uses_custom_object_state is also consumed by _ForwardPickler.reducer_override (ignition/preparation/forward_metadata.py:282), restoring pre-split parity for hyperflare_recipes.* objects with __getattr__ as well as AOT guard serialization.
Dropped on verification (8)
  • F1 ("_GuardPickler bypasses __slots__/__setstate__/__reduce__"): Inaccurate. _uses_custom_object_state checks hasattr(value, '__dict__') (forward_metadata.py:41), excluding pure __slots__ classes; aot.py:165 returns a 3-tuple without _set_state, so pickle's BUILD still invokes __setstate__; and these classes matched under ignition.* before da037284/4d957175.
  • F2 ("Mismatched gates across the two consumers"): The difference is intentional — _GuardPickler (aot.py:157) strips unguarded attributes from all prepared objects, while _ForwardPickler (forward_metadata.py:282) keeps full vars() and needs only _object+_set_state to bypass custom __getattr__ during pickle probing.
  • F4 & S1 (rebuild_manifest.py:365 silently drops weight views): Pre-existing on main, bypassed by WeightDeclaration (rebuild_manifest.py:445-446), and disclosed/deferred in the description; hoisting a shared constant would expand scope on Round 3.
  • F5 & S2 ("Use a ContextVar instead of the literal prefix"): CompilePool spawns fresh workers via SubprocKind.SPAWN (compile_pool.py:154-156) where parent ContextVar bindings are not inherited, so a naive ContextVar would break worker-side _GuardPickler unless threaded through CompilePool and cross-rank lending RPCs; the literal complies with AGENTS.md:395-396 and tests/preparation/test_core_boundary.py:39-47.
  • S3 ("Replace the end-to-end aot_compile test with _roundtrip_guard"): The real torch.compile(...).aot_compile(...) + _guard_serialization() path exercises Dynamo's actual guard_tree_values and live guard_check invalidation, matching tests/preparation/test_guard_code.py:232-249.
  • "Repository CI does not run pytest": Stale — merged #608 added .github/workflows/python-cpu.yml (not opened, :30-33); blocker updated accordingly.
  • F6 ("Add _ForwardPickler, negative unlisted-package, and rebuild_weights tests"): Round 3 scope expansion beyond prior review rounds.
  • A6 (".githooks/commit-msg checks only Design-Signed-Off-By"): True (.githooks/commit-msg:50-63) but low signal; does not affect the diff or mergeability.

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

@lukealonso

Copy link
Copy Markdown
Collaborator

Thank you @fordbmorris for identifying the missing external-recipe handling in AOT guard serialization. Your fix was generalized across all bound source_roots (including CompilePool worker propagation and rebuild_manifest.weight_views) and merged into main via #728, so closing this PR as superseded.

@lukealonso lukealonso closed this Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working priority:P2 Normal bug priority: workflow failure or diagnosis with narrower impact or an available workaround. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants