warp.capture_load_from_bytes#

warp.capture_load_from_bytes(data, modules=None, device=None)[source]#

Load a serialized graph from in-memory bytes.

data holds the contents of a .wrp file written by capture_save(), and modules holds the contents of the files in its companion <stem>_modules/ directory. The returned graph behaves the same as one returned by capture_load(). Warp copies everything it needs while loading, so the caller may release the buffers once this returns.

Parameters:
  • data – The .wrp file contents as a bytes-like object, such as bytes, bytearray, memoryview, or a C-contiguous NumPy array.

  • modules (Mapping[str, Any] | None) – Maps each module filename written to <stem>_modules/ by capture_save(), without a directory prefix, to the file’s contents as a bytes-like object. Entries the graph does not use are ignored. May be omitted when the graph launches no kernels.

  • device (Device | str | None) – The device to load the graph onto. Must have the same device family (CPU or CUDA) as the saved graph.

Returns:

A Graph object that can be launched with capture_launch().

Raises:
  • TypeError – If data or a module’s contents are not bytes-like, modules is not a mapping, or a module name is not a string.

  • ValueError – If data or a module’s contents are not a C-contiguous buffer.

  • RuntimeError – If data is malformed, or a module the graph uses is missing or fails to load.

Return type:

Graph