warp.capture_save#

warp.capture_save(
graph,
path,
inputs=None,
outputs=None,
source_fallback=False,
)[source]#

Serialize a captured graph to a .wrp file for later replay.

The graph must have been captured with apic=True. For graphs containing recorded kernels, the .wrp file and its companion _modules directory must be kept together. Set source_fallback=True to retain generated CUDA source so a loader can compile a local module when the packaged PTX or CUBIN is incompatible. Otherwise, only compiled binaries are exported.

Parameters:
  • graph (Graph) – A Graph captured with apic=True.

  • path (str) – Output path. Warp adds the .wrp extension if needed and creates <stem>.wrp and <stem>_modules/.

  • inputs (dict | None) – Named input arrays (e.g., {"positions": pos_array}).

  • outputs (dict | None) – Named output arrays (e.g., {"results": result_array}).

  • source_fallback (bool) – Whether to package CUDA source and its compile recipe for recompilation on the replay device. Every captured CUDA module needs its generated .cu file, unchanged since the module was loaded, beside the module binary, and a hashed binary name (strip_hash=True modules are not supported). Known blockers are reported together before writing the artifact. Guest hardware, driver, and compiler compatibility is checked at load time.

Raises:

RuntimeError – If source_fallback=True and any captured CUDA module has missing or changed generated source, an unverified binary name (for example, strip_hash=True), or a source-recompilation dependency that cannot be packaged: caller-provided CUDA include directories, LLVM-CUDA compilation, or LTO-IR/fatbin link inputs.

If the same array appears in both inputs and outputs (e.g., for in-place operations), both names will refer to the same memory region. Updating either via set_param on the loaded graph affects the same data. Each name binds the array’s entire base allocation rather than a view offset. Arrays passed to set_param and get_param must have the same byte capacity as that serialized region.