warp.launch#

warp.launch(
kernel,
dim,
inputs=[],
outputs=[],
adj_inputs=[],
adj_outputs=[],
device=None,
stream=None,
adjoint=False,
record_tape=True,
record_cmd=False,
max_blocks=0,
block_dim=256,
)[source]#

Launch a Warp kernel on the target device

Kernel launches are asynchronous with respect to the calling Python thread.

The default warp.config.LaunchArrayAccessMode.RELAXED mode does not check whether array arguments are accessible from the launch device. Cross-device access depends on the access direction, memory kind, and system capabilities. An inaccessible array may cause a segmentation fault in a CPU kernel or a CUDA illegal memory access. Set warp.config.launch_array_access_mode to warp.config.LaunchArrayAccessMode.CHECKED to detect known-invalid accesses before launch. Use warp.config.LaunchArrayAccessMode.STRICT to require every Warp array argument to be allocated on the launch device, including cross-device allocations the hardware could access. See Checked Launch Validation for details and limitations.

Parameters:
  • kernel – The name of a Warp kernel function, decorated with the @warp.kernel decorator

  • dim (int | Sequence[int]) – The number of threads to launch the kernel, can be an integer or a sequence of integers with a maximum of 4 dimensions.

  • inputs (Sequence) – The input parameters to the kernel (optional)

  • outputs (Sequence) – The output parameters (optional)

  • adj_inputs (Sequence) – The adjoint inputs (optional)

  • adj_outputs (Sequence) – The adjoint outputs (optional)

  • device (Device | str | None) – The device to launch on.

  • stream (Stream | None) – The stream to launch on.

  • adjoint (bool) – Whether to run forward or backward pass (typically use False).

  • record_tape (bool) – When True, the launch will be recorded the global warp.Tape object when present.

  • record_cmd (bool) – When True, the launch will return a Launch object. The launch will not occur until the user calls Launch.launch().

  • max_blocks (int) – The maximum number of CUDA thread blocks to use. Requires a grid-stride loop, which is the default. Launching a kernel that opted into the lean launch path with @warp.kernel(grid_stride=False) and max_blocks > 0 raises a RuntimeError.

  • block_dim (int) – The number of threads per block (always 1 for “cpu” devices).