[PyTorch] torch.compile fails on FusedAttnBackend IntEnum comparisons
维护者通常 2 天内回复
@pggPL 已经在做这个了。
开始于 2026年10月20日。
评估
这个 Issue 还没有评估数据。
描述
Describe the bug
torch.compile(fullgraph=True) fails in TE's fused DotProductAttention path when comparing FusedAttnBackend members:
fused_attention_backend != FusedAttnBackend["No_Backend"]
-> FusedAttnBackend.__ne__
-> FusedAttnBackend.__eq__
-> int.__eq__(self, other)
torch._dynamo.exc.Unsupported: Missing tp_richcompare_impl override
Developer debug context:
tp_richcompare_impl UserDefinedObjectVariable(FusedAttnBackend) __eq__
This affects the fused DPA cases in tests/pytorch/test_torch_compile.py, before an attention kernel runs. The same failure can be reproduced using only PyTorch on CPU.
Minimal reproduction
from enum import IntEnum
import torch
class Backend(IntEnum):
NO = 0
YES = 1
def __eq__(self, other):
return int.__eq__(self, other)
def __ne__(self, other):
result = self.__eq__(other)
return result if result is NotImplemented else not result
def f(x, backend):
return x + 1 if backend != Backend.NO else x - 1
x = torch.ones(2)
print("eager:", f(x, Backend.YES))
print("compiled:", torch.compile(f, backend="eager", fullgraph=True)(x, Backend.YES))
Expected behavior
Both calls return tensor([2., 2.]). The compiled call instead raises the Dynamo error above.
Environment
- CPU reproduction: Linux x86_64, Docker, Python 3.12.3.
- PyTorch:
2.15.0a0+fd23299d96.nvinternal.main. - The reproducer requires neither TE nor CUDA.
- The original TE failures were observed on A100, H100, B200, and GB200.
Upstream diagnosis and existing fix
The regression was introduced by pytorch/pytorch@95dddcf5d6388e7216717857b546df7cbfa073a7, “Remove _base_vt” (pytorch/pytorch#193679). With the same installed PyTorch binaries, importing the complete Dynamo sources from its parent 8ab021bb passes the reproducer; importing the sources from 95dddcf5 fails.
BuiltinVariable.call_method routes int.__eq__ through call_base_method before reaching the existing constant-folding path for explicit comparisons. Enum members use UserDefinedObjectVariable, whose MRO lacks the ConstantVariable implementation required by that route.
The open pytorch/pytorch#199496 (“Support unbound builtin method descriptors”, by KarhouTam) removes this early dispatch as part of a broader fix. Applying its relevant isolated change resolves this reproducer and passes 105 focused comparison checks; the full PR has not been validated here.
As of 2026-10-20, PyTorch main at ec16340feb88f278c3a76ded17e21ec3a143c7c4 still contains the problematic dispatch ordering (source inspection). This issue tracks the impact on TE and the upstream resolution.
- 主要语言
- Python
- 星标
- 3.6k
- 派生
- 872
- 平均合并
- 4 天 11 小时
- 30 天内合并 PR
- 59
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/TransformerEngine 的其他 Issue
-
[PyTorch] fp8_cs_quantize fake implementation returns a vector inverse scale instead of a scalar可能重新可做 @sanjana658 于 15 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
NVIDIA/TransformerEngine#3636 · 2 条评论 ·
维护者通常 2 天内回复
-
[Bug] Backend selection picks FA3 for training with head_dim_qk=192 / v_head_dim=128, but FA3 backward cannot run it可能重新可做 @modelpath-dev 于 49 天前认领,目前没有进行中的 PR。 未关闭attention
难度 2/5 1-3 小时 新手友好度 85/100
NVIDIA/TransformerEngine#3481 · 4 条评论 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
NVIDIA/TransformerEngine#2189 · 7 条评论 · 5 个 reaction ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
NVIDIA/TransformerEngine#3729 ·
维护者通常 2 天内回复
-
[Feature] Fused gated RMSNorm (RMSNorm(x) * SiLU(gate)) for GDN output norm可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭enhancement
难度 5/5 一周以上 新手友好度 35/100
NVIDIA/TransformerEngine#3724 · 1 个 reaction ·
维护者通常 2 天内回复
查看 NVIDIA/TransformerEngine 的全部 Issue
相似的 Issue
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
难度 2/5 1-3 小时 新手友好度 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
难度 2/5 1-3 小时 新手友好度 70/100
NCAR/miles-credit#526 ·
-
documentation
难度 1/5 1-3 小时 新手友好度 76/100
conda/conda-lock#957 ·
维护者通常 1 天内回复
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
aws-samples/sample-per-model-bedrock#464 ·
维护者通常 1 天内回复