Instructions to use replicate/flashinfer-draft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/flashinfer-draft 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/flashinfer-draft", version=1) - Notebooks
- Google Colab
- Kaggle
Download torch-ext/flashinfer/__init__.py from replicate/flashinfer-draft: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/replicate/flashinfer-draft/resolve/main/torch-ext/flashinfer/__init__.py
- Command line
-
hf download hf://replicate/flashinfer-draft/torch-ext/flashinfer/__init__.py
-
curl -L -o __init__.py https://huggingface.co/replicate/flashinfer-draft/resolve/main/torch-ext/flashinfer/__init__.py
1.29 kB
| # NOTE: Torch needs to be imported before the custom | |
| # extensions. Otherwise libc10.so cannot be found. | |
| import torch | |
| from ._ops import ops | |
| def gelu_and_mul(out, input, enable_pdl): | |
| return ops.gelu_and_mul(out, input, enable_pdl) | |
| def gelu_tanh_and_mul(out, input, enable_pdl): | |
| return ops.gelu_tanh_and_mul(out, input, enable_pdl) | |
| def silu_and_mul(out, input, enable_pdl): | |
| return ops.silu_and_mul(out, input, enable_pdl) | |
| # def batch_decode_with_paged_kv_cache_plan_swa_false( | |
| # float_workspace_buffer, | |
| # int_workspace_buffer, | |
| # page_locked_int_workspace_buffer, | |
| # indptr, | |
| # batch_size, | |
| # num_qo_heads, | |
| # num_kv_heads, | |
| # page_size, | |
| # enable_cuda_graph, | |
| # window_left, | |
| # logits_soft_cap, | |
| # head_dim_qk, | |
| # head_dim_vo, | |
| # empty_q_data, | |
| # empty_kv_data | |
| # ): | |
| # return ops.BatchDecodeWithPagedKVCachePlan_swa_false( | |
| # float_workspace_buffer, | |
| # int_workspace_buffer, | |
| # page_locked_int_workspace_buffer, | |
| # indptr, | |
| # batch_size, | |
| # num_qo_heads, | |
| # num_kv_heads, | |
| # page_size, | |
| # enable_cuda_graph, | |
| # window_left, | |
| # logits_soft_cap, | |
| # head_dim_qk, | |
| # head_dim_vo, | |
| # empty_q_data, | |
| # empty_kv_data | |
| # ) | |