Skip to content

vllm.model_executor.layers.quantization.utils.int8_utils

Functions:

_per_token_group_quant_int8(y_ptr, y_q_ptr, y_s_ptr, y_stride, N, eps, int8_min, int8_max, BLOCK)

A Triton-accelerated function to perform per-token-group quantization on a tensor.

This function converts the tensor values into int8 values.

per_token_group_quant_int8(x, group_size, eps=1e-10, dtype=torch.int8)

Function to perform per-token-group quantization on an input tensor x.

It converts the tensor values into signed int8 values and returns the quantized tensor along with the scaling factor used for quantization.

Parameters:

  • x

    (Tensor) –

    The input tensor with ndim >= 2.

  • group_size

    (int) –

    The group size used for quantization.

  • eps

    (float, default: 1e-10 ) –

    The minimum to avoid dividing zero.

  • dtype

    (dtype, default: int8 ) –

    The dype of output tensor. Note that only torch.int8 is supported for now.

Returns:

  • tuple[Tensor, Tensor] –

    tuple[torch.Tensor, torch.Tensor]: The quantized tensor and the scaling factor for quantization.