|
| 1 | +# Installation |
| 2 | + |
| 3 | +`fla` ships as two PyPI packages: `fla-core` (kernels in `fla/ops`, |
| 4 | +`fla/modules`, `fla/utils`) and `flash-linear-attention` (everything in |
| 5 | +`fla/layers` + `fla/models`, plus `fla-core` as a dep). Both follow the same |
| 6 | +backend-extras layout. |
| 7 | + |
| 8 | +## Pick a backend |
| 9 | + |
| 10 | +`torch` and the matching `triton` flavor live in backend extras, not in the |
| 11 | +base deps. Wheel metadata is the same across backends; `pip` only pulls the |
| 12 | +flavor you ask for. |
| 13 | + |
| 14 | +| Backend | Extra | Wheel index | `triton` flavor | |
| 15 | +| ------- | -------- | ------------------------------------------ | ------------------------ | |
| 16 | +| CUDA | `[cuda]` | `https://download.pytorch.org/whl/cu128` | `triton` | |
| 17 | +| ROCm | `[rocm]` | `https://download.pytorch.org/whl/rocm7.2` | `pytorch-triton-rocm` | |
| 18 | +| XPU | `[xpu]` | `https://download.pytorch.org/whl/xpu` | `pytorch-triton-xpu` | |
| 19 | +| NPU | `[npu]` | (use your CANN-matched `torch` / `torch_npu`) | `triton-ascend` | |
| 20 | +| CPU | `[cpu]` | `https://download.pytorch.org/whl/cpu` | `triton` (import-only) | |
| 21 | + |
| 22 | +## From PyPI |
| 23 | + |
| 24 | +```sh |
| 25 | +pip install flash-linear-attention[cuda] |
| 26 | +pip install flash-linear-attention[rocm] --extra-index-url https://download.pytorch.org/whl/rocm7.2 |
| 27 | +pip install flash-linear-attention[xpu] --extra-index-url https://download.pytorch.org/whl/xpu |
| 28 | +pip install flash-linear-attention[cpu] --extra-index-url https://download.pytorch.org/whl/cpu |
| 29 | +``` |
| 30 | + |
| 31 | +## Ascend NPU |
| 32 | + |
| 33 | +NPUs use [`triton-ascend`](https://github.com/triton-lang/triton-ascend), not |
| 34 | +upstream `triton`. Since `triton` is in backend extras (not base deps), the |
| 35 | +old "install fla, then `pip uninstall triton`, then install `triton-ascend`" |
| 36 | +dance is no longer needed. |
| 37 | + |
| 38 | +```sh |
| 39 | +# 1. install CANN + source set_env.sh |
| 40 | +# 2. install torch + torch_npu that match your CANN |
| 41 | +pip install torch==2.7.1 torch_npu==2.7.1 |
| 42 | +# 3. install fla with the npu extra |
| 43 | +pip install flash-linear-attention[npu] |
| 44 | +``` |
| 45 | + |
| 46 | +## From source |
| 47 | + |
| 48 | +```sh |
| 49 | +pip uninstall fla-core flash-linear-attention -y |
| 50 | +pip install -U "git+https://github.com/fla-org/flash-linear-attention#egg=flash-linear-attention[cuda]" |
| 51 | +# replace [cuda] with [rocm] / [xpu] / [npu] / [cpu] and add the matching --extra-index-url for non-CUDA |
| 52 | +``` |
| 53 | + |
| 54 | +Or with submodules: |
| 55 | +```sh |
| 56 | +git submodule add https://github.com/fla-org/flash-linear-attention.git 3rdparty/flash-linear-attention |
| 57 | +ln -s 3rdparty/flash-linear-attention/fla fla |
| 58 | +``` |
| 59 | + |
| 60 | +## Behavior change vs. pre-v0.5 |
| 61 | + |
| 62 | +Before v0.5, `pip install flash-linear-attention` resolved a CUDA-built |
| 63 | +`torch` + `triton` from the default PyPI index even on ROCm / XPU / NPU |
| 64 | +machines, which silently overlaid the wrong wheels. Now the base install |
| 65 | +contains no `torch` / `triton` at all: you pick a backend extra. Bare |
| 66 | +`pip install flash-linear-attention` no longer imports. |
| 67 | + |
| 68 | +## Notes |
| 69 | + |
| 70 | +- Already have a working `torch` for your backend? `pip install -e .[rocm]` |
| 71 | + (or the matching extra) leaves it alone because the `torch>=2.7.0` pin is |
| 72 | + satisfied. |
| 73 | +- For AMD GPUs the `[rocm]` extra pulls `pytorch-triton-rocm`. For Intel GPUs |
| 74 | + the `[xpu]` extra pulls `pytorch-triton-xpu`. See [FAQs](FAQs.md) for |
| 75 | + backend-specific issues. |
| 76 | + |
| 77 | +## Skipping the dep resolver |
| 78 | + |
| 79 | +`torch` pre-release / `triton-nightly` setups can sidestep resolution |
| 80 | +entirely: |
| 81 | +```sh |
| 82 | +pip install transformers einops |
| 83 | +pip uninstall fla-core flash-linear-attention -y |
| 84 | +pip install -U --no-deps git+https://github.com/fla-org/flash-linear-attention |
| 85 | +``` |
0 commit comments