Skip to content

heliopause,ignition: enforce export reachability, owned warmup pools, native ForwardCache hashing, and Triton AOT guard contracts - #728

Merged
lukealonso merged 3 commits into
mainfrom
enforce-b12x-ignition-export-memory
Dec 4, 2026
Merged

lukealonso merged 3 commits into
mainfrom
enforce-b12x-ignition-export-memory

Conversation

@lukealonso

Copy link
Copy Markdown
Collaborator

Why this change is needed

Four coupled export-memory, cache-identity, and AOT serialization gaps affect Ignition preparation and Heliopause export:

  1. Opaque export reachability failures: When Heliopause detects an exported graph node argument pointing outside every declared allocation, Reachability reports only the raw device address, requiring manual back-tracing to identify whether the pointer came from transient warmup storage, an unowned CUDA pool, or a missing buffer declaration (addressed by Report unresolved kernel argument address candidates during export #332).
  2. Unowned cuBLAS warmup pool and unseeded auxiliary overlap streams: ignition/preparation/capture.py seeded warmup-stream cuBLAS workspaces into an unowned module-level torch.cuda.MemPool() outside CoreStorage mappings (addressed by fix(ignition): seed warmup workspaces inside export storage pool #606, which had merge conflicts against main), and did not seed auxiliary overlap streams before warmups so their cuBLAS workspaces could land in transient warmup storage.
  3. Python-only ForwardCache hashing: ForwardCache.__init__ (ignition/preparation/aot.py) hashed only *.py files via rglob('*.py'), silently returning stale compiled forwards after edits to .cu, .cuh, .c, .h, .cpp, or .hpp sources across Ignition (kv_codec_gpu.cu), FlashInfer (data/include, data/csrc), and external recipe roots.
  4. External recipe guard pickling and non-static Triton serialization (failed to export inkling-2-mini on GB10 #724): forward_metadata._uses_custom_object_state and rebuild_manifest.weight_views hardcoded ('ignition.', 'b12x.'), omitting external recipe packages bound via source_roots(). Under Triton 3.8, when an unstripped external recipe object (such as Inkling2's PreparedResidualMix) or a non-static TritonCompileResult reaches pickle.dumps, export fails late with PicklingError: Can't pickle <class 'triton.compiler.compiler.KernelMetadata'>. Spawned CompilePool workers also did not inherit bound source_roots, and _GuardPickler did not fail fast if a guard directly referenced a triton.compiler.CompiledKernel.

Routing ForwardCache through flare_heliopause.export_source_identity, deriving prepared object module prefixes from bound source_roots (keeping core Ignition free of hardcoded recipe package names), owning warmup pools in CoreStorage, and enforcing static-only TritonCompileResult invariants before deepcopy/pickle.dumps resolves all four gaps at their source.

What changed

  • Heliopause export reachability diagnostics (integrates Report unresolved kernel argument address candidates during export #332 by @mark-yong):
    • Before: Reachability returned only raw unresolved addresses on export failure.
    • After: added Reachability::unresolved_report and node-context diagnostics in heliopause/src/export/{reachability.rs,capture.rs} plus documentation in docs/runtime-core-design.md and docs/TODO.txt. (Note: .github/workflows/python-cpu.yml already runs cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib since 1da22724.)
  • Owned warmup pool and auxiliary-stream cuBLAS seeding (integrates rebased fix(ignition): seed warmup workspaces inside export storage pool #606 by @avifenesh + auxiliary seeding):
    • Before: capture.py always seeded warmup workspaces in module-global _warmup_pools and left scratch-arena _auxiliary_stream unseeded before warmups.
    • After: added CoreStorage.warmup_pool() in ignition/preparation/core_storage.py, routed export-mode _seed_warmup_workspaces (mm and addmm) into warmup_storage.warmup_pool() while keeping the 2-argument non-export fallback, and added _seed_auxiliary_workspaces in ignition/preparation/capture.py seeding mm, addmm, and bmm inside warmup_storage.graph_pool. Updated docs/preparation-development.md and added CPU/CUDA tests in tests/preparation/{test_core_storage.py,test_capture_cublas_workspace_cuda.py,test_capture_stream_isolation.py}.
  • Native source hashing in ForwardCache:
    • Before: heliopause/src/export/source_identity.rs and heliopause/build.rs hashed .py/.rs/.c/.cu/.cuh/.h with directory-only exclusions, and ForwardCache.__init__ hashed only *.py.
    • After: extended heliopause/src/export/{source_identity.rs,binding.rs} and heliopause/build.rs to hash .cpp/.hpp and accept excluded_files; added forward_source_identity() in ignition/preparation/source_identity.py backed by flare_heliopause.export_source_identity; replaced ForwardCache.__init__'s Python-only loop in ignition/preparation/aot.py with forward_source_identity.
  • Generalized source_roots object handling and non-static Triton rejection (generalizes Strip unguarded attributes from hyperflare_recipes objects in AOT guard serialization #574 by @fordbmorris; fixes failed to export inkling-2-mini on GB10 #724):
    • Before: forward_metadata._uses_custom_object_state and rebuild_manifest.weight_views hardcoded ('ignition.', 'b12x.'); CompilePool workers ran with empty _EXTRA_ROOTS; inductor_tuning and aot._load_inductor did not prune/reject non-static TritonCompileResult before deepcopy/pickle.dumps; _GuardPickler attempted to pickle guarded CompiledKernel instances.
    • After: added prepared_module_roots() / is_prepared_object_module() in ignition/preparation/source_identity.py, wired forward_metadata.py and rebuild_manifest.py through it, propagated bound _EXTRA_ROOTS through CompilePool.submit_payload -> _compile_forward (ignition/preparation/compile_pool.py), added _prune_static_compile_results / _sanitize_static_bundle in ignition/preparation/inductor_tuning.py (invoked from _selected, _snapshot, freeze, and aot._load_inductor), and raised a clear TypeError in _GuardPickler.reducer_override on guarded triton.compiler.CompiledKernel.
    • Added tests in tests/preparation/{test_source_identity.py,test_forward_cache_sources.py,test_guard_code.py,test_compile_pool.py,test_inductor_prepared_winners.py}.

Claimed benefit and results

  • Expected:
    • Export reachability failures report exact graph, kernel, argument offset, and candidate details.
    • Export-mode warmup cuBLAS workspaces stay inside declared CoreStorage mappings (outside transient and graph pools), and auxiliary overlap streams bind persistent graph-pool workspaces across warmup, capture, and native replay.
    • Edits to .cu/.cuh/.c/.h/.cpp/.hpp files in Ignition, FlashInfer (data/include, data/csrc), and bound external recipe packages deterministically invalidate ForwardCache.
    • External recipe objects strip unguarded attributes identically across parent and spawned CompilePool workers without hardcoding recipe names in core Ignition, and non-static TritonCompileResult or guarded CompiledKernel objects are pruned or rejected with actionable TypeErrors before pickle.dumps.
  • Measured:
    • Verified on SM120 with real CoreStorage + RuntimeCore.write() that seeded warmup workspaces reside inside CoreStorage.mappings while leaving _capture._warmup_pools empty.
    • Verified on SM120 with real Triton 3.8.0 CompiledKernel instances (confirming pickle.dumps(compiled.metadata) raises PicklingError: KernelMetadata) that both worker-serialized and direct owning-rank aot_compile + _guard_serialization roundtrips pass guard_check(owner) with matching outputs.
    • Verified ForwardCache.root invalidates on edits to Ignition .cu, FlashInfer data/{csrc,include}, and hyperflare_jetson_recipes/csrc/*.{cu,cuh}.

Supporting evidence and limitations

Validated on Linux x86_64 with Python 3.12.12, PyTorch 2.14.1+cu132, Triton 3.8.0, a freshly built flare_heliopause extension (--features server,extension-module), and RTX PRO 6000 Blackwell Max-Q (SM120) GPUs:

  • Heliopause Rust tests: cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib -> 250 passed, 0 failed, 6 ignored (CUDA-device tests).
  • Core boundary & preparation CPU tests: tests/preparation/test_core_boundary.py, test_core_storage.py (18 passed, 1 Windows-only skipped), test_capture_stream_isolation.py (3 passed), test_source_identity.py, test_forward_cache_sources.py, test_guard_code.py (10 passed), test_compile_pool.py, test_inductor_prepared_winners.py (19 passed), and tests/cli/test_recipe_injection.py (4 passed) all passed.
  • Full CPU suite (tests/preparation/ tests/cli/): 1,431 passed, 75 skipped (CUDA/Windows-gated), 1 pre-existing unrelated failure: tests/preparation/test_runtime_triton.py::test_replaces_stock_architecture_probe_with_pointer_width_key fails standalone under Triton 3.8.0 because stock triton.runtime.build.platform_key() returns "x86_64,Linux,64bit" rather than "x86_64,Linux,64bit,ELF".
  • CUDA tests (FLARE_RUN_CUDA_TESTS=1, SM120 GPUs 2/3):
    • tests/preparation/test_capture_cublas_workspace_cuda.py: 2 passed in normal order (GPU 2) and 2 passed in reversed order (GPU 3).
    • tests/preparation/test_recorded_export_graph_cuda.py: 2 passed.
    • tests/preparation/test_inductor_tuning_cuda.py: 8 passed, 5 skipped (TP2/distributed-gated tests).
  • Limitations: Full-model GB10 (SM121) Inkling2 / GLM-5.3 exports, SM103/SM87 hardware runs, and TP2 distributed Inductor CUDA tests were not executed on this host.

Related PRs and issues

Discord: lukealonso

…bility

When core export encounters a graph node argument pointing outside every
declared allocation, Reachability previously reported only the raw device
address. Diagnosing whether an unresolved pointer came from transient
warmup storage, an unowned CUDA pool, or a missing buffer declaration
required manually tracing kernel arguments back to CUDA graph nodes.

What changed:
- Added `Reachability::unresolved_report` and supporting node-context
  reporting in `heliopause/src/export/reachability.rs`, with Rust unit
  tests covering unresolved pointer diagnostics and transitive closure.
- Wired `heliopause/src/export/capture.rs` to format export reachability
  failures through the structured report.
- Updated `docs/runtime-core-design.md` and `docs/TODO.txt` to document
  the export reachability diagnostic contract.

Claimed benefit and measured results:
Export-time dangling pointer failures immediately identify the offending
graph, kernel, argument offset, and unresolved address instead of failing
with an opaque address or deferring to replay-time illegal memory access.

Supporting evidence and limitations:
- Rust library tests: `cargo test --locked --release --manifest-path
  heliopause/Cargo.toml --lib` -> 250 passed, 0 failed, 6 ignored (CUDA
  device tests). Note that `.github/workflows/python-cpu.yml` lines 34-41
  already run this test command in CI.
- CUDA export verification (`FLARE_RUN_CUDA_TESTS=1`, SM120 GPU 2):
  `tests/preparation/test_recorded_export_graph_cuda.py` and
  `tests/preparation/test_capture_cublas_workspace_cuda.py` passed (4/4).
- Limitations: ignored CUDA-device unit tests inside `heliopause --lib`
  were not run directly via cargo.

Design-Signed-Off-By: Antigravity; design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
…uxiliary streams

`capture.py` previously seeded warmup-stream cuBLAS workspaces into an
unowned module-level `torch.cuda.MemPool()`, outside `CoreStorage`
mappings, and did not seed auxiliary overlap streams before warmups. If a
warmup-stream or auxiliary-stream cuBLAS workspace lands in transient
warmup storage or outside declared export mappings, graph capture and
native replay can reference unmapped or undeclared device addresses.

What changed:
- Added `CoreStorage.warmup_pool()` in `ignition/preparation/core_storage.py`
  to lazily create one persistent `torch.cuda.MemPool` backed by
  `CoreStorage`'s allocator and registered in `_preparation_pools`.
- Updated `_seed_warmup_workspaces(stream, device, pool=None)` and
  `capture_forwards` in `ignition/preparation/capture.py` to seed the
  warmup stream (`mm` and `addmm`) into `warmup_storage.warmup_pool()` when
  provided, keeping the 2-argument module-pool path for non-export callers.
- Added `_seed_auxiliary_workspaces(session, device, *, warmup_storage)` in
  `ignition/preparation/capture.py` to seed an auxiliary scratch-arena
  stream's `mm`, `addmm`, and `bmm` cuBLAS workspaces inside
  `warmup_storage.graph_pool` before warmups and capture.
- Updated `docs/preparation-development.md` and added CPU/CUDA tests in
  `tests/preparation/test_core_storage.py`,
  `tests/preparation/test_capture_cublas_workspace_cuda.py`, and
  `tests/preparation/test_capture_stream_isolation.py`.

Claimed benefit and measured results:
Export-mode cuBLAS warmup workspaces stay inside declared `CoreStorage`
mappings while remaining disjoint from transient and graph pools, and
auxiliary overlap streams bind persistent graph-pool workspaces across
warmup, capture, and native replay.

Supporting evidence and limitations:
- CPU tests: `tests/preparation/test_core_storage.py` (18 passed, 1
  Windows-only skipped) and `tests/preparation/test_capture_stream_isolation.py`
  (3 passed).
- CUDA tests (`FLARE_RUN_CUDA_TESTS=1`, RTX PRO 6000 Blackwell SM120):
  `tests/preparation/test_capture_cublas_workspace_cuda.py` passed in both
  forward (GPU 2) and reversed (GPU 3) test orders (2/2), verifying the
  seeded warmup workspace resides inside `CoreStorage.mappings`, leaves
  `_capture._warmup_pools` empty, and passes full `RuntimeCore.write()`
  export reachability.
- Limitations: multi-rank export with a live auxiliary overlap model graph
  was not benchmarked end-to-end here.

Design-Signed-Off-By: Antigravity; design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
…leable Triton state

Three preparation-cache and AOT serialization gaps caused stale cache hits
and late export failures: (1) `ForwardCache.__init__` hashed only `*.py`
files, silently reusing stale compiled forwards after edits to `.cu`,
`.cuh`, `.c`, `.h`, `.cpp`, `.hpp` files across Ignition, FlashInfer
(`data/include`, `data/csrc`), and external recipe roots; (2)
`forward_metadata._uses_custom_object_state` and
`rebuild_manifest.weight_views` hardcoded `('ignition.', 'b12x.')`, so
objects from external recipe packages bound via `source_roots()` did not
strip unguarded attributes during `_GuardPickler` serialization (causing
late `PicklingError` on Triton 3.8's local `KernelMetadata` namedtuple
when in-process fallback pickled a recipe owner holding a live
`CompiledKernel`), and `CompilePool` workers did not inherit bound
`source_roots`; (3) `inductor_tuning` and `aot._load_inductor` did not
prune or reject non-static `TritonCompileResult` entries before
`copy.deepcopy` and `pickle.dumps`, nor did `_GuardPickler` fail fast on
a directly guarded `triton.compiler.CompiledKernel`.

What changed:
- Extended `heliopause/src/export/source_identity.rs`, `heliopause/build.rs`,
  and `heliopause/src/export/binding.rs` (`export_source_identity`) to hash
  `.cpp` and `.hpp` alongside `.py/.rs/.c/.cu/.cuh/.h` and accept exact
  `excluded_files` alongside `excluded_directories`.
- Added `prepared_module_roots()`, `is_prepared_object_module()`, and
  `forward_source_identity()` in `ignition/preparation/source_identity.py`
  backed by `flare_heliopause.export_source_identity` (covering Ignition
  with presentation/publication exclusions, FlashInfer Python + native
  `include`/`csrc`, and all bound `_EXTRA_ROOTS`).
- Replaced Python-only `rglob('*.py')` hashing in `ForwardCache.__init__`
  (`ignition/preparation/aot.py`) with `forward_source_identity`.
- Generalized `forward_metadata._uses_custom_object_state` and
  `rebuild_manifest.weight_views` onto `is_prepared_object_module()`, and
  propagated bound `_EXTRA_ROOTS` from `CompilePool.submit_payload` into
  spawned `_compile_forward` workers (`ignition/preparation/compile_pool.py`).
- Added `_prune_static_compile_results` and `_sanitize_static_bundle` in
  `ignition/preparation/inductor_tuning.py`, invoked from `_selected`,
  `_snapshot` (before `copy.deepcopy`), `InductorSelections.freeze` (before
  `pickle.dumps`), and `aot._load_inductor`, and raised a clear `TypeError`
  in `_GuardPickler.reducer_override` if a guard references a live
  `triton.compiler.CompiledKernel`.
- Added unit tests in `tests/preparation/{test_source_identity.py,
  test_forward_cache_sources.py,test_guard_code.py,test_compile_pool.py,
  test_inductor_prepared_winners.py}`.

Claimed benefit and measured results:
Native CUDA/C++ edits across Ignition, FlashInfer, and bound recipe
packages deterministically invalidate `ForwardCache`; external recipe
objects strip unguarded attributes identically in parent and spawned
compiler workers without hardcoding recipe names in core Ignition; and
non-static `TritonCompileResult` or guarded `CompiledKernel` objects are
pruned or rejected with actionable errors before `pickle.dumps`.

Supporting evidence and limitations:
- Rust library tests: `cargo test --locked --release --manifest-path
  heliopause/Cargo.toml --lib` -> 250 passed, 0 failed, 6 ignored.
- Core boundary and targeted preparation CPU tests (with freshly compiled
  staged `flare_heliopause` extension): `test_core_boundary.py`,
  `test_source_identity.py`, `test_forward_cache_sources.py`,
  `test_guard_code.py`, `test_compile_pool.py`,
  `test_inductor_prepared_winners.py`, and `tests/cli/test_recipe_injection.py`
  all passed.
- Full CPU suite (`tests/preparation/ tests/cli/`): 1,431 passed, 75
  skipped (CUDA/Windows-gated), and 1 pre-existing unrelated failure in
  `tests/preparation/test_runtime_triton.py::test_replaces_stock_architecture_probe_with_pointer_width_key`
  (stock Triton 3.8.0 `platform_key()` omits `"ELF"`).
- CUDA tests (`FLARE_RUN_CUDA_TESTS=1`, SM120 GPU 2):
  `test_inductor_tuning_cuda.py` (8 passed, 5 TP2-gated skipped),
  `test_recorded_export_graph_cuda.py` (2 passed), and cross-repo real
  Triton 3.8.0 `PreparedResidualMix` worker + direct AOT guard roundtrips
  and `hyperflare_jetson_recipes/csrc/*.{cu,cuh}` `ForwardCache`
  invalidation checks all passed.
- Limitations: full multi-rank GB10/SM121 Inkling2 export and TP2
  distributed Inductor CUDA tests were not run on this host.

Design-Signed-Off-By: Antigravity; design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 728.
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.

@flare-autobot flare-autobot added area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. bug Something isn't working enhancement New feature or request triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

PR #728 is technically sound across all four subsystems (Heliopause reachability diagnostics, owned warmup pool + auxiliary-stream seeding, Rust-backed ForwardCache source hashing, and bound source_roots / static Triton AOT guards) with zero verified blockers. One real error-handling gap should be fixed first: forward_source_identity silently hashes zero FlashInfer native sources instead of raising RuntimeError when data/ is absent and the sibling {include,csrc} directories are not both present.

  • Blockers: 0 · Should fix: 1 · Subtract/Simplify: 4 · Nits: 3
Walkthrough
  • Heliopause export reachability diagnostics (heliopause/src/export/reachability.rs:45-349, capture.rs:3417-3419, docs/runtime-core-design.md:166-170,363-365, docs/TODO.txt:381-385): Replaces Reachability::pointer with candidate (returning false without retaining storage for both gaps and inactive ranges), records argument-relative 8-byte-aligned unresolved kernel-argument misses per call site while preserving byte-by-byte retention scanning, and prints a non-blocking per-rank stderr summary prioritizing up to 10 distinct kernel symbols.
  • Owned warmup pool and auxiliary-stream cuBLAS seeding (ignition/preparation/core_storage.py:78,309-318, capture.py:53-107,151-157, docs/preparation-development.md:88-94, tests/preparation/test_{core_storage,capture_cublas_workspace_cuda,capture_stream_isolation}.py): Adds CoreStorage.warmup_pool() registered in _preparation_pools, routes export-mode _seed_warmup_workspaces into it while retaining the 2-arg fallback for non-export callers, and adds _seed_auxiliary_workspaces to seed mm/addmm/bmm on _scratch_arena._auxiliary_stream inside warmup_storage.graph_pool.
  • Native source hashing in ForwardCache (heliopause/src/export/{source_identity.rs:19-55,binding.rs:1149-1168}, heliopause/build.rs:144, ignition/preparation/source_identity.py:61-136, aot.py:902-918, tests/preparation/test_{source_identity,forward_cache_sources}.py): Adds .cpp/.hpp hashing and exact file exclusions to export_source_identity, and routes ForwardCache.__init__ through forward_source_identity instead of Python-only rglob('*.py').
  • Generalized prepared-module roots & static Triton AOT invariants (ignition/preparation/source_identity.py:17,31-58, forward_metadata.py:39-47, rebuild_manifest.py:348,369, compile_pool.py:128-145,172-182, inductor_tuning.py:21-72,108,366, aot.py:125-133,223-229, tests/preparation/test_{guard_code,compile_pool,inductor_prepared_winners}.py): Replaces hardcoded ('ignition.', 'b12x.') checks with prepared_module_roots()/is_prepared_object_module(), propagates bound _EXTRA_ROOTS into spawned CompilePool workers, prunes/rejects non-StaticTritonCompileResult entries before deepcopy/pickle.dumps, and fails fast with TypeError on guarded triton.compiler.CompiledKernel objects in _GuardPickler.reducer_override.
Merge Risk: Medium · up to 71af7c9
  • Broad preparation-wide surface (24 files, +1,571/−85): Touches Heliopause export reachability/source hashing, CUDA warmup/auxiliary pool ownership, ForwardCache key construction (causing a one-time recompile of cached forwards on upgrade), CompilePool worker submission, and Inductor/Triton AOT serialization (StaticTritonCompileResult / CompiledKernel contracts). No serving hot path, protobuf/core wire format, or captured-graph op contract is modified.
  • Partial hardware & cross-repo coverage for Closes #724: Targeted Rust lib tests (250 passed) and SM120 CUDA unit tests passed locally, but full-model GB10 (SM121) Inkling2 / GLM-5.3 exports, SM103/SM87 runs, and TP2 distributed Inductor CUDA tests were not executed (disclosed in Limitations), and closing #724 end-to-end also relies on companion recipe PRs (hyperflare-recipes#163/#151).
  • Active concurrent PR overlap: Shares modified regions with open PRs #642/#597 (inductor_tuning.py), #678 (source_identity.py / _EXTRA_ROOTS), and #723 (capture.py), and subsumes open PRs #332, #606, and #574.
Pre-merge checks: ✅ 3 passed · ⚠️ 2 warnings
  • ✅ Security / malicious screen: No unsafe external inputs, secret handling, or prompt-injection attempts found across the diff or PR text.
  • ✅ Charter & value fit: Targets SM120/SM121 preparation reliability, removes hardcoded package-name tuples from shared Ignition layers, keeps core/wire formats untouched, and includes the four-part PR description with Limitations and Discord contact. Coordinate Co-authored-by attribution and closing disposition for #332 (@mark-yong), #606 (@avifenesh), and #574 (@fordbmorris) on merge.
  • ⚠️ Related / duplicate / conflict check: Incorporates #332 and #606 nearly verbatim and generalizes #574 without listing them in Closes, and overlaps active open PRs #642, #597, #678, and #723.
  • ⚠️ Tests & verification evidence: Heliopause Rust lib tests (250 passed) and SM120 CUDA unit tests passed locally, but confirm .github/workflows/python-cpu.yml is green on 71af7c9 (author's local venv hit an unrelated test_runtime_triton.py stock-Triton mismatch) and note that GB10/SM121 Inkling2 end-to-end export for #724 was not run on this host.

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
lukealonso merged commit 148248a into main Dec 4, 2026
1 check passed
brandonmmusic-max added a commit to brandonmmusic-max/spark-local-inference that referenced this pull request Dec 5, 2026
… to tuning replicas

Commit 2acc3f3 (NVIDIA#670) propagated bound external recipe `source_roots` across
`mp.get_context("spawn")` in `ignition.preparation.rank_group`, reading private
`_EXTRA_ROOTS.get()` directly (matching `aot.py`, and later `compile_pool.py` in
NVIDIA#728). Two gaps remain on `main`:
1. `ignition/preparation/aot.py`, `ignition/preparation/rank_group.py`,
   `ignition/preparation/compile_pool.py`, and
   `tests/preparation/test_compile_pool.py` import private `_EXTRA_ROOTS`
   directly from `source_identity.py` instead of calling a public accessor.
2. `ignition/preparation/tuning_replicas.py` spawns local tuning replicas via
   `mp.get_context("spawn")` without propagating bound `source_roots`. Although
   `_replica` currently calls `prepare(..., compile_forwards=False)` and exits
   on `TuningComplete` without reaching an in-tree `ForwardCache` or
   `source_identity()` call today, binding `source_roots` in `_replica` gives
   local spawned tuning workers the same context invariant as `rank_group._peer`
   if a recipe or future preparation path inspects bound source roots during
   tuning.

Before this change, `aot.py`, `rank_group.py`, `compile_pool.py`, and
`test_compile_pool.py` imported `_EXTRA_ROOTS` directly, `source_identity.py`
had no public accessor for the active `ContextVar`, and
`tuning_replicas._replica` ran with an empty `source_roots` context. After this
change:
- `ignition/preparation/source_identity.py` adds `current_source_roots() ->
  tuple[tuple[str, Path], ...]` returning `_EXTRA_ROOTS.get()`, and updates
  `source_roots`'s docstring to cover active CLI and spawned worker contexts.
- `ignition/preparation/aot.py`, `ignition/preparation/rank_group.py`,
  `ignition/preparation/compile_pool.py`, and
  `tests/preparation/test_compile_pool.py` call `current_source_roots()` so
  `_EXTRA_ROOTS` stays private to `source_identity.py` (preserving `NVIDIA#670`'s
  narrow `with bind_source_roots(...)` scope in `rank_group._peer` and `NVIDIA#728`'s
  native `forward_source_identity` hashing in `aot.py`).
- `ignition/preparation/tuning_replicas.py` captures `current_source_roots()` in
  `prepare_recipe`, passes `extra_source_roots` as a required argument to
  `_replica`, and binds `with source_roots(extra_source_roots), CoreStorage(...)`
  around replica preparation.
- `tests/preparation/test_forward_cache_sources.py` switches
  `_record_source_roots_prepare` to `current_source_roots()`, adds
  `test_current_source_roots_reflects_active_scope`, and adds
  `test_prepare_recipe_propagates_source_roots_to_spawned_tuning_replica`
  asserting both `current_source_roots()` and `ForwardCache.root` agreement
  between replica 0 and spawned replica 1 against the unbound baseline.

Claimed result: keeps `_EXTRA_ROOTS` encapsulated behind
`current_source_roots()`, brings spawned local tuning replicas to spawn-boundary
parity with `rank_group._peer`, and adds real-spawn CPU regression coverage for
both helpers. No model core format, Helios ABI, or single-GPU preparation
behavior changes are introduced.

Validation and limitations (CPU, `CUDA_VISIBLE_DEVICES=""`):
- `py_compile` clean across all seven modified Python files; `git diff --check`
  clean; `git grep _EXTRA_ROOTS` confirms zero references outside
  `ignition/preparation/source_identity.py`.
- `pytest -q tests/preparation/test_forward_cache_sources.py
  tests/preparation/test_forward_cache_concurrency.py
  tests/preparation/test_forward_cache_root.py
  tests/preparation/test_compile_pool.py
  tests/preparation/test_core_boundary.py
  tests/preparation/test_native_processes.py
  tests/preparation/test_tuning_shards.py
  tests/cli/test_recipe_injection.py`: all passing on CPU.
- Limitations: the tuning-replica CPU test stubs `torch.cuda.set_device`,
  `torch.cuda.synchronize`, and `CoreStorage` while exercising real
  `multiprocessing.get_context("spawn")` serialization and `source_roots`
  rebinding; multi-GPU CUDA tuning-replica runs were not executed on CPU.

Design-Signed-Off-By: Brandon M. Music; design-review=2e5b
Signed-off-by: Brandon M. Music <266531604+brandonmmusic-max@users.noreply.github.com>
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 enhancement New feature or request 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.

failed to export inkling-2-mini on GB10

2 participants