IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo struct

LaunchHostFunc

struct LaunchHostFunc

Enqueues a pre-packed host callback on the device's default stream.

Corresponds to CUDA's cuLaunchHostFunc. Accepts a 1-D int64 buffer of shape [2] whose elements are raw pointer-sized integers:

  • payload[0]: address of a void (*)(void *) trampoline function.
  • payload[1]: address of an opaque user-data block owned by the trampoline (freed after the callback runs).

Both values are produced by max._core.driver._pack_host_func(fn) on the Python side. Currently only CUDA streams support host callbacks; non-CUDA backends raise at runtime.

Implemented traitsโ€‹

AnyType, ImplicitlyDeletable

Methodsโ€‹

executeโ€‹

static def execute[target: StringSlice[ImmStaticOrigin]](payload: ManagedTensorSlice[IOSpec[_, _].MutableInput, static_spec=payload.static_spec], ctx: DeviceContext)

Was this page helpful?