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 function

dispatch_relative_logits_mask

def dispatch_relative_logits_mask[dtype: DType, layout: Layout, //, callback_fn: def[mask_t: MHAMask](mask: mask_t) raises capturing thin -> None, local_window_size: Int = Int(-1)](bias_nd: LayoutTensor[dtype, layout], cache_lengths: LayoutTensor[DType.uint32, Layout.row_major(Int(-1)), ImmutAnyOrigin], input_row_offsets: LayoutTensor[DType.uint32, Layout.row_major(Int(-1)), ImmutAnyOrigin])

Wrap bias_nd in a RelativeLogitsMask and invoke callback_fn.

Like dispatch_materialized_mask, this carries runtime state (the bias table plus the tensors that recover its ragged-flat row), so it lives outside dispatch_mask's zero-arg string dispatch. local_window_size picks the visibility mask: <= 0 (canonically -1, the graph-level "no window" value) -> CausalMask, else SlidingWindowCausalMask[local_window_size]. The mask structs themselves report "no window" as sliding_window_size() == 0; this function is where the two conventions meet.