Instructions to use replicate/paged-attention with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/paged-attention 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/paged-attention", version=1) - Notebooks
- Google Colab
- Kaggle
Download cuda-utils/cuda_utils_kernels.cu from replicate/paged-attention: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/replicate/paged-attention/resolve/main/cuda-utils/cuda_utils_kernels.cu
- Command line
-
hf download hf://replicate/paged-attention/cuda-utils/cuda_utils_kernels.cu
-
curl -L -o cuda_utils_kernels.cu https://huggingface.co/replicate/paged-attention/resolve/main/cuda-utils/cuda_utils_kernels.cu
1.01 kB
| int64_t get_device_attribute(int64_t attribute, int64_t device_id) { | |
| // Return the cached value on subsequent calls | |
| static int value = [=]() { | |
| int device = static_cast<int>(device_id); | |
| if (device < 0) { | |
| CUDA_CHECK(cudaGetDevice(&device)); | |
| } | |
| int value; | |
| CUDA_CHECK(cudaDeviceGetAttribute( | |
| &value, static_cast<cudaDeviceAttr>(attribute), device)); | |
| return static_cast<int>(value); | |
| }(); | |
| return value; | |
| } | |
| int64_t get_max_shared_memory_per_block_device_attribute(int64_t device_id) { | |
| int64_t attribute; | |
| // https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html | |
| // cudaDevAttrMaxSharedMemoryPerBlockOptin = 97 if not is_hip() else 74 | |
| attribute = hipDeviceAttributeMaxSharedMemoryPerBlock; | |
| attribute = cudaDevAttrMaxSharedMemoryPerBlockOptin; | |
| return get_device_attribute(attribute, device_id); | |
| } | |