gemini-code-assist[bot] commented on code in PR #644:
URL: https://github.com/apache/tvm-ffi/pull/644#discussion_r3475784205
##########
python/tvm_ffi/_optional_torch_c_dlpack.py:
##########
@@ -134,7 +135,17 @@ def load_torch_c_dlpack_extension() -> Any: # noqa:
PLR0912, PLR0915
major, minor = torch.__version__.split(".")[:2]
device = _torch_extension_device(torch)
suffix = ".dll" if sys.platform.startswith("win") else ".so"
- libname =
f"libtorch_c_dlpack_addon_torch{major}{minor}-{device}{suffix}"
+ # The addon is a compiled extension that links libtorch's C++ ABI, so
its
+ # cache key must capture the full torch build identity -- not just
+ # major.minor + device. ``torch.__version__`` carries the patch
version and
+ # build tag (e.g. "+cu124", "+rocm6.2", "+cpu"); we also fold in the
C++ ABI
+ # flag. Without this, two ABI-incompatible torch builds that share
+ # major.minor + device resolve to the same cached ``.so``, and a
shared cache
+ # directory (NFS home, reused container images) silently loads a
mismatched
+ # addon -> crashes or wrong tensor data instead of a clean rebuild.
+ abi_id = f"{torch.__version__}|cxx11abi={int(getattr(torch._C,
'_GLIBCXX_USE_CXX11_ABI', True))}"
Review Comment:

Using the public `torch.compiled_with_cxx11_abi()` function is preferred
over accessing the private `torch._C` module directly. This is also consistent
with how the C++11 ABI check is performed in
`_build_optional_torch_c_dlpack.py`.
```suggestion
abi_id =
f"{torch.__version__}|cxx11abi={int(torch.compiled_with_cxx11_abi())}"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]