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

Aliases

  • apply_log2e_after_mask = False:
  • mask_out_of_bound = True:
  • mask_safe_out_of_bounds = True:

Implemented traits

AnyType, Copyable, ExplicitlyCopyable, MHAMask, Movable, UnknownDestructibility

Methods

mask

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

status

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

Was this page helpful?