Skip to content

docs: flash-attn usage and install #1706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,38 @@ This is a collection of FAQ collected from the user questions on <https://github
Also see [docling#725](https://github.com/docling-project/docling/issues/725).

Source: Issue [docling-core#119](https://github.com/docling-project/docling-core/issues/119)


??? question "How to use flash attention?"

### How to use flash attention?

When running models in Docling on CUDA devices, you can enable the usage of the Flash Attention2 library.

Using environment variables:

```
DOCLING_CUDA_USE_FLASH_ATTENTION2=1
```

Using code:

```python
from docling.datamodel.accelerator_options import (
AcceleratorOptions,
)

pipeline_options = VlmPipelineOptions(
accelerator_options=AcceleratorOptions(cuda_use_flash_attention2=True)
)
```

This requires having the [flash-attn](https://pypi.org/project/flash-attn/) package installed. Below are two alternative ways for installing it:

```shell
# Building from sources (required the CUDA dev environment)
pip install flash-attn

# Using pre-built wheels (not available in all possible setups)
FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE pip install flash-attn
```
Loading