[Bug][Relax][PyTorch] float64 `matmul` / `mm` / `conv` results are downcast to float32 by `from_exported_program`
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- machine-learning
Línea de trabajo
The float32 cast is likely hard-coded in the matmul, mm, addmm and conv converters of the PyTorch frontend under python/tvm/relax/frontend/torch, so start by searching there for out_dtype="float32". Reproduce with the matmul snippet in the issue and the Linear-with-bias case, which currently raises a TypeError. Done means float64 and bfloat16 inputs keep their dtype, and the bias case converts and matches eager output.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Expected behavior
torch.mm on float64 inputs returns float64. The model converted with from_exported_program should keep the dtype and precision.
Actual behavior
The result is silently float32, so the precision is lost. The same happens for torch.matmul, torch.einsum, Conv1d, Conv2d, ConvTranspose2d and Linear without bias, and for bfloat16 inputs. With a float64 bias (Linear, Conv2d), the conversion fails instead:
eager: torch.float64 [[5.0000000002]]
tvm: float32 [[5.0]]
TypeError: Binary operators must have the same datatype for both operands.
Possibly out_dtype="float32" is hard-coded in the matmul, mm, addmm and conv converters.
Environment
- TVM: main @
2bf0532(0.28.dev0), built from source, targetllvm - PyTorch: 2.12.0+cu130
- Python: 3.12, Ubuntu x86_64
Steps to reproduce
import torch
import tvm
import tvm_tirx
from tvm import relax
from tvm.relax.frontend.torch import from_exported_program
class M(torch.nn.Module):
def forward(self, x):
return torch.mm(x, x.T)
x = torch.tensor([[1.0 + 1e-10, 2.0]], dtype=torch.float64)
e = M()(x)
print("eager:", e.dtype, e.tolist())
ep = torch.export.export(M(), (x,))
mod = from_exported_program(ep)
ex = tvm.compile(mod, target="llvm")
vm = relax.VirtualMachine(ex, tvm_tirx.cpu())
out = vm["main"](tvm_tirx.runtime.tensor(x.numpy()))[0].numpy()
print("tvm: ", out.dtype, out.tolist())
# With a bias, the conversion itself fails
m = torch.nn.Linear(2, 2, dtype=torch.float64)
ep = torch.export.export(m, (x,))
from_exported_program(ep)
- Lenguaje dominante
- Python
- Estrellas
- 13.9k
- Forks
- 4k
- Merge medio
- 7 h 59 min
- PR fusionados (30 d)
- 159
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/tvm
-
needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Los mantenedores suelen responder en 1 día
-
[Bug] [Relax][ONNX] OneHot does not convert floating-point depth to int64Posiblemente ocupada @tandede la tomó hace 2 días. Abiertoneeds-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
[Bug][Relax] ReorderTakeAfterMatmul fails on vector dot productsPosiblemente ocupada @hiyufan la tomó hace 12 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
apache/tvm#20595 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/tvm
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
strawberry-graphql/strawberry#4794 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dataforgoodfr/cetolog#21 ·
-
security_citations_test fails against ecc 2026.11.6: SECURITY.md quotes ecc v2026.11.2's linesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
btclib-org/btclib#2932 ·
Los mantenedores suelen responder en 1 día
-
metrics priority: medium
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
LearningCircuit/local-deep-research#8336 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100