warp.Launch#

class warp.Launch(
kernel,
device,
hooks=None,
params=None,
params_addr=None,
bounds=None,
max_blocks=0,
block_dim=256,
adjoint=False,
fwd_args=None,
adj_args=None,
)[source]#

Represent all data required for a kernel launch so that launches can be replayed quickly.

Users should not directly instantiate this class, instead use warp.launch(..., record_cmd=True) to record a launch.

Parameters:
  • device (Device)

  • hooks (KernelHooks | None)

  • params (Sequence[Any] | None)

  • params_addr (Sequence[ctypes.c_void_p] | None)

  • bounds (LaunchBounds | None)

  • max_blocks (int)

  • block_dim (int)

  • adjoint (bool)

  • fwd_args (list[Any] | None)

  • adj_args (list[Any] | None)

__init__(
kernel,
device,
hooks=None,
params=None,
params_addr=None,
bounds=None,
max_blocks=0,
block_dim=256,
adjoint=False,
fwd_args=None,
adj_args=None,
)[source]#
Parameters:
  • device (Device)

  • hooks (KernelHooks | None)

  • params (Sequence[Any] | None)

  • params_addr (Sequence[c_void_p] | None)

  • bounds (launch_bounds_1d_t | launch_bounds_2d_t | launch_bounds_3d_t | launch_bounds_4d_t | None)

  • max_blocks (int)

  • block_dim (int)

  • adjoint (bool)

  • fwd_args (list[Any] | None)

  • adj_args (list[Any] | None)

Methods

__init__(kernel, device[, hooks, params, ...])

launch([stream])

Launch the kernel.

set_dim(dim)

Set the launch dimensions.

set_param_at_index(index, value[, adjoint])

Set a kernel parameter at an index.

set_param_at_index_from_ctype(index, value)

Set a kernel parameter at an index without any type conversion.

set_param_by_name(name, value[, adjoint])

Set a kernel parameter by argument name.

set_param_by_name_from_ctype(name, value)

Set a kernel parameter by argument name with no type conversions.

set_params(values)

Set all parameters.

set_params_from_ctypes(values)

Set all parameters without performing type-conversions.

Attributes

device

The device to launch on.

bounds

The launch bounds.

max_blocks

The maximum number of CUDA thread blocks to use.

block_dim

The number of threads per block.

cluster_dim

The number of CUDA thread blocks per Thread Block Cluster.

adjoint

Whether to run the adjoint kernel instead of the forward kernel.

grid_stride

Whether the kernel uses a grid-stride loop (vs the lean 3D launch).

device: Device#

The device to launch on. This should not be changed after the launch object is created.

bounds: launch_bounds_1d_t | launch_bounds_2d_t | launch_bounds_3d_t | launch_bounds_4d_t#

The launch bounds. Update with set_dim().

max_blocks: int#

The maximum number of CUDA thread blocks to use.

block_dim: int#

The number of threads per block.

cluster_dim: int#

The number of CUDA thread blocks per Thread Block Cluster.

adjoint: bool#

Whether to run the adjoint kernel instead of the forward kernel.

grid_stride: bool#

Whether the kernel uses a grid-stride loop (vs the lean 3D launch). Selects the grid shape.

set_dim(dim)[source]#

Set the launch dimensions.

Parameters:

dim (int | list[int] | tuple[int, ...]) – The dimensions of the launch.

Raises:

RuntimeError – If the kernel is not grid-stride and the new dimensions exceed the lean 3D grid capacity (~7e16 work items). Decorate the kernel with @warp.kernel(grid_stride=True) to support launch dimensions this large.

set_param_at_index(index, value, adjoint=False)[source]#

Set a kernel parameter at an index.

Parameters:
  • index (int) – The index of the param to set.

  • value (Any) – The value to set the param to.

  • adjoint (bool)

set_param_at_index_from_ctype(index, value, adjoint=False)[source]#

Set a kernel parameter at an index without any type conversion.

Parameters:
  • index (int) – The index of the param to set.

  • value (Structure | int | float) – The value to set the param to.

  • adjoint (bool) – If True, target the adjoint half of the param packet.

Note

This method does not perform warp-level type conversion, so it should not be used on array-typed parameters during CPU APIC capture. APIC relocation metadata requires the original warp.array objects stored in fwd_args to track region IDs; passing a raw ctype struct bypasses that. Use set_param_at_index() instead when a CPU APIC capture is active.

set_param_by_name(name, value, adjoint=False)[source]#

Set a kernel parameter by argument name.

Parameters:
  • name (str) – The name of the argument to set.

  • value (Any) – The value to set the argument to.

  • adjoint (bool) – If True, set the adjoint of this parameter instead of the forward parameter.

set_param_by_name_from_ctype(name, value)[source]#

Set a kernel parameter by argument name with no type conversions.

Parameters:
  • name (str) – The name of the argument to set.

  • value (Structure) – The value to set the argument to.

set_params(values)[source]#

Set all parameters.

Parameters:

values (Sequence[Any]) – A list of values to set the params to.

set_params_from_ctypes(values)[source]#

Set all parameters without performing type-conversions.

Parameters:

values (Sequence[Structure]) – A list of ctypes or basic int / float types.

launch(stream=None)[source]#

Launch the kernel.

Parameters:

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

Return type:

None