Repository navigation
heliopause,ignition: enforce export reachability, owned warmup pools, native ForwardCache hashing, and Triton AOT guard contracts - #728
Conversation
…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>
|
A case file has been opened for 728. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedPR #728 is technically sound across all four subsystems (Heliopause reachability diagnostics, owned warmup pool + auxiliary-stream seeding, Rust-backed
Walkthrough
Merge Risk: Medium · up to
|
… 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>
Why this change is needed
Four coupled export-memory, cache-identity, and AOT serialization gaps affect Ignition preparation and Heliopause export:
Reachabilityreports 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).ignition/preparation/capture.pyseeded warmup-stream cuBLAS workspaces into an unowned module-leveltorch.cuda.MemPool()outsideCoreStoragemappings (addressed by fix(ignition): seed warmup workspaces inside export storage pool #606, which had merge conflicts againstmain), and did not seed auxiliary overlap streams before warmups so their cuBLAS workspaces could land in transient warmup storage.ForwardCachehashing:ForwardCache.__init__(ignition/preparation/aot.py) hashed only*.pyfiles viarglob('*.py'), silently returning stale compiled forwards after edits to.cu,.cuh,.c,.h,.cpp, or.hppsources across Ignition (kv_codec_gpu.cu), FlashInfer (data/include,data/csrc), and external recipe roots.forward_metadata._uses_custom_object_stateandrebuild_manifest.weight_viewshardcoded('ignition.', 'b12x.'), omitting external recipe packages bound viasource_roots(). Under Triton 3.8, when an unstripped external recipe object (such as Inkling2'sPreparedResidualMix) or a non-staticTritonCompileResultreachespickle.dumps, export fails late withPicklingError: Can't pickle <class 'triton.compiler.compiler.KernelMetadata'>. SpawnedCompilePoolworkers also did not inherit boundsource_roots, and_GuardPicklerdid not fail fast if a guard directly referenced atriton.compiler.CompiledKernel.Routing
ForwardCachethroughflare_heliopause.export_source_identity, deriving prepared object module prefixes from boundsource_roots(keeping core Ignition free of hardcoded recipe package names), owning warmup pools inCoreStorage, and enforcing static-onlyTritonCompileResultinvariants beforedeepcopy/pickle.dumpsresolves all four gaps at their source.What changed
Reachabilityreturned only raw unresolved addresses on export failure.Reachability::unresolved_reportand node-context diagnostics inheliopause/src/export/{reachability.rs,capture.rs}plus documentation indocs/runtime-core-design.mdanddocs/TODO.txt. (Note:.github/workflows/python-cpu.ymlalready runscargo test --locked --release --manifest-path heliopause/Cargo.toml --libsince1da22724.)capture.pyalways seeded warmup workspaces in module-global_warmup_poolsand left scratch-arena_auxiliary_streamunseeded before warmups.CoreStorage.warmup_pool()inignition/preparation/core_storage.py, routed export-mode_seed_warmup_workspaces(mmandaddmm) intowarmup_storage.warmup_pool()while keeping the 2-argument non-export fallback, and added_seed_auxiliary_workspacesinignition/preparation/capture.pyseedingmm,addmm, andbmminsidewarmup_storage.graph_pool. Updateddocs/preparation-development.mdand added CPU/CUDA tests intests/preparation/{test_core_storage.py,test_capture_cublas_workspace_cuda.py,test_capture_stream_isolation.py}.ForwardCache:heliopause/src/export/source_identity.rsandheliopause/build.rshashed.py/.rs/.c/.cu/.cuh/.hwith directory-only exclusions, andForwardCache.__init__hashed only*.py.heliopause/src/export/{source_identity.rs,binding.rs}andheliopause/build.rsto hash.cpp/.hppand acceptexcluded_files; addedforward_source_identity()inignition/preparation/source_identity.pybacked byflare_heliopause.export_source_identity; replacedForwardCache.__init__'s Python-only loop inignition/preparation/aot.pywithforward_source_identity.source_rootsobject 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):forward_metadata._uses_custom_object_stateandrebuild_manifest.weight_viewshardcoded('ignition.', 'b12x.');CompilePoolworkers ran with empty_EXTRA_ROOTS;inductor_tuningandaot._load_inductordid not prune/reject non-staticTritonCompileResultbeforedeepcopy/pickle.dumps;_GuardPicklerattempted to pickle guardedCompiledKernelinstances.prepared_module_roots()/is_prepared_object_module()inignition/preparation/source_identity.py, wiredforward_metadata.pyandrebuild_manifest.pythrough it, propagated bound_EXTRA_ROOTSthroughCompilePool.submit_payload->_compile_forward(ignition/preparation/compile_pool.py), added_prune_static_compile_results/_sanitize_static_bundleinignition/preparation/inductor_tuning.py(invoked from_selected,_snapshot,freeze, andaot._load_inductor), and raised a clearTypeErrorin_GuardPickler.reducer_overrideon guardedtriton.compiler.CompiledKernel.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
CoreStoragemappings (outside transient and graph pools), and auxiliary overlap streams bind persistent graph-pool workspaces across warmup, capture, and native replay..cu/.cuh/.c/.h/.cpp/.hppfiles in Ignition, FlashInfer (data/include,data/csrc), and bound external recipe packages deterministically invalidateForwardCache.CompilePoolworkers without hardcoding recipe names in core Ignition, and non-staticTritonCompileResultor guardedCompiledKernelobjects are pruned or rejected with actionableTypeErrors beforepickle.dumps.CoreStorage+RuntimeCore.write()that seeded warmup workspaces reside insideCoreStorage.mappingswhile leaving_capture._warmup_poolsempty.CompiledKernelinstances (confirmingpickle.dumps(compiled.metadata)raisesPicklingError: KernelMetadata) that both worker-serialized and direct owning-rankaot_compile+_guard_serializationroundtrips passguard_check(owner)with matching outputs.ForwardCache.rootinvalidates on edits to Ignition.cu, FlashInferdata/{csrc,include}, andhyperflare_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_heliopauseextension (--features server,extension-module), and RTX PRO 6000 Blackwell Max-Q (SM120) GPUs:cargo test --locked --release --manifest-path heliopause/Cargo.toml --lib-> 250 passed, 0 failed, 6 ignored (CUDA-device 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), andtests/cli/test_recipe_injection.py(4 passed) all passed.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_keyfails standalone under Triton 3.8.0 because stocktriton.runtime.build.platform_key()returns"x86_64,Linux,64bit"rather than"x86_64,Linux,64bit,ELF".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).Related PRs and issues
@lru_cacheCUDA-tensor singletons + adds AST/CUDA ban and full-moduleSourceDependencies.closuretest)PreparedResidualMix.triton_preparedboolean + unit test)csrc/intohyperflare_jetson_recipes/csrc/and packages via[tool.setuptools.package-data])Discord: lukealonso