Mojo function
top_p_sampling_gpu
top_p_sampling_gpu[dtype: DType, out_idx_type: DType, //, _test_sort: Bool = False](ctx: DeviceContext, top_ps: TileTensor[dtype, LayoutType, origin, address_space=address_space, linear_idx_type=linear_idx_type, element_shape_types=element_shape_types], input_logits: TileTensor[dtype, LayoutType, origin, linear_idx_type=linear_idx_type, element_shape_types=element_shape_types], out_token_ids: TileTensor[out_idx_type, LayoutType, origin, linear_idx_type=linear_idx_type, element_shape_types=element_shape_types], temperature: Scalar[dtype] = 1)
GPU implementation of Top-P sampling for token selection. This function applies temperature scaling, softmax, a radix sort, and then samples tokens based on the cumulative probability mass (Top-P).
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!