已关闭
[Requirement|需求建议]: 迁移 AddLayerNorm→InplaceAddLayerNorm 融合规则至 op_graph #5108
rk创建于  12 天前关闭于  10 天前
rk成员
12 天前 创建

一、背景信息(Backgroud)

AddLayerNorm→InplaceAddLayerNorm 融合规则原先存在于其他路径,需要将其迁移至 graph base(op_graph)路径,使用 graph_metadef 的原生 Graph/GNode 接口改图,与已有算子实现形成完整闭环。InplaceAddLayerNorm 将 x1/x2 原地写回,省去额外输出拷贝,降低显存占用与访存开销。

二、信息来源(Origin)

ops-nn 仓库 inplace_add_layer_norm 算子融合规则路径迁移需求。

三、价值/作用(Benefit / Necessity)

  • 将融合规则统一迁移至 op_graph 路径,使用原生 Graph/GNode 接口改图,便于维护与后续演进;
  • 推理场景下减少 x1/x2 的显存拷贝,降低显存占用与带宽开销;
  • 通过多重守卫(场景/平台/独占性/shape/dtype)保证仅在安全且有益的场景下触发,避免正确性风险。

四、设计方案(Design)

  • 迁移实现 ZInplaceAddLayerNormFusionPass,继承 FusionBasePass,使用 graph_metadef 原生 Graph/GNode 接口改图;
  • Run 入口先做全局守卫(场景、平台,只判一次),再扫图取 AddLayerNorm 候选,逐节点过守卫链后执行单节点替换,替换失败整图回退;
  • 守卫链:场景(训练跳过、CANN<9.0.0 静默)、平台(910B/910_93/950)、独占性(x1/x2 独占消费)、shape(静态按 L2 上下界、动态仅 reduce 轴 5120)、dtype(x1/x2/gamma 同型);
  • 属性 epsilon/additional_output 原样透传。

关联 PR:https://gitcode.com/cann/ops-nn/pull/9018

likedislike
Rrk成员
12 天前 添加了label:requirement
yuning_chenyuning_chen成员
11 天前 将 wangpengbo26 设为负责人
CANN-robotCANN-robot成员
10 天前 关闭了 issue
CANN-robotCANN-robot成员
10 天前 添加了label:resolved