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 struct

MaskStrategy

struct MaskStrategy

Bit-flag enum that selects the masking strategy for a tile iteration set.

Strategies are combined with bitwise OR. NO_MASK skips masking entirely. COMPUTED calls the mask functor per element. OUT_OF_BOUNDS clips keys at num_keys. BITMASK reads a 32-bit column-visibility mask from MHAMask.mask_bits(), which subsumes the older triangular and OOB strategies for SM100 kernels.

Implemented traits

AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable

comptime members

BITMASK

comptime BITMASK = MaskStrategy(Int32(16))

Mask provides its own 32-bit visibility bitmask per 32-col batch via MHAMask.mask_bits(). Subsumes the historical LOWER_TRIANGULAR / UPPER_TRIANGULAR (and OUT_OF_BOUNDS for masks that fold it into mask_bits).

COMPUTED

comptime COMPUTED = MaskStrategy(Int32(4))

Mask where the call operator must be used to compute the masked value.

NO_MASK

comptime NO_MASK = MaskStrategy(Int32(0))

No mask is to be applied.

OUT_OF_BOUNDS

comptime OUT_OF_BOUNDS = MaskStrategy(Int32(8))

Check if we are out of bounds, e.g. clip at num_keys after a COMPUTED mask. Used in combination with COMPUTED and as the kernel-hardcoded "no mask, just clip" form (e.g. hot-path optimizations in softmax_warp that bypass BITMASK when the runtime mask status is NO_MASK).

Methods

__init__

def __init__(value: Int32) -> Self

__eq__

def __eq__(self, other: Self) -> Bool

Returns:

Bool

__ne__

def __ne__(self, other: Self) -> Bool

Returns:

Bool

__contains__

def __contains__(self, other: Self) -> Bool

Returns:

Bool

__and__

def __and__(self, other: Self) -> Self

__or__

def __or__(self, other: Self) -> Self