Quantizes a tensor with dtype `torch.float16` to `torch.int8` in accordance to the `LLM.int8()` algorithm. For more information, see the [LLM.int8() paper](https://arxiv.org/abs/2208.07339). Args: A (`torch.Tensor` with dtype `torch.float16`): The input tensor. threshold (`
(A: torch.Tensor, threshold=0.0)
| 1653 | |
| 1654 | |
| 1655 | def int8_vectorwise_quant(A: torch.Tensor, threshold=0.0): |
| 1656 | """Quantizes a tensor with dtype `torch.float16` to `torch.int8` in accordance to the `LLM.int8()` algorithm. |
| 1657 | |
| 1658 | For more information, see the [LLM.int8() paper](https://arxiv.org/abs/2208.07339). |
| 1659 | |
| 1660 | Args: |
| 1661 | A (`torch.Tensor` with dtype `torch.float16`): The input tensor. |
| 1662 | threshold (`float`, *optional*): |
| 1663 | An optional threshold for sparse decomposition of outlier features. |
| 1664 | |
| 1665 | No outliers are held back when 0.0. Defaults to 0.0. |
| 1666 | |
| 1667 | Returns: |
| 1668 | `Tuple[torch.Tensor, torch.Tensor, Optional[torch.Tensor]]`: A tuple containing the quantized tensor and relevant statistics. |
| 1669 | - `torch.Tensor` with dtype `torch.int8`: The quantized data. |
| 1670 | - `torch.Tensor` with dtype `torch.float32`: The quantization scales. |
| 1671 | - `torch.Tensor` with dtype `torch.int32`, *optional*: A list of column indices which contain outlier features. |
| 1672 | """ |
| 1673 | return torch.ops.bitsandbytes.int8_vectorwise_quant.default(A, threshold) |
| 1674 | |
| 1675 | |
| 1676 | def _convert_weight_packed_for_cpu(qweight: torch.Tensor, quant_state: QuantState, block_n: int = 32): |
nothing calls this directly
no outgoing calls
no test coverage detected