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 function

kpool_compress_kernel

def kpool_compress_kernel[dtype: DType, KLayoutType: TensorLayout, k_origin: ImmOrigin, GateLayoutType: TensorLayout, gate_origin: ImmOrigin, ApeLayoutType: TensorLayout, ape_origin: ImmOrigin, IROLayoutType: TensorLayout, iro_origin: ImmOrigin, PROLayoutType: TensorLayout, pro_origin: ImmOrigin, CacheLenLayoutType: TensorLayout, OutLayoutType: TensorLayout, out_origin: MutOrigin, head_dim: Int, kpool: Int](pooled: TileTensor[dtype, OutLayoutType, out_origin], k: TileTensor[dtype, KLayoutType, k_origin], gate: TileTensor[dtype, GateLayoutType, gate_origin], ape: TileTensor[.float32, ApeLayoutType, ape_origin], input_row_offsets: TileTensor[.uint32, IROLayoutType, iro_origin], pool_row_offsets: TileTensor[.uint32, PROLayoutType, pro_origin], cache_lengths: TileTensor[.uint32, CacheLenLayoutType, ImmutAnyOrigin])

Builds one pooled key per block; one thread per channel.

Parameters:

  • ​dtype (DType): Element type of k, gate and pooled.
  • ​KLayoutType (TensorLayout): Layout of k.
  • ​k_origin (ImmOrigin): Origin of k.
  • ​GateLayoutType (TensorLayout): Layout of gate.
  • ​gate_origin (ImmOrigin): Origin of gate.
  • ​ApeLayoutType (TensorLayout): Layout of ape.
  • ​ape_origin (ImmOrigin): Origin of ape.
  • ​IROLayoutType (TensorLayout): Layout of input_row_offsets.
  • ​iro_origin (ImmOrigin): Origin of input_row_offsets.
  • ​PROLayoutType (TensorLayout): Layout of pool_row_offsets.
  • ​pro_origin (ImmOrigin): Origin of pool_row_offsets.
  • ​CacheLenLayoutType (TensorLayout): Layout of cache_lengths.
  • ​OutLayoutType (TensorLayout): Layout of pooled.
  • ​out_origin (MutOrigin): Origin of pooled.
  • ​head_dim (Int): Channels per key; also the block width.
  • ​kpool (Int): Tokens per pool.

Args:

Was this page helpful?