Instructions to use replicate/flash-attn-ops with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/flash-attn-ops 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/flash-attn-ops", version=1) - Notebooks
- Google Colab
- Kaggle
Download build/torch-cuda/_ops_compat.py from replicate/flash-attn-ops: direct link, hf CLI and curl.
- Browser
- Download file 744 Bytes
-
https://huggingface.co/replicate/flash-attn-ops/resolve/main/build/torch-cuda/_ops_compat.py
- Command line
-
hf download hf://replicate/flash-attn-ops/build/torch-cuda/_ops_compat.py
-
curl -L -o _ops_compat.py https://huggingface.co/replicate/flash-attn-ops/resolve/main/build/torch-cuda/_ops_compat.py
744 Bytes
| """Compatibility helpers for op namespacing in source and built layouts. | |
| In the built (Hub) layout, kernel-builder generates an `_ops` module that | |
| exposes `add_op_namespace_prefix`, which prefixes op names with a unique, | |
| build-hashed namespace so custom ops never collide across kernels/versions. When | |
| running directly from source there is no generated `_ops`, so we fall back to a | |
| fixed namespace. | |
| """ | |
| try: | |
| from ._ops import add_op_namespace_prefix as _generated_add_op_namespace_prefix | |
| except ImportError: | |
| def _generated_add_op_namespace_prefix(name: str) -> str: | |
| return name if "::" in name else f"flash_attn_ops::{name}" | |
| def add_op_namespace_prefix(name: str) -> str: | |
| return _generated_add_op_namespace_prefix(name) | |