Skip to main content
Log in

Mojo struct

ChunkedMask

@register_passable(trivial) struct ChunkedMask[local_window_size: Int]

Mask implementing Chunked attention.

This groups the mask into chunks of size local_window_size. Considering the following case:

  • Q_len = 7
  • K_len = 10
  • local_window_size = 4

The mask will be applied as follows: K > 0 1 2 3 4 5 6 7 8 9 Q v x--------------------x 0 | 1 1 1 1 0 0 0 0 0 0 1 | 0 0 0 0 1 1 1 1 0 0 2 | 0 0 0 0 1 1 1 1 0 0 3 | 0 0 0 0 1 1 1 1 0 0 4 | 0 0 0 0 1 1 1 1 0 0 5 | 0 0 0 0 0 0 0 0 1 1 6 | 0 0 0 0 0 0 0 0 1 1

Implemented traits

AnyType, Copyable, ExplicitlyCopyable, MHAMask, Movable, UnknownDestructibility

Aliases

apply_log2e_after_mask

alias apply_log2e_after_mask = False

mask_out_of_bound

alias mask_out_of_bound = True

mask_safe_out_of_bounds

alias mask_safe_out_of_bounds = True

Methods

mask

mask[type: DType, width: Int, //, *, element_type: DType = uint32](self, coord: IndexList[4, element_type=element_type], score_vec: SIMD[type, width]) -> SIMD[type, width]

status

status[*, element_type: DType = uint32](self, tile_offset: IndexList[2, element_type=element_type], tile_size: IndexList[2, element_type=element_type]) -> TileMaskStatus