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
kv_cache_row_offsets_ragged_paged_kernel
def kv_cache_row_offsets_ragged_paged_kernel[CacheRowOffsetsLayoutType: TensorLayout, InputRowOffsetsLayoutType: TensorLayout, CacheLengthsLayoutType: TensorLayout](cache_row_offsets: TileTensor[DType.uint32, CacheRowOffsetsLayoutType, MutUntrackedOrigin], input_row_offsets: TileTensor[DType.uint32, InputRowOffsetsLayoutType, ImmUntrackedOrigin], cache_lengths: TileTensor[DType.uint32, CacheLengthsLayoutType, ImmUntrackedOrigin])
Computes cumulative valid-cache row offsets for one batch index in a ragged prefill batch.
Each thread accumulates the running sum of valid cache lengths plus the ragged sequence deltas for all batches before its output index and writes the result to cache_row_offsets.
Parameters:
- βCacheRowOffsetsLayoutType (
TensorLayout): Memory layout of thecache_row_offsetsoutput tensor. - βInputRowOffsetsLayoutType (
TensorLayout): Memory layout of theinput_row_offsetstensor. - βCacheLengthsLayoutType (
TensorLayout): Memory layout of thecache_lengthstensor.
Args:
- βcache_row_offsets (
TileTensor[DType.uint32, CacheRowOffsetsLayoutType, MutUntrackedOrigin]): Output tensor receiving the cumulative valid-cache row offsets, with shape (batch_size + 1,). - βinput_row_offsets (
TileTensor[DType.uint32, InputRowOffsetsLayoutType, ImmUntrackedOrigin]): Tensor with shape (batch_size + 1,) denoting the start of each sequence along the ragged sequence dimension. - βcache_lengths (
TileTensor[DType.uint32, CacheLengthsLayoutType, ImmUntrackedOrigin]): Tensor with shape (batch_size,) giving the number of valid cached tokens per batch.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!