Answers for LLM inference engineers

ImportError: cannot import name 'flash_attn_unpadded_func' (or FlashMHA, flash_attn_varlen_func, any name) from 'flash_attn...': which flash-attn releases have it

flash-attn 2.0 (2023-07-24 for 2.0.1, the first 2.x release on PyPI) renamed flash_attn_unpadded_func, flash_attn_unpadded_kvpacked_func and flash_attn_unpadded_qkvpacked_func to flash_attn_varlen_func, flash_attn_varlen_kvpacked_func and flash_attn_varlen_qkvpacked_func, and removed flash_attn.flash_attention (FlashAttention, FlashMHA); 1.0.9 is the last release with the old names. The first seven arguments are the same, so renaming the import is usually the whole fix; only deterministic is missing in 2.0 to 2.3. The opposite error, from flash_attn import flash_attn_func failing, means a 1.x install. For any other name, in any module of flash-attn, paste the error below.

Published 2026-11-25 · Data as of 2026-11-25 · flash-attn 0.2.1 to 2.8.3, the first release of each of 12 minor versions, with patch releases that differ noted · read from the source of each release tag, nothing was installed or run (how, limits) · Corrected 2026-12-05

Corrected on 2026-12-05: this page read only the first release of each minor version, so a name or module added or removed in a patch release was dated to the next minor. For example, the module flash_attn.models.llama is in 1.0.4 (2023-04-26) and later 1.0.x, not only from 2.0.1. Every release was then read once from PyPI: 4 top-level names (and 437 module-and-name pairs in all) differ in some patch release from the first release of the same minor. The lookup now gives those patch releases. The per-minor ranges are unchanged.

Examples:

Runs in your browser on flash_attn.json (68 KB); nothing you paste is sent anywhere. Covers 24 top-level names and 1,652 module-and-name pairs in 91 modules.

What did flash-attn 2.0 rename?

The 1.x names and their 2.x replacements; the new functions are also importable from flash_attn itself.

1.x (to 1.0.9)2.0 and later
flash_attn_unpadded_funcflash_attn_varlen_func
flash_attn_unpadded_kvpacked_funcflash_attn_varlen_kvpacked_func
flash_attn_unpadded_qkvpacked_funcflash_attn_varlen_qkvpacked_func
flash_attn.flash_attention.FlashAttention, FlashMHAflash_attn.modules.mha.MHA or the functions above

Names that need a newer 2.x (the first release of each minor version that has them):

ImportFromDate (PyPI)
from flash_attn import flash_attn_func2.0.12023-07-24
from flash_attn import flash_attn_varlen_func2.0.12023-07-24
from flash_attn import flash_attn_with_kvcache2.2.02023-09-06

How do I read the error?

How was this read, and how was it checked?

From the source of each release tag of Dao-AILab/flash-attention, with Python's ast module; no release was installed, imported or compiled. A module's names are everything it binds at module level and what from .x import * brings in; code under if TYPE_CHECKING: is skipped. Dates come from PyPI.

Checks: (1) each of the 24 top-level names is found as plain text in flash_attn/__init__.py in every release of its range (239 name-and-release pairs) and not on either side (8 edges). (2) A regular expression finds 1,742 definitions in 251 file versions; all are among the names read. (3) 10 release checks by plain-text search in the tags agree:

NameReleaseText and data
flash_attn.flash_attn_interface.flash_attn_unpadded_func1.0.0has it
flash_attn.flash_attn_interface.flash_attn_unpadded_func2.0.1does not
flash_attn.flash_attn_interface.flash_attn_varlen_func2.0.1has it
flash_attn.flash_attn_interface.flash_attn_varlen_func1.0.0does not
flash_attn.flash_attn_func2.0.1has it
flash_attn.flash_attn_func1.0.0does not
flash_attn.flash_attention.FlashMHA1.0.0has it
flash_attn.flash_attention.FlashMHA2.0.1does not
flash_attn.flash_attn_interface.flash_attn_with_kvcache2.2.0has it
flash_attn.flash_attn_interface.flash_attn_with_kvcache2.1.0does not

Limits

Questions

How do I fix "cannot import name 'flash_attn_unpadded_func' from 'flash_attn.flash_attn_interface'"?

flash-attn 2.0 renamed it to flash_attn_varlen_func (and the kvpacked and qkvpacked variants the same way); 1.0.9 is the last 1.x release with the old names. Change the import, or pin pip install "flash-attn<2.0" for code you cannot change. The first seven arguments are the same; 2.0 to 2.3 have no deterministic argument (the 2.4 series has it again).

Where did FlashMHA and flash_attn.flash_attention go?

flash-attn 2.0 removed the flash_attn.flash_attention module with FlashAttention and FlashMHA. flash_attn.modules.mha.MHA is the module that remains, or call flash_attn_func directly.

Why does "from flash_attn import flash_attn_func" fail?

The installed flash-attn is 1.x, which did not export it at the top level (the first release read that does is 2.0.1). If the error is an undefined symbol in flash_attn_2_cuda instead, the build does not match your PyTorch; that is not an import-name problem and reinstalling flash-attn against your PyTorch fixes it.

Does this page cover flash_attn.modules, flash_attn.ops and the AMD Triton backend?

Yes: every module of flash-attn from 0.2.1 to 2.8.3, 1,652 module-and-name pairs in 91 modules.

Sources

The same data as JSON: flash_attn.json, licensed CC BY 4.0.

Related: "No module named 'triton.ops'" · "cannot import name ... from 'vllm'" · "... from 'transformers'".