Instructions to use replicate/quantization-bitsandbytes with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/quantization-bitsandbytes with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("replicate/quantization-bitsandbytes", version=1) - Notebooks
- Google Colab
- Kaggle
Download build/torch29-cxx11-cpu-x86_64-linux/custom_ops.py from replicate/quantization-bitsandbytes: direct link, hf CLI and curl.
- Browser
- Download file 496 Bytes
-
https://huggingface.co/replicate/quantization-bitsandbytes/resolve/main/build/torch29-cxx11-cpu-x86_64-linux/custom_ops.py
- Command line
-
hf download hf://replicate/quantization-bitsandbytes/build/torch29-cxx11-cpu-x86_64-linux/custom_ops.py
-
curl -L -o custom_ops.py https://huggingface.co/replicate/quantization-bitsandbytes/resolve/main/build/torch29-cxx11-cpu-x86_64-linux/custom_ops.py
496 Bytes
| import torch | |
| from ._ops import ops | |
| def gemm_4bit_forward( | |
| input: torch.Tensor, | |
| weight: torch.Tensor, | |
| absmax: torch.Tensor, | |
| blocksize: int, | |
| quant_type: int, | |
| ) -> torch.Tensor: | |
| original_dtype = input.dtype | |
| if original_dtype != torch.bfloat16: | |
| input = input.to(torch.bfloat16) | |
| output = ops.gemm_4bit_forward(input, weight, absmax, blocksize, quant_type) | |
| if original_dtype != torch.bfloat16: | |
| output = output.to(original_dtype) | |
| return output | |