Instructions to use replicate/finegrained-fp8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/finegrained-fp8 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/finegrained-fp8", version=1) - Notebooks
- Google Colab
- Kaggle
Download build/torch-cuda/utils.py from replicate/finegrained-fp8: direct link, hf CLI and curl.
- Browser
- Download file 386 Bytes
-
https://huggingface.co/replicate/finegrained-fp8/resolve/main/build/torch-cuda/utils.py
- Command line
-
hf download hf://replicate/finegrained-fp8/build/torch-cuda/utils.py
-
curl -L -o utils.py https://huggingface.co/replicate/finegrained-fp8/resolve/main/build/torch-cuda/utils.py
386 Bytes
| import torch | |
| from contextlib import contextmanager | |
| def device_context(device: torch.device): | |
| """Context manager that sets the active device for any backend (cuda, xpu, etc.).""" | |
| backend = getattr(torch, device.type, None) | |
| if backend is not None and hasattr(backend, "device"): | |
| with backend.device(device): | |
| yield | |
| else: | |
| yield | |