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
quantize_tensor_dynamic_scaled_fp8
def quantize_tensor_dynamic_scaled_fp8[out_dtype: DType, in_dtype: DType, scales_dtype: DType, InputFnType: def[width: Int, alignment: Int](row: Int, col: Int) -> SIMD[in_dtype, width] & ImplicitlyCopyable & RegisterPassable, //, group_size_or_per_token: Int, num_cols: Int, pdl_level: PDLLevel = PDLLevel.ON](input_fn: InputFnType, scaled_output: TileTensor[out_dtype, Storage=scaled_output.Storage, address_space=scaled_output.address_space, linear_idx_type=scaled_output.linear_idx_type], scales: TileTensor[scales_dtype, Storage=scales.Storage, address_space=scales.address_space, linear_idx_type=scales.linear_idx_type], scale_ub: Float32, ctx: DeviceContext, num_rows: Int) where (eq InputFnType.in_dtype, in_dtype)
TileTensor primary implementation of dynamic scaled FP8 quantization.
Parameters:
- βout_dtype (
DType): FP8 dtype of the quantized output; must befloat8_e4m3fn. - βin_dtype (
DType): Dtype of the input values loaded byinput_fn. - βscales_dtype (
DType): Dtype of the per-group scale factors written toscales; one ofbfloat16,float16, orfloat32. - βInputFnType (
def[width: Int, alignment: Int](row: Int, col: Int) -> SIMD[in_dtype, width]&ImplicitlyCopyable&RegisterPassable): Compile-time callable type that loadsSIMD[in_dtype, width]tiles for a given(row, col)(inferred). - βgroup_size_or_per_token (
Int): Number of columns per quantization group;-1selects per-tensor scaling over allnum_cols. - βnum_cols (
Int): Number of columns in the input; the hidden dimension size. - βpdl_level (
PDLLevel): Programmatic dependent launch level for the kernels (defaults toPDLLevel.ON).
Args:
- βinput_fn (
InputFnType): Callable that loads input tiles for a given(row, col)pair. - βscaled_output (
TileTensor[out_dtype, Storage=scaled_output.Storage, address_space=scaled_output.address_space, linear_idx_type=scaled_output.linear_idx_type]): Rank-2 outputTileTensorof FP8-quantized values. - βscales (
TileTensor[scales_dtype, Storage=scales.Storage, address_space=scales.address_space, linear_idx_type=scales.linear_idx_type]): Rank-2 outputTileTensorof per-group scale factors. - βscale_ub (
Float32): Upper bound for the dynamic scale factor. - βctx (
DeviceContext): Device context used to enqueue the kernels. - βnum_rows (
Int): Number of rows to quantize;0skips the launch.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!