[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
- フォーク
- 862
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 61
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/TransformerEngine のほかの issue
-
[PyTorch] fp8_cs_quantize fake implementation returns a vector inverse scale instead of a scalar再び着手できるかも @sanjana658 が 13 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 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 が 47 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンattention
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
NVIDIA/TransformerEngine#3481 · コメント 4 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
NVIDIA/TransformerEngine#2189 · コメント 7 件 · リアクション 5 件 ·
メンテナーはふだん 2 日以内に返信
-
[PyTorch] FA2 is selected for head_dim > 192 with dropout on sm120, where flash-attn's backward launches no kernel対応中かも @0z5a が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 69/100
NVIDIA/TransformerEngine#3711 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
[BUG] Grouped MXFP8 activation kernels return all-zero output when tensor widths differ (CUDA 12.x builds)対応中かも @ravimajeti が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
NVIDIA/TransformerEngine#3703 ·
メンテナーはふだん 2 日以内に返信
NVIDIA/TransformerEngine の issue をすべて見る
似ている issue
-
Uninstall guide omits the CloudWatch log groups AWS CodeBuild creates for useCodeBuild pipelinesオープンbug documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
awslabs/visual-asset-management-system#552 ·
メンテナーはふだん 1 日以内に返信
-
netbox status: needs triage type: documentation
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
netbox-community/netbox#23460 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
awslabs/threat-composer#362 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ansys/pyansys-common-mcp#213 ·
メンテナーはふだん 3 日以内に返信