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

Ouverte
#21,054 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
22/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
cpp, python
Domaine
compilers

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
13.9k
Forks
4.1k
Merge moyen
4 j 22 h
PR mergées (30 j)
22

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de apache/tvm

Toutes les issues de apache/tvm

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.