vllm.model_executor.layers.quantization.utils.int8_utils ¶
Functions:
-
block_dequant–This function conducts block-wise dequantization.
-
per_token_group_quant_int8–Function to perform per-token-group quantization on an input tensor
x.
_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.
Source code in vllm/model_executor/layers/quantization/utils/int8_utils.py
block_dequant(x_q_block, x_s, block_size) ¶
This function conducts block-wise dequantization. The inputs are block-wise quantization tensor x_q_block, block-wise quantization scale and the block size. The outputs are dequantized tensor.
Source code in vllm/model_executor/layers/quantization/utils/int8_utils.py
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.int8is supported for now.
Returns:
-
tuple[Tensor, Tensor]–tuple[torch.Tensor, torch.Tensor]: The quantized tensor and the scaling factor for quantization.