warp.capture_begin#
- warp.capture_begin(
- device=None,
- stream=None,
- force_module_load=None,
- external=False,
- apic=False,
- capture_mode=CaptureMode.THREAD_LOCAL,
Begin capture of a graph.
Records supported Warp operations subsequently issued on the selected device. On CUDA devices, the CUDA driver captures operations into a CUDA graph. On CPU devices, operations are recorded into an API Capture (APIC) operation stream, which
capture_launch()replays in C++.If
apic=True, APIC recording is also performed alongside CUDA graph capture, and the result can be serialized to a.wrpfile viacapture_save(). The flag has no effect on CPU (recording is always on there) beyond gating whethercapture_save()is allowed.- Parameters:
device (Device | str | None) – The device to capture on (CUDA or CPU).
stream (Stream | None) – The CUDA stream to capture on (CUDA only).
force_module_load (bool | None) – Whether to force loading of all kernels before capture. In general it is better to use
load_module()to selectively load kernels. When running with CUDA drivers that support CUDA 12.3 or newer, this option is not recommended to be set toTruebecause kernels can be loaded during graph capture on more recent drivers. If this argument isNone, then the behavior inherits fromwarp.config.enable_graph_capture_module_load_by_defaultif the driver is older than CUDA 12.3.external (bool) – Whether the capture was already started externally (CUDA only). The
capture_modeargument should specify the mode that was used to initiate the external capture.apic (bool) – Whether to allow
capture_save()on the captured graph. On CUDA this also enables APIC operation-stream recording during the capture; on CPU, recording happens regardless because it is the only replay mechanism.capture_mode (CaptureMode) – The
CaptureMode(i.e.cudaStreamCaptureMode) used when Warp opens the capture. Defaults toCaptureMode.THREAD_LOCAL. UseCaptureMode.RELAXEDwhen composing with libraries that may call capture-unsafe CUDA runtime APIs during the capture (e.g. lazy context initialization). Ignored on CPU devices.