Skip to content

When Flash Attention 2 is used and "use_dora = True", errored out: "RuntimeError: FlashAttention only support fp16 and bf16 data type" #1013

Closed

Description

@rohhro

When FA2 is enabled ("FA2=True" shows up when tuning),

"Unsloth 2024.8: Fast Llama patching. Transformers = 4.44.2.
\ /| GPU: NVIDIA GeForce RTX 4090. Max memory: 23.617 GB. Platform = Linux.
O^O/ _/ \ Pytorch: 2.4.0. CUDA = 8.9. CUDA Toolkit = 12.1.
\ / Bfloat16 = TRUE. FA [Xformers = 0.0.27.post2. FA2 = True]"

and "use_dora = True," in the script,

it always errors out "RuntimeError: FlashAttention only support fp16 and bf16 data type".
And there is no way to disable FA2 in the script - I have tried many FA2 configs in the script.

The only way to use dora is to use Unsloth in a env which has no FA2 installed.

Activity

  1. danielhanchen commented on Sep 14, 2024

    @danielhanchen
    Member

    @rohhro Sorry on the delay! Did you use bf16 = True or fp16 = True in the trainer?

  2. rohhro commented on Sep 14, 2024

    @rohhro
    Author

    @rohhro Sorry on the delay! Did you use bf16 = True or fp16 = True in the trainer?

    I have tried bf16 = True or fp16 = True.
    Same error in both cases.

  3. benjamin-marie commented on Apr 22, 2025

    @benjamin-marie

    I also have this issue.
    Is DoRA fine-tuning officially supported by Unsloth?

    I tried many different configurations with Llama 3.1 8B, using DoRA, and all failed. The error mentioned in this issue is triggered when I use load_in_4bit. Otherwise, the fine-tuning runs out of memory (RTX 4090). Setting use_dora=False runs well.

  4. CanGeng commented on Aug 29, 2025

    @CanGeng

    Same error. My solution is:

    for name, param in model.named_parameters():
        if param.dtype == torch.float32:
            param.data = param.data.to(torch.bfloat16)
    

    after get_peft_model().
    but it doesn't work when resume_from_checkpoint=True

  5. added a commit that references this issue on Jun 23, 2026
    9780cdc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions