The GitHub Actions job "CI" on tvm-ffi.git/pyobject has failed.
Run started by GitHub user cyx-6 (triggered by cyx-6).

Head commit for run:
83bb1e9421c6cdb1eedf1ed822d72c40d981ad1e / Yaxing Cai <[email protected]>
[FEAT][Python] Tie Python wrapper lifetime to underlying C++ FFI object

Bind one Python wrapper to one C++ FFI object ("chandle") for the object's
lifetime, so identity is stable: `a.x is a.x`, `id(a.x)` stable across
drop+refetch, and `f(x) is x` for FFI returns. Works on both the GIL and
free-threaded (3.14t) builds.

Allocation layout:
- Two-layer custom-allocator hook in core libtvm_ffi (TVMFFIObjectAllocHeader +
  TVMFFICustomAllocator registry); frontends override the process-wide default.
- The Cython module installs TVMFFIPyAllocate, prepending a 16-byte
  PyCustomAllocHeader that encodes the wrapper binding. Rust and the reflection
  dataclass path route through the same registry.

Binding state machine (python/tvm_ffi/cython/tvm_ffi_python_object.h):
- A tagged word (tagged_pyobj) holds the wrapper back-pointer plus low tag bits:
  Detached / Active / Inactive / InTransit. Every FFI return funnels through
  make_ret_object, reviving an Inactive cached allocation in place for a stable
  id(). Cache-vs-free handshake across tp_dealloc / tp_free / delete_space.
- Free-threaded build: the word doubles as a per-word spin-lock (raw atomics in
  namespace pyobj_detail); make_ret holds the lock across its alloc (InTransit 
is
  the dealloc handshake's baton only). Active-hit revival uses 
PyUnstable_TryIncRef.
  GIL build is byte-identical (all FT machinery behind #ifdef Py_GIL_DISABLED).

Robustness fixes folded in: fix a double free when tp_new fails on the revival
path; reject re-registering a type with a larger wrapper class (size-aware, so
the enum binder's same-size rebinding still works); rebind before nulling the
source handle in __move_handle_from__.

Rebased onto main: route __ffi_new__ through the custom allocator while keeping
ConstructPyClassFields for the separated-native-lifetime dataclass path.

Also: drop cp38 from the cibuildwheel matrix (requires-python is >=3.9); require
cython>=3.2.8 for the free-threaded __dealloc__ keep-alive fix (cython#7769).

Test plan: new tests/python/test_pyobject_tying.py (Active/Inactive/InTransit
transitions, cache-on aliasing, _move(), pickle/threading/GC stress, finalizer
exclusion, free-threaded carrier stress). Full suite passes on 3.13 (GIL) and
3.14t (free-threaded).

Co-Authored-By: Yaoyao Ding <[email protected]>

Report URL: https://github.com/apache/tvm-ffi/actions/runs/29399759792

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to