Recommendation: Changes Requested
The core production fix (ignition/preparation/core_storage.py:300-309 and ignition/preparation/capture.py:52-74, 118-122) is technically sound and addresses a real native-export failure path: prepare_allocations (heliopause/src/export/capture.rs:1426-1468, invoked at :2894 before reachability) rejects undeclared cuMemMap / VMM device segments whose cuPointerGetAttribute(CU_POINTER_ATTRIBUTE_CONTEXT) returns 0x0, and a dedicated CoreStorage.warmup_pool() keeps warmup segments inside CoreStorage.mappings while remaining disjoint from storage.pool and storage.graph_pool. However, the new CUDA test (tests/preparation/test_capture_cublas_workspace_cuda.py:123-173) introduces order-dependent global _warmup_streams[0] / cuBLASLt cache pollution with the existing test and uses a plain MemPool + SimpleNamespace stub that never tests CoreStorage or declared core mappings; fixing that test, reconciling the contradictory docstring in capture.py:59-63, and posting the failing native error string / #331 cross-references are needed before merge.
Merge Risk
Level: Low
- Narrow production footprint: 23 production lines across
ignition/preparation/core_storage.pyandignition/preparation/capture.py; no CLI flags, config defaults, serving hot-path changes, or per-model branches. Non-export capture preserves the exact 2-argument_seed_warmup_workspaces(warm, device)path (capture.py:122). - Safe isolation and retention behavior:
CoreStorage.warmup_pool()allocates disjoint VMM segments fromself._allocator(avoiding co-location with live tensors instorage.poolthat could bloat exported cores by 32 MiB/rank), registers in_preparation_poolsso the freed 2 MiB operand segment is marked inactive inunused_ranges(), and stays alive for the lifetime of the process-singletonCoreStorage(heliopause/src/allocator.rs:311-314). - Test & CI gap: No CI ran on
2535841, and the new GPU test shares process-global_warmup_streams[0]state withtest_first_capture_binds_workspace_from_the_recording_poolwhile mocking outCoreStorage.
Walkthrough
ignition/preparation/core_storage.py:300-309: AddsCoreStorage.warmup_pool(), lazily creating one persistenttorch.cuda.MemPool(self._allocator.allocator())cached onself._warmup_pooland registering its ID inself._preparation_pools.ignition/preparation/capture.py:52-74: Adds optionalpool=Noneto_seed_warmup_workspaces(stream, device, pool=None)so the module-level_warmup_pools[index]lookup/creation only runs whenpool is None, and updates the docstring (:59-63).ignition/preparation/capture.py:118-122: Incapture_forwards, querieswarmup_storage.warmup_pool()when exposed and passes it to_seed_warmup_workspaces; otherwise preserves the existing 2-argument call_seed_warmup_workspaces(warm, device).tests/preparation/test_core_storage.py:83-105: Adds CPU unit testtest_warmup_pool_reuses_one_core_allocator_poolverifying lazy reuse, allocator identity, and_preparation_poolsregistration via a monkeypatchedFakeMemPool.tests/preparation/test_capture_cublas_workspace_cuda.py:123-173: Adds CUDA-gated testtest_export_warmup_pool_seeds_workspace_inside_storage_poolusing aSimpleNamespacestorage stub and plaintorch.cuda.MemPool()s.
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe external inputs, secret handling, or suspicious native/FFI patterns; no prompt-injection or instruction-override attempts observed in PR material.
- [PASS] Charter & value fit: Targets GB10 / DGX Spark (SM 12.1), keeps native export allocation validation intact without relaxing checks, and adds no flags or per-model branches.
- [PASS] Related / duplicate / conflict check: Genuinely additive with no competing fix and clean against current
main(44f59df); open PR #581 also editsignition/preparation/capture.pyin a different region (record_export_graphcall site) and should merge cleanly. - [WARN] Tests & verification evidence: No CI on
2535841; the new GPU test mocks outCoreStorageand introduces order-dependent global_warmup_streams[0]state pollution, and the PR description omits the exact failing native error message and#331/#266references.
Blockers
- New CUDA test pollutes shared
_warmup_streams[0]/ cuBLASLt cache across tests and never testsCoreStorageor declared core mappings (tests/preparation/test_capture_cublas_workspace_cuda.py:123-173):- Order-dependent breakage & cache pollution:
test_first_capture_binds_workspace_from_the_recording_pool(:33-120) andtest_export_warmup_pool_seeds_workspace_inside_storage_pool(:123-173) run in the same process and share_capture._warmup_streams[0](ignition/preparation/capture.py:21) and PyTorch's(handle, stream)cuBLASLt workspace cache. If the new test runs first (e.g., under test reordering), it seeds_warmup_streams[0]'s cuBLASLt workspace into its localexport_warmuppool; when the existing test subsequently runs,_warmup_streams[0]already has a cached workspace, so_capture._warmup_pools[0]receives only freed temporary operand tensors and:97(assert _active_pool_blocks(_capture._warmup_pools[0].id)) fails. Conversely, in default order,capture_forwardsat:147reuses Test 1's cached workspace on_warmup_streams[0]and never allocates a cuBLASLt workspace inexport_warmup—which is why:159falls back to checking non-emptymemory_snapshot(export_warmup.id)(satisfied by inactive operand blocks alone) and:164-165manually invokes private_seed_warmup_workspaces(fresh_stream, 0, export_warmup)on a round-robintorch.cuda.Stream(), contaminating that pool stream's cuBLASLt cache with a test-local pool. - Missing
CoreStorage/ mapping verification::138-143uses a plaintorch.cuda.MemPool()inside aSimpleNamespacestub. It never instantiatesCoreStorage, never callsCoreStorage.warmup_pool(), never verifies that seeded segments fall insideCoreStorage.mappings, and never exercisesModuleImages/ native export (AGENTS.md:194-199). - Fix: Run the export warmup test in an isolated subprocess (matching
tests/preparation/test_recorded_export_graph_cuda.py:15-20, which avoids both the process-singletonCoreStoragearena conflict inheliopause/src/allocator.rs:312and_warmup_streams[0]cache contamination). Inside the subprocess, openModuleImages()and a realCoreStorage(), callcapture_forwards(..., warmup_storage=storage, pool=storage.graph_pool.id, retain_graphs=True, compile_decoder=False), and assert: (a)_active_pool_blocks(storage.warmup_pool().id)is non-empty directly fromcapture_forwards(dropping the private_seed_warmup_workspaces(fresh_stream, ...)workaround), (b) every segment instorage.warmup_pool().idis covered bystorage.mappings, and (c) no warmup allocation recorded byimagesfalls outsidestorage.mappings.
- Order-dependent breakage & cache pollution:
Should Fix
- Self-contradictory docstring in
_seed_warmup_workspaces(ignition/preparation/capture.py:59-63):- Lines 59–61 retain
#331's wording ("outside transient storage, any caller-owned pool, and the exported graph pool"), immediately followed by lines 61–63 ("When an export storage supplies a persistent warmup pool, seed inside it so the allocation stays within declared core mappings"). - Fix: Rewrite
:59-63into one coherent statement explaining that the seed lives in a dedicated persistent pool outside transient storage, caller-owned model storage (storage.pool), and the exported graph pool—using the export storage's dedicatedwarmup_pool()when supplied so its disjoint segments remain within declared core mappings and are omitted as unreachable at export time.
- Lines 59–61 retain
- Document the exact failing native error,
#331/#266references, and retention/re-export impact in the PR description:- The description asserts native export rejection on GB10 (
spark-b23d) without quoting the exact error string (e.g.,external allocation ... is not device memory in the serving context (...)fromheliopause/src/export/capture.rs:1463) or reproduction command (AGENTS.md:165-169). - It modifies the design introduced by
#331(Refs #266) without referencing either item, and omits both the memory-accounting shift (in export processes, the ~34 MiB warmup pool moves from module-level_warmup_poolsintoCoreStorage's fixed address window rather than allocating both) and the compatibility note (previously exported cores do not need re-export because affected exports failed prior to writing a core). - Fix: Add the failing GB10 error message and command, cite
#331/#266, and note the memory-ownership shift and existing-core status in the PR description.
- The description asserts native export rejection on GB10 (
Subtract / Simplify
- Collapse the caller-side
if/elseincapture_forwards(ignition/preparation/capture.py:118-122):_seed_warmup_workspaces(stream, device, pool=None)already handlespool is None(capture.py:67-70), so:118-122duplicates that fallback solely to keep the 2-argument call signature for seven CPU test stubs (tests/preparation/test_capture_graph_metadata.py:181(not opened),test_capture_rank_readiness.py:56(not opened),test_capture_roce_wait.py:40(not opened),test_capture_stream_isolation.py:44,test_forward_compile_options.py:309(not opened),test_preparation_reclamation.py:41(not opened),test_transient_retention.py:131(not opened)). Either collapse:118-122to_seed_warmup_workspaces(warm, device, warmup_storage.warmup_pool() if hasattr(warmup_storage, "warmup_pool") else None)and addpool=Noneto those seven lambdas, or add a brief inline comment if keeping the 2-argument form to avoid touching those test files is intentional.
- Remove duplicated setup and redundant assertions in
tests/preparation/test_capture_cublas_workspace_cuda.py:123-173:- Replacing the stubbed test with the isolated real-
CoreStoragesubprocess test (Blocker 1) removes both the duplicatedSimpleNamespace/tensor scaffold and the weakermemory_snapshot(...)+ private_seed_warmup_workspaces(fresh_stream, ...)pair (:159-168).
- Replacing the stubbed test with the isolated real-
Nits
- Declare
self._warmup_pool = NoneinCoreStorage.__init__(ignition/preparation/core_storage.py:72-73, 304): Place it besideself._retention_pool = Noneat:73for consistency with the class's other lazy pool fields (getattr(self, "_warmup_pool", None)can remain forCoreStorage.__new__-based unit tests, matching_persistent_arenaat:332). - Update
docs/preparation-development.md:88-91: Add one clause noting that cuBLAS warmup workspaces are seeded intoCoreStorage.warmup_pool()inside declared core mappings (AGENTS.md:226).
Dropped on verification
- Correctness F1 ("Claimed native-export rejection is not
capture.rs:1437-1466; in-processcuPointerGetAttributepasses trivially and unreferenced segments are omitted at:3472; only floor rule:3385could fire"): Dropped as false.prepare_allocations(heliopause/src/export/capture.rs:1426-1468) is called at:2894beforeReachability(:3182) and omission (:3472), so unreferenced external segments are validated—not omitted—before:1461. CUPTI recordscuMemMapsegments as"device"allocations (heliopause/src/export/recorder.rs:467-478), and CUDA VMM allocations returncontext = 0x0fromcuPointerGetAttribute(CU_POINTER_ATTRIBUTE_CONTEXT)even in-process (confirmed in#154), triggering:1461-1466whenever a VMM-backedMemPoolsegment lies outsidestorage.mappings. (Only the valid request to quote the exact failing error string is kept under Should Fix.) - Correctness F2 ("Registering
pool.idin_preparation_poolscauses undeclared exported core metadata shifts, extralive_piecessplits, and relabeled memory-inventory rows"): Dropped as false/overstated._warmup_poolowns disjoint VMM segments, sounused_ranges()never splitsstorage.poolorstorage.graph_poolallocations; unreferenced warmup segments are omitted fromoutput.allocations(capture.rs:3472);ignition/preparation/memory_inventory.py:198-210inspectstorch.cuda.memory_snapshotacross all device segments directly without consulting_preparation_pools; and addingpool.idto_preparation_poolsmatchesself.pool,transient,scratch_pool, andPackedWeightswhile preventing false-positive retention of the freed 2 MiB operand segment (heliopause/src/export/reachability.rs:119-122). - Subtraction S2(a) ("
CoreStorage.warmup_pool()duplicatesCoreStorage.pool(core_storage.py:113-117); delete it and reusewarmup_storage.pool"): Dropped as unsafe.storage.poolholds live model buffers/weights/metadata; placing the 32 MiBactive_allocatedcuBLASLt warmup workspace instorage.poolallows it to share a VMM segment with graph-reachable tensors, causing export reachability to retain and download 32 MiB of warmup workspace per rank (unused_ranges()only excludesinactiveblocks and padding, notactive_allocatedblocks). A separateMemPoolis necessary so warmup segments stay disjoint and omitted at export time. - Correctness F5 ("Pool construction at
capture.py:118/core_storage.py:306lefttorch.cuda.device(device)scope anduse_mem_poolomitsdevice="): Dropped as false.torch.cuda.MemPool(allocator)does not bind to a device at construction (matchingcore_storage.py:113, 114, 277, 281, 563andpacked_weights.py:30), andcapture.py:71enterstorch.cuda.device(index)left-to-right beforetorch.cuda.use_mem_pool(pool). - Correctness F6 ("Unsynchronized lazy init of
_warmup_poolcreates a concurrency race on concurrentcapture_forwardscalls"): Dropped as speculative. Same-device preparation is explicitly single-threaded per rank process (heliopause/src/allocator.rs:311-314,#331Limitations); all other lazyCoreStoragestate (_retention_pool,_persistent_arena,_device_cursor,_host_cursor) and module-level_warmup_streams/_warmup_poolsare likewise unsynchronized. (Only the__init__declaration consistency note is kept as a Nit.) - Correctness F4's framing as a blocking architectural invariant reversal of
#331: Narrowed to Should Fix.#331's safety invariants (off-capture warmup stream, persistent warmup workspace backing separate from transient storage,storage.pool, andstorage.graph_pool) remain intact; only the docstring contradiction incapture.py:59-63and missing#331/#266references need cleanup.