Skip to content

Export CUDA graph templates without holding executable instances - #245

Closed
voipmonitor wants to merge 1 commit into
mainfrom
astra/k31-retained-graph-export
Closed

voipmonitor wants to merge 1 commit into
mainfrom
astra/k31-retained-graph-export

Conversation

@voipmonitor

Copy link
Copy Markdown
Collaborator

Preparing a large CUDA graph catalog can run out of device memory while instantiating executables that export never uses. Export needs graph templates and their instantiation flags; Helios creates its own executable instances when it loads a core. Avoiding the preparatory instances removes that duplicate residency without changing what serving executes.

Retained capture now records the supported instantiation flags and keeps the graph templates without creating executable handles. A separate export-manifest check validates templates, buffers and contexts; native replay still requires executables. Heliopause accepts exactly one source of flags: an existing executable or explicitly recorded flags. Non-retained capture keeps its existing executable path. The serialized core format and native launch policy are unchanged.

The implemented benefit is lower graph memory during export. This PR does not claim a serving-speed improvement or an isolated full-model memory measurement. Heliopause must be rebuilt for the Python API change; previously exported cores remain readable without re-export.

Validation on Flare main 8c2e782d with this change, Torch 2.14.1+cu132 and SM120: 42 focused CPU tests and nine GPU tests passed. They cover template/executable validation, flags 0/1/8/9, tensor-parallel readiness and capture construction order. Four standalone fixed-address native replay cases also passed: both 64 GiB and 64 MiB shard caps, with Python exit or direct executable handover. Two GEMM fixture cases were blocked before export by a hardcoded CUDA kernel parameter-size assertion in helios/tests/runtime_core_fixture.py:112. That fixture is byte-identical to main 8c2e782d; its assertion precedes RuntimeCore construction and export. These two cases do not establish native replay compatibility. The fixture subprocesses used NVCC_PREPEND_FLAGS="-ccbin=/usr/bin/g++-13" to select the installed host compiler explicitly.

python -m pytest -q tests/preparation/test_runtime_core.py \
  tests/preparation/test_capture_rank_readiness.py \
  tests/preparation/test_graph_bundle.py \
  tests/preparation/test_capture_selection.py \
  tests/preparation/test_capture_progress.py

Large captured catalogues can exhaust device memory while instantiating graph
executables that export does not need. Export needs the graph templates and
their launch policy; native serving constructs its own executable instances.

Retained capture records supported instantiation flags without instantiating
executables. Export validates graph templates, buffers and context through a
separate manifest; native replay still requires executable handles. Heliopause
accepts exactly one flags source, either a live executable or explicit flags,
and retains the existing serialized graph format. Tensor-parallel readiness
and the native diagnostic use the corresponding resource contract.

The change removes duplicate executable residency during preparation without
changing serving arithmetic or core compatibility. On main 8c2e782, 42 focused CPU tests and nine SM120 GPU tests pass, covering
template/executable validation, flags 0/1/8/9, and captured construction order.
The implementation before the core/API rename also passed standalone native
replay fixtures; full-model native qualification of this port is separate.

Design-Signed-Off-By: Codex (GPT-6); design-review=cfcf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant