Skip to content
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

flash-attn Detection Logic Fails for flash-attn #1555

Open
Zzhiter opened this issue Jan 19, 2025 · 3 comments
Open

flash-attn Detection Logic Fails for flash-attn #1555

Zzhiter opened this issue Jan 19, 2025 · 3 comments
Labels
fixed - pending confirmation Fixed, waiting for confirmation from poster

Comments

@Zzhiter
Copy link
Contributor

Zzhiter commented Jan 19, 2025

Problem Description

When using unsloth, I noticed an issue with the flash-attn detection logic. Specifically, unsloth checks for the presence of flash-attn using the following code:

from flash_attn.flash_attn_interface import flash_attn_cuda

However, in latest flash-attn(mine is 2.7.3), the flash_attn_cuda module has been removed and replaced with flash_attn_gpu (see this commit). As a result, unsloth's detection logic fails for flash-attn, incorrectly concluding that flash-attn is not installed or is broken, and falls back to xformers.

Expected Behavior

unsloth should correctly detect the presence of flash-attn regardless of whether the installed version uses flash_attn_cuda or flash_attn_gpu.

Actual Behavior

When flash-attn is installed, unsloth fails to detect it and falls back to xformers, even though flash-attn is properly installed and functional.

Steps to Reproduce

  1. Install flash-attn: pip install flash-attn --no-build-isolation
  2. Run a training script using unsloth.
  3. Observe the logs. unsloth will incorrectly report that flash-attn is not installed or is broken, and will fall back to xformers.

Environment Information

Python Version: 3.10
PyTorch Version: 2.5.1+cu124
CUDA Version: 12.4
flash-attn Version: 2.7.3

@Zzhiter Zzhiter changed the title flash-attn Detection Logic Fails for flash-attn>=2.7.3 flash-attn Detection Logic Fails for flash-attn Jan 19, 2025
@danielhanchen
Copy link
Contributor

Appreciate the fix!

@danielhanchen
Copy link
Contributor

Just pushed it in - hopefully flash-attn works as expected now! For local machines, please update Unsloth via:

pip install --upgrade --no-cache-dir --force-reinstall --no-deps unsloth unsloth_zoo

@danielhanchen danielhanchen added the fixed - pending confirmation Fixed, waiting for confirmation from poster label Jan 20, 2025
@ChaJiuZuoban
Copy link

This is an awesome issue. It has been of great help to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed - pending confirmation Fixed, waiting for confirmation from poster
Projects
None yet
Development

No branches or pull requests

3 participants