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

Đang mở
#21,054 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, python
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
13.9k
Fork
4.1k
Merge trung bình
4 ngày 22 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/tvm

Tất cả issue của apache/tvm

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.