warp.load_module#
- warp.load_module(
- module=None,
- device=None,
- recursive=False,
- block_dim=None,
- max_workers=None,
Force a user-defined module to be compiled and loaded.
This is the recommended way to explicitly load modules that contain Warp code. It accepts Python module references (module object, module name string, or Warp
Module) and provides convenient options for loading submodules recursively.Modules containing Warp code are typically loaded automatically on first kernel launch, so this function is mainly useful for:
Preloading modules to avoid JIT compilation delays during runtime
Loading modules in controlled environments (e.g. testing, profiling)
Ensuring modules are compiled before specific operations (e.g. CUDA graph capture)
Loading a module hierarchy with the
recursiveoption
The Python module must be imported and contain at least one Warp kernel, function, or struct definition to be loadable.
- Parameters:
module (Module | ModuleType | str | None) – The module to load. Can be a Python module object, module name string, or Warp
Module. IfNone, loads the module that called this function.device (Device | str | list[Device] | list[str] | None) – The device or list of devices to load the module on. If
None, load on all devices.recursive (bool) – Whether to load submodules. For example, if the given module is
warp.render, this will also loadwarp.render.utilsandwarp.render.opengl.block_dim (int | None) – The number of threads per block (always 1 for
"cpu"devices).max_workers (int | None) – The maximum number of parallel threads to use for loading modules.
0means serial loading. IfNone,`warp.config.load_module_max_workersdetermines the default.
- Raises:
RuntimeError – If the specified module does not contain any Warp kernels, functions, or structs, or has not been imported yet.
TypeError – If the module argument is not a valid module type.