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

sparse_kv_row

def sparse_kv_row[physical_indices: Bool](kv_lut: T, batch_idx: UInt32, index: Int32) -> Int32

Returns the KV TMA row a sparse index names, or -1 for an unused slot.

Parameters:

  • ​physical_indices (Bool): Whether index is an already-paged physical_block * page_size + offset row (the indexer's physical rows, or latent sparse attention's flat rows) rather than a token position within batch_idx's entry.

Args:

  • ​kv_lut (T): Cache operand the index addresses.
  • ​batch_idx (UInt32): Batch entry the index belongs to; unread when physical_indices.
  • ​index (Int32): The sparse index, -1 for an unused slot.

Returns:

Int32: The TMA row, or -1.

Was this page helpful?