已合并
add t5 config #44026
lihui创建于 13 天前
add t5 config #44026
已合并
共 2 个文件变更+9-9
| @@ -630,6 +630,15 @@ def _patch_model_24(): | |||
| 630 | anir_config.force_fallback_kernel_names["mlir_fused_add_lt_neg_where_13"] = True | 630 | anir_config.force_fallback_kernel_names["mlir_fused_add_lt_neg_where_13"] = True |
| 631 | except ImportError: | 631 | except ImportError: |
| 632 | log.warning("import config failed for T5ForConditionalGeneration patch") | 632 | log.warning("import config failed for T5ForConditionalGeneration patch") |
| 633 | + from torch._higher_order_ops.effects import ( | ||
| 634 | + _EffectType, | ||
| 635 | + _register_effectful_op, | ||
| 636 | + ) | ||
| 637 | + | ||
| 638 | + _register_effectful_op( | ||
| 639 | + torch.ops.aten.native_dropout.default, | ||
| 640 | + _EffectType.ORDERED, | ||
| 641 | + ) | ||
| 633 | 642 | ||
| 634 | 643 | ||
| 635 | 644 | ||
| @@ -4,15 +4,6 @@ import torch | |||
| 4 | from torch._decomp import remove_decompositions | 4 | from torch._decomp import remove_decompositions |
| 5 | from torch._inductor import decomposition as inductor_decomp | 5 | from torch._inductor import decomposition as inductor_decomp |
| 6 | from torch_npu._inductor.mfusion.decomp import matmul_backward | 6 | from torch_npu._inductor.mfusion.decomp import matmul_backward |
| 7 | -from torch._higher_order_ops.effects import ( | ||
| 8 | - _EffectType, | ||
| 9 | - _register_effectful_op, | ||
| 10 | -) | ||
| 11 | - | ||
| 12 | -_register_effectful_op( | ||
| 13 | - torch.ops.aten.native_dropout.default, | ||
| 14 | - _EffectType.ORDERED, | ||
| 15 | -) | ||
| 16 | 7 | ||
| 17 | aten = torch.ops.aten | 8 | aten = torch.ops.aten |
| 18 | prims = torch.ops.prims | 9 | prims = torch.ops.prims |
🟡 Medium Priority
变更行:
torch_npu/_inductor/dvm/decomp.py第 7–15 行(删除)→benchmarks/torchbench/npu_support.py第 633–641 行(新增)影响的行为/合约:
失效模式: 非 T5ForConditionalGeneration 的模型(以及非 benchmark 场景下使用 DVM 的所有模型)将缺少
native_dropout的 ORDERED effectful 注册。PyTorch Inductor 编译器可能因此对native_dropout进行不当优化(消除、重排、CSE),在训练模式下导致 dropout 行为异常。触发条件:任何非 T5ForConditionalGeneration 模型经过 DVM 编译路径(
mlir_fusion.mfusion_graph_fusion→patch_decomp→ Inductor lowering)时,native_dropout将不被视为有副作用的操作。建议:将
_register_effectful_op调用恢复到torch_npu/_inductor/dvm/decomp.py模块顶层(或在torch_npu/_inductor初始化路径中找一个合适的全局位置),确保对所有 DVM 编译路径生效。T5 benchmark patch 中可保留该调用作为兜底,或在确认全局注册已生效后移除此处重复调用。