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
apply_mask_kernel
def apply_mask_kernel[mask_t: MHAMask, ScoresLayoutType: TensorLayout, scores_origin: MutOrigin, VLLayoutType: TensorLayout, vl_origin: ImmOrigin, CLLayoutType: TensorLayout](output: TileTensor[DType.float32, ScoresLayoutType, scores_origin], valid_length: TileTensor[DType.uint32, VLLayoutType, vl_origin], cache_lengths: TileTensor[DType.uint32, CLLayoutType, ImmutAnyOrigin], mask: mask_t, max_num_keys: Int)
Apply causal mask to the output scores.
Parameters:
- βmask_t (
MHAMask): TheMHAMasktype applied to each score coordinate. - βScoresLayoutType (
TensorLayout): Layout of theoutputscores tensor. - βscores_origin (
MutOrigin): Origin of theoutputscores tensor. - βVLLayoutType (
TensorLayout): Layout of thevalid_lengthtensor. - βvl_origin (
ImmOrigin): Origin of thevalid_lengthtensor. - βCLLayoutType (
TensorLayout): Layout of thecache_lengthstensor.
Args:
- βoutput (
TileTensor[DType.float32, ScoresLayoutType, scores_origin]): Score matrix with row stridemax_num_keys, indexed as[global_seq_idx, key_idx]. - βvalid_length (
TileTensor[DType.uint32, VLLayoutType, vl_origin]): Row offsets intooutputper batch, lengthbatch_size + 1. - βcache_lengths (
TileTensor[DType.uint32, CLLayoutType, ImmutAnyOrigin]): Per-batch cached-prefix length used to map a local query index to an absolute position. - βmask (
mask_t): The mask instance applied to each score coordinate. - βmax_num_keys (
Int): Row stride ofoutputand maximum keys per token.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!