warp.ScopedCapture#

class warp.ScopedCapture(
device=None,
stream=None,
force_module_load=None,
external=False,
apic=False,
)[source]#

Context manager to capture a sequence of operations into a graph.

Captures kernel launches, memory copies, and memsets for later replay with reduced launch overhead. Works on both CPU and CUDA devices. The captured graph is available as the graph attribute after exiting the context.

Parameters:
  • device (DeviceLike) – Device on which to capture operations (CPU or CUDA).

  • stream – Stream on which to capture operations (CUDA only).

  • force_module_load – If True, force all modules to load before capture begins.

  • external – If True, indicates an external graph capture is already active.

  • apic (bool) – If True, enable APIC recording for serialization via capture_save(). On CPU, recording always occurs regardless of this flag (needed for CPU graph replay). Default is False.

graph#

The captured graph, available after context exit.

active#

Whether capture is currently in progress.

Example

with warp.ScopedCapture() as capture:
    warp.launch(my_kernel, dim=n, inputs=[arr])

# Replay the captured graph
warp.capture_launch(capture.graph)
__init__(
device=None,
stream=None,
force_module_load=None,
external=False,
apic=False,
)[source]#
Parameters:

Methods

__init__([device, stream, ...])