[Others] update flash mask version#7819
Conversation
|
Thanks for your contribution! |
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览
2 任务状态汇总2.1 Required任务 : 9/10 通过
2.2 可选任务 — 31/32 通过
3 失败详情(仅 required)Approval — 代码规范(置信度: 高)Approval
根因详情: 修复建议:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7819 +/- ##
==========================================
Coverage ? 63.35%
==========================================
Files ? 462
Lines ? 64371
Branches ? 9872
==========================================
Hits ? 40780
Misses ? 20825
Partials ? 2766
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览⏳ Required 任务进行中:5 个运行中,1 个等待中,暂无 Required 失败。
2 任务状态汇总2.1 Required任务 : 3/9 通过
2.2 可选任务 — 24/28 通过
3 失败详情(仅 required)无 required 失败任务。 |
| paddle.enable_compat(scope={"cutlass"}) | ||
| from flash_mask.cute.interface import flashmask_attention as fa4 | ||
| try: | ||
| from paddlefleet.ops import is_flash_mask_available |
There was a problem hiding this comment.
最近paddlefleet有名称变更,如果不太着急的话可以关注下这个PR 的修改同步也适配下 #7859
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-20 14:47:17
📋 Review 摘要
PR 概述:将 flash_mask 从独立包迁移至 paddlefleet_ops 内置模块,解决 nvidia-cutlass-dsl 版本冲突问题。
变更范围:fastdeploy/model_executor/layers/attention/、requirements.txt、tests/layers/
影响面 Tag:[OP]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🔴 Bug | flash_attn_backend.py:102 |
内层 except 静默后 fa4 未绑定,NameError 不被外层 except ImportError 捕获,模块级 import 在 SM≥100 无 paddlefleet_ops 时崩溃 |
📝 PR 规范检查
PR 标题格式合规([Others] 在官方 Tag 列表中),描述各段(Motivation / Modifications / Usage or Command / Accuracy Tests / Checklist)均已填写,结构完整,无需修改。
总体评价
依赖迁移思路正确,但引入了一个关键异常处理缺陷:内层 except 静默异常后 fa4 未绑定,导致模块在 SM≥100 平台上若未安装 paddlefleet_ops 则无法 import,需修复后合入。
| logger.info(f"The current platform[sm{get_sm_version()}] can't import Flash Attention V4.") | ||
|
|
||
| global flashmask_attention_v4 | ||
| flashmask_attention_v4 = fa4 |
There was a problem hiding this comment.
🔴 Bug fa4 在内层 except 执行后为未绑定变量,此行会抛出 NameError: name 'fa4' is not defined。
根因:当 paddlefleet_ops 不可用(ImportError)或 is_flash_mask_available() 返回 False(ModuleNotFoundError)时,内层 except 捕获并静默,但 fa4 从未被赋值。外层 except ImportError 仅捕获 ImportError,无法捕获 NameError,异常因此向上传播。
影响:init_flash_attn_version() 在模块顶层被调用(line 124),在任何 SM≥100 且未安装 paddlefleet_ops 的机器上,import 该模块即会崩溃。测试中 test_fa4_flash_mask_unavailable 和 test_fa4_paddlefleet_import_error 均通过 except NameError: pass 掩盖了这个问题。
建议修复:将成功路径的赋值移入 if is_flash_mask_available(): 块内:
try:
from paddlefleet_ops import is_flash_mask_available
if is_flash_mask_available():
from paddlefleet_ops.flash_mask.cute.interface import (
flashmask_attention as fa4,
)
global flashmask_attention_v4
flashmask_attention_v4 = fa4
FLASH_ATTN_VERSION = 4
logger.info("The current platform supports Flash Attention V4.")
else:
raise ModuleNotFoundError("flash_mask not available.")
except (ImportError, ModuleNotFoundError):
logger.info(f"The current platform[sm{get_sm_version()}] can't import Flash Attention V4.")
Motivation
flashinfer升级到0.6.11版本要求nvidia-cutlass-dsl>=4.4.2(https://github.com/PaddlePaddle/FastDeploy/pull/7799),flash mask旧版本锁死了nvidia-cutlass-dsl==4.4.2,产生冲突,因此升级一下flash mask版本
Modifications
删除flash mask依赖,直接使用paddlefleet中的flashmask
升级flash mask版本
版本信息记录在:https://ku.baidu-int.com/knowledge/HFVrC7hq1Q/pKzJfZczuc/YeqWcBGW4m/EUBpKxHfTurV5G
Usage or Command
NA
Accuracy Tests
NA
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.