#1 [high] PR #606 change surface (verified from diff at head 8c1a28a)
PR #606 files (pr_diff): docs/preparation-development.md +4/-1; ignition/preparation/capture.py +16/-7; ignition/preparation/core_storage.py +12/-0; tests/preparation/test_capture_cublas_workspace_cuda.py +134/-0; tests/preparation/test_core_storage.py +25/-0.
Production change:
- core_storage.py:74
self._warmup_pool = Nonein init; core_storage.py:301-310 newCoreStorage.warmup_pool()->torch.cuda.MemPool(self._allocator.allocator()), cached,self._preparation_pools.add(pool.id). Allocator isflare_core_allocate/flare_core_free(core_storage.py:109-111). - capture.py:52-75
_seed_warmup_workspaces(stream, device, pool=None); module-level_warmup_pools[index]only when pool is None (capture.py:68-71). - capture.py:119-124
capture_forwardsduck-typeswarmup_storage.warmup_pool()and passes it; else keeps 2-arg call (comment at :123 "Keep the 2-argument call for non-export callers and existing test stubs"). - docs/preparation-development.md:88-94 documents the new warmup_pool.
Tests:
- tests/preparation/test_core_storage.py:83-105 CPU unit test (monkeypatched FakeMemPool, CoreStorage.new).
- tests/preparation/test_capture_cublas_workspace_cuda.py:123-145 subprocess wrapper, :148-254
check_export_warmup_pool: builds real CoreStorage + ModuleImages, capture_forwards(..., warmup_storage=storage, pool=storage.graph_pool.id, retain_graphs=True, compile_decoder=False), assertsnot _capture._warmup_pools, warmup pool id in_preparation_pools, active blocks in warmup pool, every warmup segment insidestorage.mappings, active block in graph pool, thenRuntimeCore.write(tmp_path/"rank.json", ...). - Module-level skip:
pytestmark = pytest.mark.skipif(os.environ.get("FLARE_RUN_CUDA_TESTS") != "1")at that file :22.
#2 [high] Defect mechanism and the native validation the fix targets
Failure path (heliopause/src/export/capture.rs):
prepare_allocations(:1400-1492) runs at :2894 BEFORE Reachability/omission, so unreferenced recorded segments are validated, not omitted.- Discovery branch active when
request.discover_allocationsor peer_mappings non-empty (:1407-1414). Onlyexport_modelsetsdiscover_allocations=True(runtime_core.py:360);RuntimeCore.writedoes NOT (runtime_core.py:122-133 has no such key). - Interaction with graph bug: for each recorded device allocation not covered by a declared
request.allocations, the exporter callscuPointerGetAttributeCONTEXT(:1443-1452)/TYPE(:1453-1460) and rejects whenmemory != 2 || context as usize != request.context(:1461-1466). Error text: "external allocation {addr}+{nbytes} is not device memory in the serving context (memory .., context .., recorded context .., serving context ..)". - The quoted GB10 error address 0x4000000000 == CoreStorage.EXTERNAL_FLOOR (core_storage.py:42), +2097152 (2 MiB) i.e. a VMM cuMemMap segment from the module-level pool. CUPTI records cuMemMap as memory="device" (heliopause/src/export/recorder.rs:467-478).
- Device-address floor check at capture.rs:3383-3389 uses
request.device_address_floor, set only in export_model fromstorage.EXTERNAL_FLOOR if storage.integrated else 0(runtime_core.py:364); RuntimeCore.write default is 0 (runtime_core.py:98). - Declared mappings skip: capture.rs:1437-1441 (
allocations.iter().any(|a| a.address <= recorded.address && end <= a.address + a.nbytes)) — export_model declares onedevice-{index}allocation per storage.mappings entry with preserve_address (runtime_core.py:308-310). - Export-time inactive/zero_ranges: runtime_core.py:298-301 = graph_pool snapshot +
storage.unused_ranges(); unused_ranges (core_storage.py:320-335) only iteratesself._preparation_pools, so the new warmup_pool registration feeds the freed 2 MiB operand block as inactive intozero_rangesandinactive. live_pieces/without_zero_ranges split at capture.rs:1471-1490. storage.integrated=torch.cuda.get_device_properties(device).is_integrated(core_storage.py:65). On GB10 that is True; on discrete RTX PRO 6000 it is False. So_reserve_low_window()(core_storage.py:106-108, 127-140) and the floor only matter on cn7/GB10.
#3 [high] Hardware-test essentials: machine fit, harness gap, run commands
HARDWARE FIT
- Defect is unified-memory-only: prepare_allocations discovery + cuPointerGetAttribute(CONTEXT)=0x0 path (capture.rs:1443-1466) and core_storage._reserve_low_window/seal_low_window (core_storage.py:106-108,127-141,161-189) run only when
storage.integratedis True (core_storage.py:65) — GB10 = cn7. cn5 = discrete RTX PRO 6000 (is_integrated False → device_address_floor 0 at runtime_core.py:364) → cn5 can only serve as a discrete no-change regression box. - cn7 has 1 GPU and 10 CPUs / 60 GiB job RAM → single-rank only; multi-rank GB10 not testable with available hardware. cn5 has 4 GPUs but the bug cannot appear there.
HARNESS GAP (why the PR's own test cannot prove the fix)
- New test exports via
RuntimeCore.write(runtime_core.py:108-135): request omitsdiscover_allocations(set only by export_model, :360) anddevice_address_floor(default 0, :98) → capture.rs:1407/1412 discovery branch and :3383 floor check never run. - The test also passes only buffers + graph-pool segments as
allocations(test :223-236); it never declaresdevice-{i}mappings the way export_model does (runtime_core.py:308-310). So flipping discover_allocations=True inwritewould make CoreStorage's own cuMemMap segments fail — the harness must go throughexport_model. - Minimal legitimate contract to reproduce/validate: export_model(prepared, images, storage, path, options={}) with prepared = PreparedExecution whose graphs came from capture_forwards(..., warmup_storage=storage, retain_graphs=True, compile_decoder=False), plus
prepared.server_config = {}andprepared.core_data = None(pattern: helios/tests/fixed_core_fixture.py:159-172; SimpleNamespace variant: tests/preparation/test_persistent.py:281-284). By default runs full discovery: FAIL on main (module MemPool), PASS on head (CoreStorage.warmup_pool).
RUN COMMANDS (AGENTS.md:294-307, pyproject.toml:55-57)
- CPU tier:
.venv/bin/python -m pytest tests/preparation/test_core_storage.py -q(contains new test :83-105) and the 7 CPU files stubbing _seed_warmup_workspaces with 2-arg lambdas (test_capture_stream_isolation.py, test_transient_retention.py, test_capture_graph_metadata.py, test_capture_rank_readiness.py, test_capture_roce_wait.py, test_forward_compile_options.py, test_preparation_reclamation.py). - GPU tier:
CUDA_VISIBLE_DEVICES=0 FLARE_RUN_CUDA_TESTS=1 .venv/bin/python -m pytest tests/preparation/test_capture_cublas_workspace_cuda.py tests/preparation/test_recorded_export_graph_cuda.py -q(file-level skip at test_capture_cublas_workspace_cuda.py:22; subprocess timeout 120 s at :143). - A/B baseline:
git worktree add ../flare-main origin/mainand run the same harness there with the venv.
ENV / BUILD RISK on cn7 (arm64): needs torch 2.14.1+cu132 aarch64 + uv sync --extra prepare + uv pip install --no-deps ./heliopause (heliopause/pyproject.toml maturin, features server+extension-module). Build failure = abort (AGENTS.md:249-266). Integrated host_allocate locks pages (core_storage.py:460-461) → needs RLIMIT_MEMLOCK headroom (CI raises to 64 MiB: .github/workflows/native-serving.yml:61-62).
- Recipes are external (local-inference-lab/hyperflare-recipes), so
ignition export qwen3.8-27bneeds that package + a cached checkpoint; the machine listings show 0 GiB for all models → an end-to-end recipe export implies a multi-GB download plus full tuning/compile on 10 CPUs. - No performance claim in the PR (correctness fix): the only quantitative deltas to measure are retained bytes (~2 MiB operand segment, up to ~32 MiB cuBLASLt workspace) and export wall time; no benchmark suite should be run.
#4 [high] Ready-to-run A/B harness: export_model reproduction of the GB10 defect
Why this harness (not the PR's test): the PR's CUDA test exports through RuntimeCore.write, which never sets discover_allocations (only export_model, runtime_core.py:360) and leaves device_address_floor=0 (default :98 vs :364), so capture.rs:1407-1468 and :3383-3389 never execute. torch.cuda.MemPool() segments are themselves VMM (cuMemCreate/cuMemMap, recorded as memory="device" at recorder.rs:467-478), so cuPointerGetAttribute(CONTEXT) returns 0x0 for them — that is the quoted GB10 error — while CoreStorage's own segments are declared as device-{i} allocations (runtime_core.py:308-310) and the containment test at capture.rs:1437-1441 skips them.
Harness (save as /tmp/warmup_export_repro.py; run from repo root in .venv):
import sys
from contextlib import nullcontext
from pathlib import Path
from types import SimpleNamespace
import torch
from ignition.preparation.capture import capture_forwards
from ignition.preparation.core_storage import CoreStorage
from ignition.preparation.execution import GraphSignature, PreparedExecution
from ignition.preparation.module_images import ModuleImages
from ignition.preparation.runtime_core import export_model
out = Path(sys.argv[1]); out.mkdir(parents=True, exist_ok=True)
with ModuleImages() as images:
torch.cuda.set_device(0)
prev = torch.backends.cuda.preferred_blas_library()
torch.backends.cuda.preferred_blas_library("cublaslt")
try:
storage = CoreStorage() # integrated=True on GB10 -> floor + low-window seal active
with storage:
src = torch.randn((512, 512), device="cuda", dtype=torch.bfloat16)
w = torch.randn((512, 512), device="cuda", dtype=torch.bfloat16)
o = torch.empty_like(src)
frame = torch.zeros(1, device="cuda", dtype=torch.int32)
seq = torch.zeros(1, device="cuda", dtype=torch.int64)
rec = torch.zeros((2, 1, 24), device="cuda", dtype=torch.int64)
def forward(): torch.mm(src, w, out=o)
stream = torch.cuda.Stream()
graphs, _ = capture_forwards({"decode": forward}, {"decode": GraphSignature("decode", 1, 1)},
session=SimpleNamespace(capture=nullcontext), device=0, stream=stream,
pool=storage.graph_pool.id, warmup_storage=storage,
retain_graphs=True, compile_decoder=False)
try:
prep = PreparedExecution(device=0, graphs=graphs,
buffers=dict(source=src, weight=w, output=o, frame_index=frame,
submission_sequence=seq, completion_records=rec),
max_active=1, signatures={"decode": GraphSignature("decode", 1, 1, ("source",))})
prep.server_config = {}
prep.core_data = None
core = export_model(prep, images, storage, out / "rank.json",
options={}, bundle_only=True) # full discovery + floor, no server contract
warm = storage.warmup_pool() if hasattr(storage, "warmup_pool") else None
addrs = [(a.name, a.address, a.nbytes) for a in core.allocations]
print("EXPORT_OK")
print("allocations:", len(addrs))
print("external:", core.external)
if warm is not None:
for seg in torch.cuda.memory_snapshot(warm.id, include_traces=False):
inside = any(a[1] <= seg["address"] and seg["address"] + seg["total_size"] <= a[1] + a[2]
for a in addrs)
covered = any(a[1] <= seg["address"] < a[1] + a[2] for a in addrs)
print(f"warmup segment {seg['address']:#x}+{seg['total_size']} declared={inside} exported={covered}")
finally:
for g in graphs.values(): g.reset()
finally:
torch.backends.cuda.preferred_blas_library(prev)
Expected: main = RuntimeError "external allocation 0x... is not device memory in the serving context" (capture.rs:1461-1466); head = EXPORT_OK, external: [], every warmup segment declared=True exported=False.
Note: bundle_only=True keeps server metadata out of validation (runtime_core.py:332,366); it does not skip prepare_allocations/reachability. Drop it only if a full metadata export is wanted.
Fallbacks: if PreparedExecution rejects the bundle, reuse helios/tests/fixed_core_fixture.py:159-172 verbatim. If bundle_only signature differs, pass options={} and a minimal server_config from helios/tests/fixture_frontend.py server_config(root).
Mount the cached test corpus (<1 s each) since scratch is 16 GiB; nothing here needs a checkpoint.
#5 [high] Interpretation caveats: main may not reproduce; reported GB10 details
Honesty caveats to carry into the report:
- The PR's quoted GB10 failure ("external allocation 0x4000000000+2097152 is not device memory in the serving context ... context 0x0") has never been reproduced in CI (no Python/CUDA pytest job; .github/workflows/native-serving.yml runs Rust only), and on
mainthe module-level pool (torch.cuda.MemPool()with no allocator, capture.py:71) takes segments from the default caching allocator, which may be cudaMalloc-backed (valid context → check passes) rather than VMM. So Step 0 of the plan must attempt reproduction onmainbefore anything else; ifmainpasses the export_model harness on cn7, the defect is not reproducible on our hardware and the change cannot be validated here (report INCONCLUSIVE, escalate to the author for their exact GB10 command/log), rather than burning GPU time on the rest. - Fallback stronger evidence path if main reproduces only intermittently: check
torch.cuda.memory_snapshot()of_capture._warmup_pools[0](itssegment_type/pool id) and the recordedimages.allocationsaddresses vsstorage.mappings— an address in a cuMemMap segment outsidestorage.mappingsis the exact predicate capture.rs:1437-1441 tests. - No speedup claim exists in PR #606: it is a correctness fix (+12/−0 core_storage.py, +16/−7 capture.py). Any "performance" expectation is memory retention only: one 2 MiB operand segment plus up to ~32 MiB cuBLASLt workspace moving from an unmanaged module pool into CoreStorage's VMM arena (retention moved, not added). Do not run ignition bench or flare run benchmarking for this PR.
- cn7 has 1 GPU + 10 CPUs + 60 GiB RAM + 16 GiB scratch: single-rank exports only; multi-rank GB10 (the TP path in rank_group.py/host_ranks.py, which also calls capture_forwards with warmup_storage) is NOT testable with the available hardware — say so explicitly.
- cn5 (4× RTX PRO 6000, discrete, is_integrated False) cannot hit the code path: device_address_floor is 0 (runtime_core.py:364) and _reserve_low_window/seal_low_window are no-ops (core_storage.py:167). Its only value is a no-regression check that non-integrated export is unchanged, and that can be done in one short run.