torch.compile的推理优化模式?reduce-overhead vs max-autotune?torch.compile的推理优化模式?reduce-overhead vs max-autotune?
torch.compile 对模型做图捕获与优化(TorchDynamo + Inductor 等)。推理时可指定 mode:mode="reduce-overhead" 侧重降低 Python 与调度开销(如减少 Python 调用、融合 kernel);mode="max-autotune" 侧重 极致性能,会做更多 kernel 搜索与选型,编译更慢、运行时更快。
mode="default"):介于两者之间。推理常用 reduce-overhead 做延迟优化,或 max-autotune 做吞吐优化;训练一般不用 max-autotune(编译与显存成本高)。torch.compile(model, mode="reduce-overhead");大 batch 或离线优化:mode="max-autotune"。fullgraph=True(若可行)减少 Python 回退;首次运行会编译,可做 warmup。| 返回模块 | 返回总览 |