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

FlashAttentionAlgorithm

struct FlashAttentionAlgorithm

Identifies which flash-attention algorithm variant to use for a kernel launch.

The four variants range from a naive reference implementation to the latest warp-specialized FA3 pipeline. The default constructed value is FLASH_ATTENTION_3. Use init() to resolve an unspecified (-1) value to the best algorithm for the target dtype and GPU architecture.

Implemented traits

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

comptime members

FLASH_ATTENTION_1

comptime FLASH_ATTENTION_1 = FlashAttentionAlgorithm(Int(1))

FLASH_ATTENTION_2

comptime FLASH_ATTENTION_2 = FlashAttentionAlgorithm(Int(2))

FLASH_ATTENTION_3

comptime FLASH_ATTENTION_3 = FlashAttentionAlgorithm(Int(3))

NAIVE

comptime NAIVE = FlashAttentionAlgorithm(Int(0))

Methods

__init__

def __init__() -> Self

def __init__(value: Int) -> Self

__eq__

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

Returns:

Bool

def __eq__(self, version: Int) -> Bool

Returns:

Bool

__ne__

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

Returns:

Bool

init

def init(self, dtype: DType) -> Self

write_to

def write_to(self, mut writer: T)