---
title: flash-attn2
canonical_url: "https://www.modelscope.cn/models/kernels-community/flash-attn2"
md_url: "https://www.modelscope.cn/models/kernels-community/flash-attn2.md"
repository: kernels-community/flash-attn2
last_updated: 2026-09-03
license: bsd-3-clause
library_name:
  - pytorch
frameworks:
  - pytorch
downloads: 127
stars: 0
---

# flash-attn2

> flash-attn2 - kernels-community 在 ModelScope 开源的模型。[!CAUTION] Starting from September 13, 2026, we will be removing the "model" type repositories of kernels (e.g., kernels-community/flash-attn3). Make sure you're using a latest version of kernels. If you…

kernels-community/flash-attn2 是 ModelScope 魔搭社区上的机器学习模型，采用 bsd-3-clause 许可。

- **Repository**: kernels-community/flash-attn2
- **License**: bsd-3-clause
- **Downloads**: 127
- **Stars**: 0
- **Last updated**: 2026-09-03

Source: https://www.modelscope.cn/models/kernels-community/flash-attn2

---

> [!CAUTION]
> Starting from September 13, 2026, we will be removing the "model" type repositories of kernels (e.g., kernels-community/flash-attn3). Make sure you're using a latest version of kernels. If you face any disruption, please report them here: https://github.com/huggingface/kernels/issues/new.

This is the repository card of kernels-community/flash-attn2 that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated.

## How to use

```python
# make sure `kernels` is installed: `pip install -U kernels`
from kernels import get_kernel

kernel_module = get_kernel("kernels-community/flash-attn2", version=2)
flash_attn_func = kernel_module.flash_attn_func

flash_attn_func(...)
```

## Available functions
- `flash_attn_func`
- `flash_attn_kvpacked_func`
- `flash_attn_qkvpacked_func`
- `flash_attn_varlen_func`
- `flash_attn_varlen_kvpacked_func`
- `flash_attn_varlen_qkvpacked_func`
- `flash_attn_with_kvcache`
- `fwd`
- `varlen_fwd`
- `bwd`
- `varlen_bwd`
- `fwd_kvcache`

## Benchmarks

Benchmarking script is available for this kernel. Run `kernels benchmark kernels-community/flash-attn2 --version 2`.
