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

naively_compute_total_iters

def naively_compute_total_iters[MaskType: MHAMask, //, BM: Int, BN: Int](mask: MaskType, seq_id: UInt32, q_row: UInt32, end: UInt32) -> UInt32

Count the non-fully-masked KV tile iterations for a query row by linear scan.

Walks every BN-wide column tile from 0 to end, calling mask.status() for each and counting tiles that are not TileMaskStatus.FULL_MASK. Intended as a reference fallback for mask types that do not implement a closed-form total_iters().

Parameters:

  • ​MaskType (MHAMask): Concrete MHAMask implementation to query.
  • ​BM (Int): Query tile height (number of query rows per block).
  • ​BN (Int): Key tile width (number of key columns per block).

Args:

  • ​mask (MaskType): The mask instance.
  • ​seq_id (UInt32): Sequence/batch index.
  • ​q_row (UInt32): Starting query-row index of the current query tile.
  • ​end (UInt32): Exclusive upper bound on key column indices.

Returns:

UInt32: The number of KV tiles in [0, end) that are not fully masked.

Was this page helpful?