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

assert_sparse_row_packed

def assert_sparse_row_packed[sparse_row: SparseRowLayout](d_indices: OptionalReg[Pointer[Int32, MutAnyOrigin]], indices_stride: Int, q_token_idx: Int, visible: Int, selection_lag: Int, sparse_topk: Int)

Asserts that a token's sparse row is packed as sparse_row states.

Only runs with all assertions enabled. A producer that drops a causal key makes the closed-form length overcount, and the softmax then scores the trailing -1 slots as zero keys instead of masking them.

The message is a literal on purpose: formatting runtime values needs a 2 KB local buffer, and CUDA 13.1 ptxas segfaults compiling that callee from a warp-specialized branch after setmaxnreg.

Parameters:

Args:

  • ​d_indices (OptionalReg[Pointer[Int32, MutAnyOrigin]]): The [total_q_tokens, indices_stride] sparse indices.
  • ​indices_stride (Int): Row stride of d_indices.
  • ​q_token_idx (Int): Global index of the token whose row is checked.
  • ​visible (Int): Number of keys the token sees.
  • ​selection_lag (Int): Positions between the token the row was computed for and this one.
  • ​sparse_topk (Int): The kernel's slot count for the sequence.

Was this page helpful?