[Bug] [Relax] ToMixedPrecision crashes with missing expr type on tuple-returning ops (batch_norm, dropout, topk, split)

Abierto
#21,070 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

@tandede ya está trabajando en esto.

Desde el 28/11/2026.

  • #21078 de @tandede — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
compilers

Línea de trabajo

Start by reproducing the crash with the provided SplitMod and BatchNormMod examples, then trace relax.transform.ToMixedPrecision to the GetType call that receives an expression with a missing type. Check how tuple-returning operators are handled, including dropout and topk, and add regression coverage for the listed cases. Done when ToMixedPrecision("float16") succeeds on normalized, well-formed modules containing these operators.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

needs-triage type: bug
Expected behavior

relax.transform.ToMixedPrecision("float16") should succeed on normalized, well_formed Relax IRModules containing standard tuple-returning operators such as R.nn.batch_norm, R.nn.dropout, R.topk(..., ret_type="both"), and R.split.

Actual behavior

Calling relax.transform.ToMixedPrecision("float16") on any Relax function containing a tuple-returning operator crashes immediately with an InternalError in tvm::relax::GetType(const Expr&) — even when relax.transform.Normalize() and relax.analysis.well_formed() are run immediately beforehand:

File "/project/include/tvm/relax/type.h", line 401, in tvm::Type tvm::relax::GetType(const Expr&)
tvm.error.InternalError: Check failed: (!expr->ty.IsMissing()) is false: The type is not populated, check if you have normalized the expr

Verified to crash identically on all of the following minimal 5-line modules:

  • R.nn.batch_norm(..., training=True)
  • R.nn.batch_norm(..., training=False)
  • R.nn.dropout(x, rate=0.5)
  • R.topk(x, k=3, axis=1, ret_type="both")
  • R.split(x, 2, axis=1)
Environment
  • TVM version: apache-tvm==0.27.0.post1
  • OS: Linux (x86_64)
  • Python: 3.12.x
  • Target: llvm (backend-independent — crashes inside relax.transform.ToMixedPrecision)
Steps to reproduce
import tvm
from tvm import relax
from tvm.script import ir as I, relax as R

@I.ir_module
class SplitMod:
    @R.function
    def main(x: R.Tensor((4, 8), "float32")) -> R.Tensor((4, 4), "float32"):
        with R.dataflow():
            t = R.split(x, 2, axis=1)
            y = t[0]
            R.output(y)
        return y

@I.ir_module
class BatchNormMod:
    @R.function
    def main(
        x: R.Tensor((2, 4, 4, 4), "float32"),
        g: R.Tensor((4,), "float32"),
        b: R.Tensor((4,), "float32"),
        m: R.Tensor((4,), "float32"),
        v: R.Tensor((4,), "float32"),
    ) -> R.Tensor((2, 4, 4, 4), "float32"):
        with R.dataflow():
            bn = R.nn.batch_norm(x, g, b, m, v, axis=1, training=False)
            y = bn[0]
            R.output(y)
        return y

for name, mod in [("split", SplitMod), ("batch_norm", BatchNormMod)]:
    mod = relax.transform.Normalize()(mod)
    relax.analysis.well_formed(mod)
    print(f"Running ToMixedPrecision on {name}...")
    relax.transform.ToMixedPrecision("float16")(mod)

Observed output on apache-tvm==0.27.0.post1:

Running ToMixedPrecision on split...
Traceback (most recent call last):
  ...
  File "/project/include/tvm/relax/type.h", line 401, in tvm::Type tvm::relax::GetType(const Expr&)
tvm.error.InternalError: Check failed: (!expr->ty.IsMissing()) is false: The type is not populated, check if you have normalized the expr

BatchNormMod (both training=False and training=True), R.nn.dropout, and R.topk(..., ret_type="both") crash with the exact same stack trace.

Triage
  • needs-triage
  • relax
Lenguaje dominante
Python
Estrellas
13.9k
Forks
4.1k
Merge medio
4 d 22 h
PR fusionados (30 d)
22

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

  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 apache/tvm

Todos los issues de apache/tvm

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.