danbot-comfy-node icon indicating copy to clipboard operation
danbot-comfy-node copied to clipboard

Flash Attention 2 causes a "pos_idx_in_fp32" error in DanbotLoadModel on Blackwell GPUs

Open nyaa-kobayashi opened this issue 1 year ago • 0 comments

Report

When Flash Attention 2 is enabled in a Windows environment with a Blackwell-series GPU, the DanbotLoadModel node throws the following error. Tested Flash Attention version: flash_attn-2.7.4.post1

## Error Details
- **Node ID:** 379
- **Node Type:** DanbotLoadModel
- **Exception Type:** TypeError
- **Exception Message:** RotaryEmbedding.__init__() got an unexpected keyword argument 'pos_idx_in_fp32'

Current Workaround

To avoid this issue, I disabled Flash Attention 2 within the DanbotLoadModel node and explicitly specified the use of SDPA (scaled dot product attention) in v2408.py.

Steps:

  1. Comment out lines 136–140 in v2408.py.
  2. Add the following line directly below:
            attn_implementation="sdpa",  # Explicitly use SDPA for stability

The modified code looks like this:

            trust_remote_code=trust_remote_code,
            # Flash Attention 2 is disabled due to known issues with Blackwell GPUs
            # Original code:
            # attn_implementation=(
            #     "flash_attention_2"
            #     if (is_flash_attn_available() and load_device.type == "cuda")
            #     else "sdpa"
            # ),
            attn_implementation="sdpa",  # Explicitly use SDPA for stability
        )

While this is only a temporary workaround, I have not found any other way to make Flash Attention 2 and Danbot work together on Blackwell GPUs at this time. I’m sharing this as both a report and a possible reference for others facing similar issues.

nyaa-kobayashi avatar Jun 21 '25 02:06 nyaa-kobayashi