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

Aperta
#21,070 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@tandede ci sta già lavorando.

Dal 28/11/2026.

  • #21078 di @tandede — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
13.9k
Fork
4.1k
Merge medio
4g 22h
PR unite (30g)
22

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/tvm

Tutte le issue di apache/tvm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.