Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[PyTorch] torch.compile fails on FusedAttnBackend IntEnum comparisons

Abierto
#3,716 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 2 días

@pggPL ya está trabajando en esto.

Desde el 20/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

bug

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.

Lenguaje dominante
Python
Estrellas
3.6k
Forks
862
Merge medio
4 d 12 h
PR fusionados (30 d)
60

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/TransformerEngine

Todos los issues de NVIDIA/TransformerEngine

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.