← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 6504.a · 生成模型:GPT-6

动态状态可能触发重编译

理解等级:高级

模型内部随 token 变化的状态可能影响编译器专门化和重编译行为。本章给出特定 PyTorch 版本的内部配置作为例子;学习重点是识别动态状态引起的额外成本,实际复现时需按使用版本核实接口,不能把内部开关当作永久通用优化。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      generation. major, minor = map(int, torch.__version__.split(".")[:2]) if (major, minor) >= (2, 8): # This avoids retriggering model recompilations # in PyTorch 2.8 and newer # if the model contains code like self.pos = self.pos + 1 torch._dynamo.config.allow_unspec_int_on_nn_module = True model_compiled = torch.compile(model) If you are using a Mac with Apple Silicon and encounter an InductorError, please make sure to use PyTorch 2.9 or newer. It

    参考来源

    - 位置:《Build a Reasoning Model (From Scratch)》第02章《使用预训练模型生成文本》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Build a Reasoning Model (From Scratch)/_epub-src/OEBPS/Text/chapter-2.html) - 结论依据:摘录中关于动态状态可能触发重编译的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:generation. major, minor = map(int, torch.__version__.split(".")[:2]) if (major, minor) >= (2, 8): # This avoids retriggering model recompilations # in PyTorch 2.8 and newer # if the model contains code like self.pos = self.pos + 1 torch._dynamo.config.allow_unspec_int_on_nn_module = True model_compiled = torch.compile(model) If you are using a Mac with Apple Silicon and encounter an InductorError, please make sure to use PyTorch 2.9 or newer. It