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

オープン
#21,070 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@tandede がすでに取り組んでいます。

2026年11月28日 から。

  • #21078 @tandede による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
13.9k
フォーク
4.1k
平均マージ
4日 22時間
マージ済み PR(30日)
22

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/tvm のほかの issue

apache/tvm の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。