-
Notifications
You must be signed in to change notification settings - Fork 106
[release/0.3] fix fleet fa version dispatch #1398
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
base: release/0.3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,21 +61,22 @@ def _get_fa_version(hdim): | |
| if "xpu" in paddle.get_device(): | ||
| return 2 | ||
| # Xiangrui: For deterministic, NOT support for hdim > 128 currently. | ||
| if "block_mask" in inspect.signature(flashmask_attention).parameters: | ||
| if ( | ||
| paddle.get_flags(["FLAGS_cudnn_deterministic"])[ | ||
| "FLAGS_cudnn_deterministic" | ||
| ] | ||
| and hdim > 128 | ||
| ): | ||
| return 2 | ||
| elif paddle.get_flags(["FLAGS_cudnn_deterministic"])[ | ||
| "FLAGS_cudnn_deterministic" | ||
| ]: | ||
| return 2 | ||
| fa_version = paddle.base.framework.get_flags(["FLAGS_flash_attn_version"])[ | ||
| "FLAGS_flash_attn_version" | ||
| ] | ||
| if fa_version == 3: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug 这里用原始 flag 是否等于 3 来决定 deterministic fallback,会漏掉 当前函数后面会把不可用的 v4 回退成 v3;但这个回退发生在 deterministic 检查之后。确定性模式且 建议修复方式: if fa_version == 4 and not _flash_mask_available:
fa_version = 3
if fa_version == 3 and deterministic_needs_v2:
return 2
return fa_version |
||
| if "block_mask" in inspect.signature(flashmask_attention).parameters: | ||
| if ( | ||
| paddle.get_flags(["FLAGS_cudnn_deterministic"])[ | ||
| "FLAGS_cudnn_deterministic" | ||
| ] | ||
| and hdim > 128 | ||
| ): | ||
| return 2 | ||
| elif paddle.get_flags(["FLAGS_cudnn_deterministic"])[ | ||
| "FLAGS_cudnn_deterministic" | ||
| ]: | ||
| return 2 | ||
| # Fall back to version 3 if flash_mask is not available | ||
| if fa_version == 4 and not _flash_mask_available: | ||
| logger.warning( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Bug CP 路径同样只检查原始
fa_version == 3,导致请求 v4 但_flash_mask_available=False时前向实际走普通flashmask_attention,却仍把fa_version=4返回给后向。cp_flashmask_allgatherkv_balance_backward()只有在fa_version == 4 and _flash_mask_available时才走 v4 分支,否则会落到ValueError("FlashAttention version 4 is not supported.")。确定性配置下旧逻辑会降到 v2,新逻辑跳过降级后会让 CP 训练在 backward 阶段失败。建议修复方式:
像
_get_fa_version()一样集中计算 effective version;当 v4 后端不可用时把fa_version改成普通 FlashMask 实际使用的 3/2,并把这个值返回给 backward。