Mojo function
k_matmul_ragged_paged_scale
k_matmul_ragged_paged_scale[dtype: DType, weight_dtype: DType, scale_dtype: DType, target: StringSlice[StaticConstantOrigin], scales_granularity_mnk: IndexList[3]](hidden_state: LayoutTensor[dtype, element_layout=hidden_state.element_layout, layout_int_type=hidden_state.layout_int_type, linear_idx_type=hidden_state.linear_idx_type, masked=hidden_state.masked, alignment=hidden_state.alignment], input_row_offsets: LayoutTensor[DType.uint32, element_layout=input_row_offsets.element_layout, layout_int_type=input_row_offsets.layout_int_type, linear_idx_type=input_row_offsets.linear_idx_type, masked=input_row_offsets.masked, alignment=input_row_offsets.alignment], weight: LayoutTensor[weight_dtype, element_layout=weight.element_layout, layout_int_type=weight.layout_int_type, linear_idx_type=weight.linear_idx_type, masked=weight.masked, alignment=weight.alignment], input_scale: LayoutTensor[scale_dtype, element_layout=input_scale.element_layout, layout_int_type=input_scale.layout_int_type, linear_idx_type=input_scale.linear_idx_type, masked=input_scale.masked, alignment=input_scale.alignment], weight_scale: LayoutTensor[scale_dtype, element_layout=weight_scale.element_layout, layout_int_type=weight_scale.layout_int_type, linear_idx_type=weight_scale.linear_idx_type, masked=weight_scale.masked, alignment=weight_scale.alignment], kv_collection: PagedKVCacheCollection, layer_idx: UInt32, ctx: DeviceContextPtr)
Performs a matmul, writing the output into a mutable PagedKVCacheCollection object.
Args:
- βhidden_state (
LayoutTensor[dtype, element_layout=hidden_state.element_layout, layout_int_type=hidden_state.layout_int_type, linear_idx_type=hidden_state.linear_idx_type, masked=hidden_state.masked, alignment=hidden_state.alignment]): Tensor with shape (sum(seq_lens), num_heads * head_size). - βinput_row_offsets (
LayoutTensor[DType.uint32, element_layout=input_row_offsets.element_layout, layout_int_type=input_row_offsets.layout_int_type, linear_idx_type=input_row_offsets.linear_idx_type, masked=input_row_offsets.masked, alignment=input_row_offsets.alignment]): Tensor with shape (batch_size + 1,) denoting the start of each sequence along the seq_len dimension. - βweight (
LayoutTensor[weight_dtype, element_layout=weight.element_layout, layout_int_type=weight.layout_int_type, linear_idx_type=weight.linear_idx_type, masked=weight.masked, alignment=weight.alignment]): Tensor with shape (num_heads * head_size, num_kv_heads * head_size). - βinput_scale (
LayoutTensor[scale_dtype, element_layout=input_scale.element_layout, layout_int_type=input_scale.layout_int_type, linear_idx_type=input_scale.linear_idx_type, masked=input_scale.masked, alignment=input_scale.alignment]): Scale to be multiplied to the input Tensor. - βweight_scale (
LayoutTensor[scale_dtype, element_layout=weight_scale.element_layout, layout_int_type=weight_scale.layout_int_type, linear_idx_type=weight_scale.linear_idx_type, masked=weight_scale.masked, alignment=weight_scale.alignment]): Scale to be multiplied to the weight Tensor. - βkv_collection (
PagedKVCacheCollection): The historical KVCache for keys and values. The KVCache for this layer is retrieved via layer_idx. - βlayer_idx (
UInt32): The index of the layer being executed. Used to retrieve the KVCache for the given layer from kv_collection. - βctx (
DeviceContextPtr): The call context pointer, passed by the graph compiler.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!