IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Mojo struct

WaitHostValue

struct WaitHostValue

Stalls the stream until a host-visible flag reaches a given value.

Lowers to CUDA's cuStreamWaitValue64 via DeviceStream.wait_for_host_value. Accepts a 1-D int64 buffer of shape [2], mirroring mo.launch_host_func's payload shape:

  • payload[0]: raw address of a M::Driver::CompletionFlag (as u64). Typically obtained from max.driver.CompletionFlag._unsafe_ptr and packed into the buffer by the Python caller; the C++ object must outlive any graph execution that references it.
  • payload[1]: the 64-bit value to wait for (the int64 element is reinterpreted as a u64).

Captures cleanly into a CUDA graph as a wait-value / batch-mem-op node, so this op can sit inside a captured forward graph just before the sampling kernel to gate the sampler on the bitmask compute finishing while the rest of the forward body runs concurrently. Currently only CUDA streams support stream memory ops; 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)