已合并
add t5 config #44032
lihui创建于 15 天前
add t5 config #44032
已合并
共 1 个文件变更+9-0
| @@ -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 | ||
🟡 Medium Priority
变更行 633-636:新增的
from torch._higher_order_ops.effects import (_EffectType, _register_effectful_op)未被 try/except 包裹。受影响的合约:
_patch_model_24()被@register_patch("T5ForConditionalGeneration")注册,当运行 T5ForConditionalGeneration 基准测试时被调用。失败模式:
torch._higher_order_ops.effects是 PyTorch 内部模块(模块路径和导出符号均带_前缀,不是公开 API),在 PyTorch 版本升级后内部结构可能发生变更(模块重命名、符号移除/改名)。一旦发生,import会抛出未处理的ImportError,导致 T5ForConditionalGeneration 基准测试直接崩溃。证据:同一函数内,上方的
torch_npu._inductor.ascend_npu_ir导入(第 625-632 行)使用了 try/except 包裹,允许ImportError时仅记录 warning 并继续;而新增的代码没有遵循这一模式。本文件中_patch_model_19、_patch_model_20等也对其关键导入做了 try/except 保护。建议:将第 633-641 行包裹在 try/except 中:try 块内完成 import 和 _register_effectful_op 调用;except ImportError 时记录 warning 并安全返回(或继续执行后续代码,取决于设计意图)。