ai-infra-interview-305

第 100 题:torch.compile的推理优化模式?reduce-overhead vs max-autotune

题目

torch.compile的推理优化模式?reduce-overhead vs max-autotune


完整讲解

一、torch.compile 的推理模式

torch.compile 对模型做图捕获与优化(TorchDynamo + Inductor 等)。推理时可指定 modemode="reduce-overhead" 侧重降低 Python 与调度开销(如减少 Python 调用、融合 kernel);mode="max-autotune" 侧重 极致性能,会做更多 kernel 搜索与选型,编译更慢、运行时更快。

二、reduce-overhead vs max-autotune

三、使用建议


面试要点


记忆要点

  1. reduce-overhead = 低延迟、少 overhead;max-autotune = 高吞吐、慢编译。
  2. 推理延迟用 reduce-overhead;吞吐用 max-autotune。
  3. 首次运行编译,需 warmup。
返回模块 返回总览