You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
flux2-klein-base-4b训练出错 RuntimeError: FlashAttention only support fp16 and bf16 data type #1271
Activity
zhenbuxianggaimingzi commentedon Feb 6, 2026
看起来似乎是因为flux2_dit中使用的是torch.nn库中的Layernorm和RMSNorm,accelerate自动混合精度训练时会自动将类型向上转换为fp32,但并不会再自动转换回bf16,因此需要手动在所有的norm后手动添加类型转换,转回bf16。
在我自己的代码里这样修改确实是可行的,修改后训练能正常进行了。
历史issue中似乎也有过类似的问题 #628 #696,但都是wan相关的训练,新版本代码仓wan中使用的自定义RMSNorm会自动将类型转回bf16,另外zimage/qwen-image/flux1等其他dit代码中也都是使用的自定义RMSNorm,仅有flux2会出现类似问题......
Artiprocher commentedon Feb 10, 2026
@zhenbuxianggaimingzi 这是个存在很久但我们一直没能复现的问题,近期我们发现这是由于 torch 版本过低导致的,这个问题已修复,但我们仍然建议升级到最新版的 torch:#1280
fix(flux2): cast query and key to the value dtype before attention (m…