已合并
add t5 config #44032
add t5 config #44032
已合并
lihui创建于 15 天前
1 个文件变更+9-0
Mbenchmarks/torchbench/npu_support.py+9-0
@@ -630,6 +630,15 @@ def _patch_model_24():
630 anir_config.force_fallback_kernel_names["mlir_fused_add_lt_neg_where_13"] = True630 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+ )
atomgit-bot
atomgit-botatomgit-bot15 天前

🟡 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 并安全返回(或继续执行后续代码,取决于设计意图)。

likedislike
633 642 
634 643 
635@register_patch("BartForCausalLM")644@register_patch("BartForCausalLM")