[Bug][FFI] save_json / ToJSONGraph segfaults on a trivial IRModule in 0.26.0 (also breaks MetaSchedule tuner)

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

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

まだ誰も着手していません。

評価

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

調査の方向性

Start by running the four-line reproduction in the issue, which calls tvm.ir.save_json on a trivial IRModule and segfaults inside tvm::ffi::ToJSONGraph. The issue links this to PR #19662, which routed JSON serialization through tvm-ffi, so begin with that change and the native ToJSONGraph code it touched. Done means save_json returns a string on x86_64 and aarch64 and the MetaSchedule tune_tir reproduction no longer crashes.

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

説明

Expected behavior

tvm.ir.save_json(mod) returns a JSON string for a valid IRModule.

Actual behavior

On the 0.26.0 release, tvm.ir.save_json() segfaults (SIGSEGV, core dumped) on even a trivial IRModule. The native backtrace points at tvm::ffi::ToJSONGraph:

!!!!!!! Segfault encountered !!!!!!!
  File "<unknown>", line 0, in tvm::ffi::ToJSONGraph(tvm::ffi::Any const&, tvm::ffi::Any const&)
  File "<unknown>", line 0, in _PyObject_MakeTpCall
  ...
Segmentation fault (core dumped)

Because MetaSchedule routes workload/record serialization through this same path, this also makes the tuner unusable on this build: ms.tune_tir(...) and ms.relax_integration.tune_relax(...) both crash with the identical ToJSONGraph backtrace during setup/task-extraction (exit 139), even with an in-memory MemoryDatabase. MemoryDatabase.commit_workload(single_primfunc) by itself does not crash, so the fault appears to be in the JSON-graph serialization specifically.

Minimal reproducible example
import tvm
from tvm import te

A = te.placeholder((8,), "float32", name="A")
C = te.compute((8,), lambda i: A[i] * 2.0, name="C")
mod = tvm.IRModule({"main": te.create_prim_func([A, C])})

tvm.ir.save_json(mod)   # -> SIGSEGV in tvm::ffi::ToJSONGraph
Environment
  • TVM: 0.26.0 (release wheel)
  • Python: 3.12.3
  • OS: Linux x86_64, glibc 2.39
  • The same crash reproduces on aarch64, where it surfaces as SIGBUS instead of SIGSEGV.
Possible cause

This looks related to #19662 ("[FFI][IR] Route JSON serialization through tvm-ffi"), which moved JSON serialization through tvm-ffi — the layer where ToJSONGraph lives. Happy to test a patch or provide a core dump.

主要言語
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 を短くまとめたダイジェスト。