Install & Compatibility
Where this runs
tested against v2.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 93s
py 3.11
✕ build_error
✓ 88.5s
py 3.12
✕ build_error
✓ 79.8s
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 101.9s
5274MB installed
● package 5274MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
flash_attn_func
✓ from vllm_flash_attn import flash_attn_func
✗ from flash_attn import flash_attn_func
flash_attn provides a full trian/test API; vllm_flash_attn exports only forward-only functions.
flash_attn_with_kvcache
✓ from vllm_flash_attn import flash_attn_with_kvcache
✗ from flash_attn import flash_attn_with_kvcache
This function is specifically for inference with precomputed KV cache.
Basic usage of forward-only flash attention. Requires CUDA GPU.
import torch
from vllm_flash_attn import flash_attn_func
q = torch.randn(1, 1, 8, 64, device='cuda', dtype=torch.float16)
k = torch.randn(1, 1, 8, 64, device='cuda', dtype=torch.float16)
v = torch.randn(1, 1, 8, 64, device='cuda', dtype=torch.float16)
out = flash_attn_func(q, k, v, softmax_scale=1.0, causal=False)
print(out.shape)
Errors
Common errors & fixes
ImportError: No module named 'vllm_flash_attn'
Package not installed or installed with an older name (flash_attn instead of vllm_flash_attn).
fixpip install vllm-flash-attn
RuntimeError: FlashAttention only supports CUDA with compute capability >= 8.0
GPU older than Ampere (e.g., V100, GTX 1080).
fixUpdate to a GPU with compute capability >= 8.0, or use a CPU implementation.
AssertionError: Input tensor must be contiguous in memory
Input tensors are not contiguous; flash attention requires contiguous memory layout.
fixCall .contiguous() on tensors before passing: q.contiguous(), k.contiguous(), v.contiguous()
Upgrade
Version history
2.6.2latest on PyPI · released Sep 5, 2024
Audit
Dependencies
torchrequiredFlash attention kernels depend on PyTorch tensors and CUDA.
flash-attnrequiredThe underlying flash-attention library; vllm-flash-attn wraps it for forward-only use.