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 function
dispatch_mask
def dispatch_mask[mask_type: String, callback_fn: def[mask_t: MHAMask](mask: mask_t) raises capturing thin -> None, local_window_size: Int = Int(-1)]()
Instantiate an MHAMask by name and invoke a callback with it.
Resolves the mask string to one of the built-in MHAMask implementations
at compile time and calls callback_fn with a concrete mask instance.
This lets callers write mask-agnostic kernels while still specialising the
generated code per mask type.
Parameters:
- โmask_type (
String): Name of the mask (e.g."causal","null","sliding_window_causal"). Must match one of theMaskNameconstants. - โcallback_fn (
def[mask_t: MHAMask](mask: mask_t) raises capturing thin -> None): Parametric callback invoked with the resolved mask. - โlocal_window_size (
Int): Sliding-window or chunk size for masks that require it. Must be-1for masks that ignore it and positive for masks that require it.
Raises:
Compile-time assertion error if mask_type is unrecognised or if
local_window_size is inconsistent with the selected mask.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!