PR #606 — Correctness, Contracts & System-Level Consequences review
Head 8c1a28a, +191/−8 across 5 files, stale against zero human reviews. Verdict: Changes Requested — 1 Blocker, 1 Major, 3 Minor. The production change itself is small and, on the paths I could inspect, behaviourally consistent; the blocker is that the PR's headline evidence does not exercise the native validations it claims to satisfy.
Key findings
- Blocker — the new "export" CUDA test cannot reach either native validation the fix exists for. It hand-builds
RuntimeCoreand callswrite(tests/preparation/test_capture_cublas_workspace_cuda.py:237-249);write's request never setsdiscover_allocations(runtime_core.py:122-133; sole setter isexport_model,runtime_core.py:360), so the discovery/context rejection is skipped (capture.rs:1412-1414), anddevice_address_floorstays at the constructor default0(runtime_core.py:97-98) instead ofstorage.EXTERNAL_FLOOR if storage.integrated else 0(runtime_core.py:364), so the below-floor rejection (capture.rs:3381-3389) can never fire. - Major — the new pool id silently changes exported core content through
unused_ranges()/zero_ranges, and the warmup segment is the one preparation-pool segment never declared zero.core_storage.py:309+:320-335→runtime_core.py:298-301→capture.rs:1471-1490. Untested either way. - Minor — a persistent ~34 MiB core-window segment is now created for every
CoreStoragecapture, including non-export tuning-replica captures (capture.py:117-124,tuning_replicas.py:157-160), andmemory_inventory.py:198-210gives it no line item. - Minor — PR body still claims #331's "outside any caller-owned pool" invariant is preserved, while the code and its own docstring say the export path deliberately uses a caller-owned pool (
capture.py:59-64); still no statement on whether previously exported cores need re-export. - Minor — lost coverage + stale test module docstring: the direct 3-argument seed call and the export-path transient-cleanliness assertion are gone;
:11-12still says the file "needs no package-export resources" although:123-255builds realCoreStorage/ModuleImages/RuntimeCore.
1. Correctness, Safety & Platform Parity
1.1 Blocker — the end-to-end test never enters the code path that produced the quoted error
tests/preparation/test_capture_cublas_workspace_cuda.py:237-249:
package = RuntimeCore(
allocations=allocations,
modules={},
kernels=(),
recorder=images.native,
owners=(bundle, storage),
)
package.write(
tmp_path / "rank.json (not opened)",
bundle.graphs,
execution=bundle.export_manifest(),
sources=True,
)
write's request (ignition/preparation/runtime_core.py:122-133) ends with:
roots=[a.name for a in self.allocations],
cupti_path=_cupti_path(), publisher=_publisher_metadata(publisher),
reservations=[(r["address"], r["nbytes"]) for r in self.reservations], events=self.events,
transports=self.transports, device_address_floor=self.device_address_floor, execution=execution,
There is no discover_allocations key. The native check is gated on it (heliopause/src/export/capture.rs:1412-1414):
if let Some(recorder) =
recorder.filter(|_| request.discover_allocations || !request.peer_mappings.is_empty())
{
so the loop containing the quoted failure (capture.rs:1461-1466) never runs:
if memory != 2 || context as usize != request.context {
return Err(invalid(format!(
"external allocation {:#x}+{} is not device memory in the serving context ...",
The second validation is also unreachable: RuntimeCore.__init__ defaults device_address_floor=0 (runtime_core.py:97-98), whereas the real path passes the floor (runtime_core.py:364):
device_address_floor=storage.EXTERNAL_FLOOR if storage.integrated else 0,
and capture.rs:3381-3389 requires allocation.address < request.device_address_floor, which is never true for a zero floor. Because EXTERNAL_FLOOR (core_storage.py:42) is exactly the 0x4000000000 in the error string, the test would pass identically if the seed landed below the floor on an integrated host — the exact condition the PR is fixing.
Impact: the PR's only end-to-end evidence is Python-level (module pool unused :187, pool id registered :189, block active in the warmup pool :190, segment inside storage.mappings :197-204, workspace in storage.graph_pool :205). Those are real and useful, but a regression that reintroduced an unowned VMM segment in a path reaching roots/execution would still pass this test. Combined with the fact that no CI job runs the Python/CUDA suite, the "36 passed, 1 skipped" claim cannot be upgraded to proof of the fix.
Fix: drive the test through export_model (precedent: helios/tests/fixed_core_fixture.py:171), or teach write to accept and forward discover_allocations=True plus a non-zero device_address_floor, then assert package.native_output/.external reflect the warmup segment as declared rather than external.
1.2 Minor — coverage lost in the test rewrite
The direct _seed_warmup_workspaces(fresh_stream, 0, export_warmup) call was removed; the third-argument branch is now only reached indirectly through capture_forwards (capture.py:119-124). The export-path transient-cleanliness assertion (not _active_pool_blocks(transient.id)) survives only for the non-export test (:94-96), so nothing asserts that export seeding put nothing into storage.transient. Since #331's whole point was off-transient-stream workspace retention, that assertion should be restored inside the export test as well.
1.3 Minor — stale module docstring in the changed test file (:11-12)
pool. The test uses plain MemPools for transient storage and the
shared graph pool handle so it needs no package-export resources.
check_export_warmup_pool (:148-255) now instantiates real CoreStorage and ModuleImages and exports a native package, i.e. precisely the resources the docstring says are not needed. This is the same drift class the commit set out to fix elsewhere.
1.4 Areas checked and found sound (no issue invented)
_seed_warmup_workspacesdocstring (capture.py:52-65) now describes both branches accurately and matches the code at:66-75; stream creation, per-thread caching andstream.synchronize()ordering are unchanged.- The non-export path keeps the exact two-argument call and the module-level dict (
capture.py:68-71,:122-124), so existing stubs/callers withoutwarmup_pool()are unaffected:tests/preparation/test_capture_rank_readiness.py:70(not opened) andtests/preparation/test_transient_retention.py:141-142(not opened) pass aSimpleNamespacewithout that attribute;test_capture_cublas_workspace_cuda.py:97still resolves_warmup_pools[0]. _warmup_poolis properly declared inCoreStorage.__init__(core_storage.py:74); the remaininggetattrat:305only serves the CPU test that builds the object viaCoreStorage.__new__(tests/preparation/test_core_storage.py:95-101), which correctly asserts single lazy creation and registration.- No new lock, queue or hot-path work:
warmup_pool()is called once percapture_forwards, and seeding already mutates the process-global allocator. No ordering hazard versus capture: seeding still completes (withstream.synchronize()) before compile/capture begins (capture.py:120-125). - Windows parity: untouched — the window-sealing path in
core_storage.pyearly-returns under WDDM, and the only new object is atorch.cuda.MemPoolover the core allocator, which is platform-independent. - Device parity:
warmup_pool()does not verifydevice, but in every call site theCoreStoragedevice is the capture device, so I found no reachable mismatch; the integrated-GPU branch (core_storage.py:66-70, Jetson Orin floor/DEVICE_BASEoverride) is not disturbed by the new pool.
2. Unintended System-Level Consequences
2.1 Major — _preparation_pools registration changes exported core content, and the warmup segment is the only one not declared zero
ignition/preparation/core_storage.py:306-309 and :320-335:
pool = getattr(self, "_warmup_pool", None)
if pool is None:
pool = torch.cuda.MemPool(self._allocator.allocator())
self._warmup_pool = pool
self._preparation_pools.add(pool.id)
for segment in torch.cuda.memory_snapshot(include_traces=False):
if (segment["device"] != self.device
or tuple(segment["segment_pool_id"]) not in self._preparation_pools):
continue
for block in segment["blocks"]:
live = 0 if block["state"] == "inactive" else block["requested_size"]
if live < block["size"]:
ranges.append((block["address"] + live, block["address"] + block["size"]))
Adding the pool id makes unused_ranges() sweep warmup-pool padding into exported metadata. export_model consumes that as both inactive and zero_ranges (runtime_core.py:296-301):
zero_ranges.extend((segment["address"], segment["total_size"])
for segment in storage.graph_pool.snapshot(include_traces=False))
inactive = storage.unused_ranges()
zero_ranges.extend((start, end - start) for start, end in inactive)
and the native side uses inactive to split allocations into live pieces (capture.rs:1471-1486) and zero_ranges to blank ranges (capture.rs:1487-1490). Note the asymmetry: graph-pool segments are declared content-free in full (runtime_core.py:298-299), while the warmup segment is active (asserted at test :190) and only its padding is zeroed. If the warmup mapping is ever reachable from a graph node or from roots, the cuBLASLt workspace bytes would be snapshotted/restored as if they were live state, and the allocation would be emitted as live pieces instead of as a single declared mapping. In today's path it is probably unreachable (the seed workspace lives only on the warmup stream, and export_model passes no roots; runtime_core.py:354-370), so this is incidental — but it is unasserted, it is a new exported-content effect introduced by a PR whose stated goal is unchanged export semantics, and the test never calls unused_ranges() nor passes zero_ranges.
Fix (cheap, in-repo): extend runtime_core.py:298-299 to also declare the warmup pool content-free, e.g. add storage.warmup_pool().snapshot(include_traces=False) segments when storage._warmup_pool is not None; and add an assertion in the export test that storage.unused_ranges() spans and zero_ranges cover the warmup segment.
Correction to my earlier note: the prior-review framing that the change "avoids 32 MiB/rank of export bloat" is not established by this code; nothing here proves the workspace bytes were previously exported. The description should drop that implication.
2.2 Minor — permanent core-window retention on every capture, including non-export, with no reporting
ignition/preparation/capture.py:117-124:
warmup = nullcontext if warmup_storage is None else warmup_storage.transient
warm = _warmup_stream(device)
warmup_pool = warmup_storage.warmup_pool() if hasattr(warmup_storage, "warmup_pool") else None
if warmup_pool is not None:
_seed_warmup_workspaces(warm, device, warmup_pool)
else:
# Keep the 2-argument call for non-export callers and existing test stubs.
_seed_warmup_workspaces(warm, device)
CoreStorage is not export-only: tuning replicas build one and prepare with retain_graphs=False (ignition/preparation/tuning_replicas.py:157-160), so those runs now create a persistent core-allocator MemPool and take one segment (the 2 MiB operand segment from the error string plus the 32 MiB cuBLASLt workspace, ~34 MiB) out of the same fixed device window that backs storage.pool, storage.graph_pool and transients, for the life of the process. The PR body frames this as moving retention, not adding it, but the two placements are not equivalent: the previous module-level pool took caching-allocator segments outside the declared window; the new one is inside the window sized for the graph pool and persistent state. On a tuned run with several replicas that is ~34 MiB × replicas unavailable to graph allocation.
Observability shift: memory_inventory.py:198-210 only special-cases storage.graph_pool.id, and inactive-block slack otherwise; warmup-pool blocks are attributed through core.allocations fixed ranges (memory_inventory.py:228-229) with no distinguishing label, so retained-bytes reporting grows silently and nobody can tell the warmup pool apart from real persistent state in print_inventory output.
Fix: either gate pool creation on the export path (retain_graphs/warmup_storage being a real export storage) rather than on duck-typing, or add an explicit warmup_pool claim/line item in memory_inventory so the cost is visible.
Retraction: my scratchpad cited a core-allocator free-list site in heliopause/src/export/allocator.rs (not opened); that file does not exist at this head (list_files shows no allocator.rs under heliopause/src/export/). The retention claim above rests only on the verified Python sites, and the "one segment permanently out of the free list" mechanism is inferred, not citeable here.
2.3 Not applicable / cleared
No mutex, queue or lock ordering change; no unbounded buffering added; no per-request hot path touched (all of this is preparation-time). Failure propagation is unchanged: pool creation failing raises at capture_forwards entry, same as the module-pool allocation it replaces. Concurrency: the only shared state is the per-CoreStorage _warmup_pool and the per-process _warmup_streams/cuBLASLt cache, both already preparation-global; the new GPU test's subprocess isolation (:123-128) correctly avoids cross-test contamination.
3. Architecture, Contracts & Charter Compliance
- Wrong layer? The change is placed in
CoreStorage(the owner of declared mappings) and reachescapture.pyonly through duck typing, which is the right layer for "keep warmup segments inside declared mappings" — better than teachingcapture.pyabout core storage internals. However, the duck-typedhasattr(warmup_storage, "warmup_pool")check (capture.py:119) silently degrades: any future storage type that forgets the method falls back to the module pool with no diagnostic, reproducing the original bug invisibly. Consider an explicit protocol/attribute or an assertion in the export path. (Observation, not a blocker.) - Captured-graph contract: no new graph kind and no op contract change, so no owner sign-off is triggered. Neither
AGENTS.md(not opened)-level design docs nordocs/preparation-development.mdcontract text is contradicted by the code —docs/preparation-development.md:92-94now documentsCoreStorage.warmup_pool()consistently. - Charter: the PR is a bug fix with a plausible root cause, not a perf claim, so #210 evidence does not apply. It does reverse one #331 invariant while claiming to preserve all of them (see 4.2), which is the kind of contract drift the charter asks reviewers to catch.
4. Tests & Claim Accuracy
4.1 Blocker — see 1.1
4.2 Minor — the description contradicts its own diff on #331's invariant, and omits the re-export question
PR body: "preserves all of #331's safety invariants (off-capture warmup stream, persistent backing outside transient storage, storage.pool, and storage.graph_pool)" and "keeping warmup segments inside declared CoreStorage.mappings". But the new docstring (capture.py:59-64) says the export branch deliberately does the opposite of #331's "outside any caller-owned pool":
later call could reuse it. When ``pool`` is omitted, seeding uses a
module-level pool outside transient storage, caller-owned pools, and
the exported graph pool. When an export storage supplies
``warmup_pool()``, seeding uses that persistent pool instead so the
That is a reasonable design (a pool owned by the export storage is not a transient caller-owned pool), but the body should say it reverses that specific invariant and why it is safe — not claim it is preserved. Also still absent: whether cores exported on unified-memory GPUs before this change need a re-export (the sentence yatesdr required on #331 and which #331's description carries), and any mention of #332, the export-time diagnostic that would make this failure class self-detecting instead of hand-analyzed.
4.3 Missing in-repo regression coverage
- No CPU-level test asserts that the export branch is taken:
tests/preparation/test_core_storage.py:83-105covers lazy creation and_preparation_poolsregistration but notcapture_forwards' dispatch atcapture.py:119-124, which is testable without a GPU using a fake storage exposingwarmup_pool()and monkeypatching_seed_warmup_workspacesto record its arguments. - No assertion anywhere ties the new
_preparation_poolsentry tounused_ranges()/zero_ranges(see 2.1). - CLAUDE.md (not opened)/rules aside, the structural CI gap stands: no workflow runs pytest or sets
FLARE_RUN_CUDA_TESTS, so "36 passed, 1 skipped" and the reversed-order run remain self-reported and require maintainer confirmation on the cited GB10 host.
Open questions
- Does the new test still pass on a hardware-integrated host where
storage.integratedis true andEXTERNAL_FLOORis non-zero — i.e. would it catch a seed landing below0x4000000000? Nothing in the test can tell (see 1.1). - Are the warmup pool's active block bytes actually transferred into exported cores, or skipped as unreachable from
roots/execution(capture.rs:3380-3400iteratesreach)? Unasserted either way; this determines whether 2.1 is a real artifact-content bug or only a metadata asymmetry. - Do cores exported before this change on unified-memory GPUs need a re-export? Not answered in the body.
- Is relocating the allocation the right fix at all, versus a #332-style export-time diagnostic that names the offending allocation site? A maintainer design call.
Not found / not verifiable from here
- No linked issue or user bug report corroborating the specific GB10 rejection; #266 stays open/P1 and is referenced but untested.
- No competing fix on
mainfor this failure class. Signed-off-by/ DCO state not verifiable through the available tooling (a recurring gap on #331/#332 as well).heliopause/src/export/allocator.rs(not opened) does not exist at this head, so any free-list mechanism claim must not be cited; correspondingly I withdrew that part of my earlier note (see 2.2).