Closed
[Bug-Report|缺陷反馈]: SparseApplyAdadelta 更新公式运算顺序错误、tiling/infershape 缺少入参与溢出校验 #8581
renshuojianAdd on 11 days agoClosed at 9 days ago
11 days ago Added label: bug-report
11 days ago Assign rsj007 as responsible person
9 days ago Close issue
9 days ago changed custom state from 待办的 to 已完成
9 days ago Added label: resolved
Describe the current behavior / 问题描述 (Mandatory / 必填)
SparseApplyAdadelta算子存在以下缺陷:update计算为sqrtf(numer) * (g / sqrtf(denom)),先做除法再做乘法。当denom很大、g很小时,g / sqrt(denom)中间结果会下溢为 0 或产生明显精度偏差;与 README 公式及 TensorFlow 参考实现的(sqrt(numer) / sqrt(denom)) * g不等价。kCount、varShapeSize未做负值判断与乘法溢出检查(MulOverflow),未校验var秩非零、indices为一维;核数计算使用较小位宽类型,大 shape 下存在溢出后SetBlockDim异常的风险。var/accum/accum_update/grad/indices秩至少为 1、accum/accum_update与var逐维形状一致、indices为一维、lr/rho/epsilon为标量。非法输入不会返回GRAPH_FAILED,而是进入后续流程,存在越界访问与结果错误风险。GetScalarFloat读取lr/rho/epsilon并写入SparseApplyAdadeltaTilingData,增加了 tiling 数据依赖与主机侧开销(属加固项,非功能缺陷)。Environment Information / 环境信息 (Mandatory / 必填)
950
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
SparseApplyAdadelta可正常调用。denom极大(如1e20)、grad极小(如1e-20)的输入执行算子,与 TF 参考实现对比update结果。varShapeSize乘积溢出的 shape,或将kCount/varShapeSize传入负值,观察 tiling 是否拦截。var与accum形状不一致,如var = [3, 4]、accum = [4, 4];var为 0 维标量;indices为 2 维;lr/rho/epsilon为非标量(如 1 维);观察是否返回失败。
Describe the expected behavior / 预期结果 (Mandatory / 必填)
update按(sqrt(numer) / sqrt(denom)) * g计算,与 README 公式及 TF 参考实现一致,极小/极大值场景不出现中间商下溢与精度偏差。kCount、varShapeSize的负值与乘法溢出进行拦截并返回明确错误码;var秩非零、indices一维校验不通过时直接失败;核数计算全程使用int64后再SetBlockDim。GRAPH_FAILED,并输出明确的校验失败日志;合法输入形状推导结果保持不变。lr/rho/epsilon由 kernel 直接从 GM 读取,tiling 不再下发对应标量字段,行为与精度不变。Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
// 问题 1:中间商下溢
grad/sqrt(denom) = 1e-20 / 1e10 = 0(下溢)
期望 (sqrt(numer)/sqrt(denom))*grad != 0
// 问题 2:溢出不拦截
kCount = -1 / varShapeSize 溢出,tiling 未返回失败
// 问题 3:非法形状未拦截
var=3,4, accum=4,4 -> infershape 未返回 GRAPH_FAILED
var 为 0 维 / indices 为 2 维 / lr 为 1 维 -> 未返回 GRAPH_FAILED
Special notes for this issue/备注 (Optional / 选填)