IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Mojo struct

Struct_mha_ragged_paged_fp8_kv

struct Struct_mha_ragged_paged_fp8_kv

MHA with bf16 Q and fp8_e4m3fn paged KV cache (dequant-staging path).

Dequantizes the fp8 KV blocks to a bf16 staging buffer using per-block float32 scales, then calls the standard bf16 flash attention kernel on the staging buffer.

Implemented traitsโ€‹

AnyType, ImplicitlyDestructible

Methodsโ€‹

executeโ€‹

static def execute[scale_dtype: DType, //, quantization_granularity: Int, target: StringSlice[StaticConstantOrigin], mask_str: StringSlice[StaticConstantOrigin], local_window_size: Int = -1](output: ManagedTensorSlice[Output, static_spec=output.static_spec], q: ManagedTensorSlice[Input, static_spec=q.static_spec], input_row_offsets: ManagedTensorSlice[Input, static_spec=input_row_offsets.static_spec], kv_blocks: ManagedTensorSlice[MutableInput, static_spec=kv_blocks.static_spec], cache_lengths: ManagedTensorSlice[Input, static_spec=cache_lengths.static_spec], kv_lookup_table: ManagedTensorSlice[Input, static_spec=kv_lookup_table.static_spec], max_lengths: ManagedTensorSlice[Input, static_spec=max_lengths.static_spec], kv_scales: ManagedTensorSlice[MutableInput, static_spec=kv_scales.static_spec], layer_idx: UInt32, scale: Float32, mha_decode_dispatch_metadata: ManagedTensorSlice[Input, static_spec=mha_decode_dispatch_metadata.static_spec], ctx: DeviceContext)