From f3fe2df6100a52029fc1d017cc5da32e3bc018e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=88=AA=E5=AE=87?= <3364451258@qq.com> Date: Sat, 13 Jun 2026 14:45:32 +0800 Subject: [PATCH] =?UTF-8?q?revert:=20=E7=A7=BB=E9=99=A4=E6=89=80=E6=9C=89?= =?UTF-8?q?=20torch.compile=EF=BC=88=E5=9B=9B=E6=88=98=E5=85=A8=E8=B4=A5?= =?UTF-8?q?=EF=BC=89=EF=BC=8C=E5=9B=9E=E5=88=B0=E7=A8=B3=E5=AE=9A=E7=89=88?= =?UTF-8?q?=2058.49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit torch.compile 全模式验证: - reduce-overhead: 199s (+126%) - default 全模型: 118s (+34%) - default Expert: 108.6s (+23%) - dynamic=True: 102.6s (+17%) MoE 动态路由 + 可变序列长度,与任何 JIT 编译不兼容 --- 代码/code/infer.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/代码/code/infer.py b/代码/code/infer.py index 77f5250..9bca191 100644 --- a/代码/code/infer.py +++ b/代码/code/infer.py @@ -504,14 +504,6 @@ def load_model(ckpt_path, device='cuda:0'): print(f"[WARNING] Checkpoint {ckpt_path} not found, using random weights") model.to(dev) - - # === torch.compile + dynamic=True:告知编译器形状可变,避免重编译 === - try: - model = torch.compile(model, dynamic=True) - print(f"[INFO] torch.compile applied (dynamic=True)") - except Exception as e: - print(f"[WARNING] torch.compile failed ({e}), using original model") - model.eval() print(f"[INFO] Model ready. Device: {dev}")