Instructions to use kernels-community/rotary with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use kernels-community/rotary 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("kernels-community/rotary", version=1) - Notebooks
- Google Colab
- Kaggle
Download tests/utils.py from kernels-community/rotary: direct link, hf CLI and curl.
- Browser
- Download file 517 Bytes
-
https://huggingface.co/kernels-community/rotary/resolve/refs%2Fpr%2F3/tests/utils.py
- Command line
-
hf download hf://kernels-community/rotary@refs/pr/3/tests/utils.py
-
curl -L -o utils.py https://huggingface.co/kernels-community/rotary/resolve/refs%2Fpr%2F3/tests/utils.py
517 Bytes
| import torch | |
| def infer_device(): | |
| """ | |
| Get current device name based on available devices | |
| """ | |
| if torch.cuda.is_available(): # Works for both Nvidia and AMD | |
| return "cuda" | |
| elif torch.xpu.is_available(): | |
| return "xpu" | |
| else: | |
| return None | |
| def supports_bfloat16(): | |
| device = infer_device() | |
| if device == "cuda": | |
| return torch.cuda.get_device_capability() >= (8, 0) # Ampere and newer | |
| elif device == "xpu": | |
| return True | |
| else: | |
| return False |