您好,感谢反馈!
问题分析
1. helper 缺前置判空,核实属实。 FusedInferAttentionScoreProcessSoftmaxLse(attention/fused_infer_attention_score/op_api/aclnn_fused_infer_attention_score_inner.cpp:186-198)在 softmaxLseFlag == true 分支将 softmaxLse 原样下传,无判空;三个旁支副本(aclnn_flash_mla_with_kvcache.cpp:44-56、aclnn_flash_attn.cpp:44-56、aclnn_quant_flash_attn.cpp:49-61)与 V5 的两处内联写法(aclnn_fused_infer_attention_score_v5.cpp:130-140、:220-230)为同型逻辑,同样无判空。
2. FIA 主链路无崩溃,与您的核实一致。 手写 inner 实现 InnerFusedInferAttentionScoreGetWorkspaceSizeImpl(同文件 :690)入口 :726-728 在 softmaxLseFlag 为真时执行 OP_CHECK_NULL(softmaxLse, ...),nullptr 不会下发 l0,接口返回 161001。您提到的报错语义问题也成立:该宏打印的是通用文案(“Expected a value of type [...] for argument [softmaxLse] but instead found nullptr.”),未携带“flag=true 时 softmaxLse 不可为空”的组合条件。补充一个链路细节:仓内源码中,V1 源文件直连手写 Inner* 转发链(aclnn_fused_infer_attention_score.cpp:60,经 inner.cpp:896 汇入 Impl),而 V2–V5 的转发均经 aclnnInner* 封装(由构建工具在 build/autogen/inner 生成,仓内无源码)——这一段与您对 V5 标注的“高置信”属同类情况,静态确证需结合构建产物;不过只要调用汇入上述手写入口,:726-728 的拦截即有效,与您的行为核实结果一致。
3. 旁支三接口:tiling 层拦截已核实,剩余缺口在 autogen op_api 层。 您提到的 SoftmaxLSEChecker 存在性校验,我们补充核实了其实际生效位置:三个算子的 tiling 入口都会先执行 checker 链(flash_attn_tiling.cpp:60-64、quant_flash_attn_tiling.cpp:60-63、flash_mla_with_kvcache_tiling.cpp:60-63),其中 SoftmaxLSE checker 对“开关开启且 lse_out 为空”的拦截文案带组合语义(flash_attn 的 softmax_lse_checker.cpp:66-77:“When softmaxLSE is enabled, lse_out cannot be empty”;quant_flash_attn 的 CheckMultiPara :68-81、flash_mla_with_kvcache :66-77 同型),且三个算子的 tiling 信息解析对 lse_out shape 为空均有判空保护(flash_attn 解析 :567、quant_flash_attn 解析 :546、flash_mla_with_kvcache 解析 :605)。因此只要调用到达 op_host tiling 层,该参数组合会被干净拒绝(GRAPH_FAILED + 明确报错)而非解引用崩溃。剩余不确定性与您的判断一致:自动生成的 op_api inner 层在进入 tiling 前是否解引用 nullptr,仓内源码无法覆盖,需实机或框架侧确认。
处理方向
- 前置判空:您给出的方向可行——在 helper 层补组合校验(函数签名改为返回 aclnnStatus)或在各调用点校验,报错明确指向“softmaxLseFlag=true 且 softmaxLse=nullptr”的组合条件。这不改变 FIA 主链路既有行为(仍返回 161001),收益在于报错位置前移、语义可定位,并与 tiling 层现有文案风格保持一致。
- 副本收敛:4 份副本加 V5 两处内联写法的漂移风险确实存在(V5 已是第三种写法)。需要说明的约束是:4 个 helper 分属 4 个独立算子目录、构建单元各自独立,flag 形参类型也有差异(int64_t 与 bool),收敛为一份公共实现需要权衡公共代码归属与跨算子构建依赖;FIA 家族内部先行收敛(V1–V4 已共用 fused_infer_attention_score_inner.h 中的实现,V5 改为复用)成本较低。这一方向可与第 1 点一并评估。
- 旁支验证:您提出的用例(returnSoftmaxLse 开启且 softmaxLse=nullptr,期望返回 161001 而非崩溃/UB)是闭合剩余不确定性的直接方式。我们也会继续确认三个旁支接口在自动生成 inner 层的实际行为,有结论后在此同步。
再次感谢您详尽的分析与严谨的核实。


fused_infer_attention_score @yue-ma
flash_mla_with_kvcache @xtqh
flash_attn @haijie_699874
quant_flash_attn @shen_weiling


Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
Describe the current behavior / 问题描述 (Mandatory / 必填)
fused_infer_attention_score_inner.cpp :186-:199 定义的共用辅助函数 FusedInferAttentionScoreProcessSoftmaxLse,在 softmaxLseFlag == true 分支直接 placeHolder = softmaxLse,不判空;softmaxLse == nullptr 时 nullptr 被原样下传至 inner GetWorkspaceSize。同一段逻辑共存在 4 份副本,全部缺少判空。
先说结论,避免误判严重级:FIA 主链路(V1–V4,V5 高置信同链路)在 inner 入口存在兜底判空(见“二、行为核实”),nullptr 不会到达 l0/kernel,不会崩溃,本单不是崩溃缺陷,实际主张为以下三点:
一、缺陷代码与副本分布
master 21983cdf(2026-09-21 逐行核验;与 2026-09-18 基线 12a3dd6617 一致):
// attention/fused_infer_attention_score/op_api/aclnn_fused_infer_attention_score_inner.cpp :186-:199 void FusedInferAttentionScoreProcessSoftmaxLse(bool softmaxLseFlag, const aclTensor *softmaxLse, const aclTensor *&tempTensor, const aclTensor *&placeHolder) { if (softmaxLseFlag == false) { std::vector<int64_t> shape = {0}; int64_t addr = 0xff; tempTensor = aclCreateTensor(shape.data(), shape.size(), aclDataType::ACL_FLOAT, shape.data(), 0, ACL_FORMAT_ND, shape.data(), shape.size(), static_cast<void *>(&addr)); placeHolder = tempTensor; } else { placeHolder = softmaxLse; // ← 未判空,nullptr 原样下传 } }副本与调用点分布:
旁证:aclnn_fused_infer_attention_score_v5.cpp 未复用共用函数,而是在 :132-:140 与 :222-:229 将同逻辑内联重写(同样无判空)——新代码已倾向绕开共用实现,但 4 份旧副本未收敛、未修正。
Describe the expected behavior / 预期结果 (Mandatory / 必填)
} else { if (softmaxLse == nullptr) { OP_LOGE(ACLNN_ERR_PARAM_NULLPTR, "When softmaxLseFlag is true, softmaxLse must be provided, but got nullptr."); return ACLNN_ERR_PARAM_NULLPTR; } placeHolder = softmaxLse; }Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
不涉及(host 侧静态审查,未上板)。全部证据为源码行号引用与代码片段,见问题描述;旁支三接口运行时行为待实机确认。