Instructions to use replicate/metal-flash-sdpa with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/metal-flash-sdpa 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/metal-flash-sdpa", version=1) - Notebooks
- Google Colab
- Kaggle
Download torch-ext/torch_binding.cpp from replicate/metal-flash-sdpa: direct link, hf CLI and curl.
- Browser
- Download file 473 Bytes
-
https://huggingface.co/replicate/metal-flash-sdpa/resolve/main/torch-ext/torch_binding.cpp
- Command line
-
hf download hf://replicate/metal-flash-sdpa/torch-ext/torch_binding.cpp
-
curl -L -o torch_binding.cpp https://huggingface.co/replicate/metal-flash-sdpa/resolve/main/torch-ext/torch_binding.cpp
473 Bytes
| TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) { | |
| ops.def("flash_attention_varlen(Tensor! out, Tensor query, Tensor key, Tensor value, Tensor cu_seqlens_q, Tensor cu_seqlens_k, int max_seqlen_q, int max_seqlen_k, bool do_causal, float scale, float softcapping) -> ()"); | |
| ops.impl("flash_attention_varlen", torch::kMPS, flash_attention_varlen); | |
| } | |
| REGISTER_EXTENSION(TORCH_EXTENSION_NAME) | |