[PyTorch] torch.compile fails on FusedAttnBackend IntEnum comparisons
Maintainer thường phản hồi trong vòng 2 ngày
@pggPL đang làm issue này rồi.
Từ ngày 20/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 3.6k
- Fork
- 872
- Merge trung bình
- 4 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 60
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA/TransformerEngine
-
[PyTorch] fp8_cs_quantize fake implementation returns a vector inverse scale instead of a scalarCó thể làm lại được @sanjana658 đã nhận 13 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA/TransformerEngine#3636 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] Backend selection picks FA3 for training with head_dim_qk=192 / v_head_dim=128, but FA3 backward cannot run itCó thể làm lại được @modelpath-dev đã nhận 47 ngày trước và không có pull request nào đang mở. Đang mởattention
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
NVIDIA/TransformerEngine#3481 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Increase MAX_TENSOR_NUMĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
NVIDIA/TransformerEngine#2189 · 7 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Feature] Fused gated RMSNorm (RMSNorm(x) * SiLU(gate)) for GDN output normCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
NVIDIA/TransformerEngine#3724 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
NVIDIA/TransformerEngine#3720 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của NVIDIA/TransformerEngine
Issue tương tự
-
comp/tools P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NousResearch/hermes-agent#142908 · 1 bình luận ·
-
[oblt-aw][autodoc] Fix malformed headings in new Buildkite docs pagesCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mởdocumentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offlineCó thể đã có người làm @r2jaff đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ComposioHQ/composio#5054 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
pytorch/tensordict#3286 ·
Maintainer thường phản hồi trong vòng 1 ngày