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 function

generic_flare_mla_decompress_k_cache_ragged_paged

def generic_flare_mla_decompress_k_cache_ragged_paged[target: StringSlice[ImmStaticOrigin], dtype: DType](buffer_row_offsets_1d: LayoutTensor[DType.uint32, element_layout=buffer_row_offsets_1d.element_layout, layout_int_type=buffer_row_offsets_1d.layout_int_type, linear_idx_type=buffer_row_offsets_1d.linear_idx_type, masked=buffer_row_offsets_1d.masked, alignment=buffer_row_offsets_1d.alignment], cache_offsets_1d: LayoutTensor[DType.uint32, element_layout=cache_offsets_1d.element_layout, layout_int_type=cache_offsets_1d.layout_int_type, linear_idx_type=cache_offsets_1d.linear_idx_type, masked=cache_offsets_1d.masked, alignment=cache_offsets_1d.alignment], buffer_length: Int32, weight: LayoutTensor[dtype, element_layout=weight.element_layout, layout_int_type=weight.layout_int_type, linear_idx_type=weight.linear_idx_type, masked=weight.masked, alignment=weight.alignment], kv_collection: PagedKVCacheCollection[scale_dtype_=kv_collection.scale_dtype_, quantization_granularity_=kv_collection.quantization_granularity_], layer_idx: UInt32, k_latent_buffer: LayoutTensor[dtype, element_layout=k_latent_buffer.element_layout, layout_int_type=k_latent_buffer.layout_int_type, linear_idx_type=k_latent_buffer.linear_idx_type, masked=k_latent_buffer.masked, alignment=k_latent_buffer.alignment], k_buffer: LayoutTensor[dtype, element_layout=k_buffer.element_layout, layout_int_type=k_buffer.layout_int_type, linear_idx_type=k_buffer.linear_idx_type, masked=k_buffer.masked, alignment=k_buffer.alignment], context: DeviceContext)

Decompresses MLA latent K cache rows into a full K buffer via a matmul.

Gathers compressed latent K vectors from the paged KV cache into k_latent_buffer using buffer_row_offsets and cache_offsets, then multiplies by the down-projection weight to produce the decompressed K buffer.

Parameters:

  • ​target (StringSlice[ImmStaticOrigin]): Target device string for kernel dispatch; must be a GPU target.
  • ​dtype (DType): Data type of the weight and K buffers (inferred).

Args: