Final review report · NVIDIA/hyperflare-inference #606

Raw Markdown for agents: https://autobot.eidonix.com/p/3a91ad16-aa36-46d9-bd99-96dfa3f933ce.md

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

Walkthrough

Pre-merge Checks

Blockers

  1. New CUDA test pollutes shared _warmup_streams[0] / cuBLASLt cache across tests and never tests CoreStorage or 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) and test_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 local export_warmup pool; 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_forwards at :147 reuses Test 1's cached workspace on _warmup_streams[0] and never allocates a cuBLASLt workspace in export_warmup—which is why :159 falls back to checking non-empty memory_snapshot(export_warmup.id) (satisfied by inactive operand blocks alone) and :164-165 manually invokes private _seed_warmup_workspaces(fresh_stream, 0, export_warmup) on a round-robin torch.cuda.Stream(), contaminating that pool stream's cuBLASLt cache with a test-local pool.
    • Missing CoreStorage / mapping verification: :138-143 uses a plain torch.cuda.MemPool() inside a SimpleNamespace stub. It never instantiates CoreStorage, never calls CoreStorage.warmup_pool(), never verifies that seeded segments fall inside CoreStorage.mappings, and never exercises ModuleImages / 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-singleton CoreStorage arena conflict in heliopause/src/allocator.rs:312 and _warmup_streams[0] cache contamination). Inside the subprocess, open ModuleImages() and a real CoreStorage(), call capture_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 from capture_forwards (dropping the private _seed_warmup_workspaces(fresh_stream, ...) workaround), (b) every segment in storage.warmup_pool().id is covered by storage.mappings, and (c) no warmup allocation recorded by images falls outside storage.mappings.

Should Fix

  1. 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-63 into 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 dedicated warmup_pool() when supplied so its disjoint segments remain within declared core mappings and are omitted as unreachable at export time.
  2. Document the exact failing native error, #331/#266 references, 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 (...) from heliopause/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_pools into CoreStorage'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.

Subtract / Simplify

  1. Collapse the caller-side if/else in capture_forwards (ignition/preparation/capture.py:118-122):
    • _seed_warmup_workspaces(stream, device, pool=None) already handles pool is None (capture.py:67-70), so :118-122 duplicates 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-122 to _seed_warmup_workspaces(warm, device, warmup_storage.warmup_pool() if hasattr(warmup_storage, "warmup_pool") else None) and add pool=None to those seven lambdas, or add a brief inline comment if keeping the 2-argument form to avoid touching those test files is intentional.
  2. 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-CoreStorage subprocess test (Blocker 1) removes both the duplicated SimpleNamespace/tensor scaffold and the weaker memory_snapshot(...) + private _seed_warmup_workspaces(fresh_stream, ...) pair (:159-168).

Nits

  1. Declare self._warmup_pool = None in CoreStorage.__init__ (ignition/preparation/core_storage.py:72-73, 304): Place it beside self._retention_pool = None at :73 for consistency with the class's other lazy pool fields (getattr(self, "_warmup_pool", None) can remain for CoreStorage.__new__-based unit tests, matching _persistent_arena at :332).
  2. Update docs/preparation-development.md:88-91: Add one clause noting that cuBLAS warmup workspaces are seeded into CoreStorage.warmup_pool() inside declared core mappings (AGENTS.md:226).

Dropped on verification