Repository navigation
[Runtime][Disco] Fix session attribute storage, NVSHMEM build, and test gating - #19736
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors and improves the robustness of the Disco distributed runtime tests. Key changes include adding __slots__ = ("__dict__",) to several Disco classes to allow dynamic Python-side attributes, introducing a centralized SocketSessionTester utility to manage socket sessions and remote nodes, and refactoring NVSHMEM tests to run in fresh processes to prevent undefined behavior from repeated initializations. Feedback on these changes highlights potential hang risks in the new SocketSessionTester implementation, specifically recommending configuring the server thread as a daemon and adding a timeout to thread.join() to prevent indefinite blocking in CI environments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
147bea9 to
ea9a9f6
Compare
ea9a9f6 to
f54f538
Compare
…st gating
The tvm_ffi Object metaclass now gives every subclass `__slots__ = ()`, so
the Disco Python wrappers can no longer store instance attributes and every
session construction fails with AttributeError. Declare the attributes each
wrapper actually stores as named slots, fix the NVSHMEM dist_gemm.cu so TVM
builds with USE_NVSHMEM = ON, and gate the disco tests on the disco runtime
being present so they skip cleanly on builds (e.g. the pip wheel) that report
USE_NCCL / USE_NVSHMEM = ON without shipping it.
Session attribute storage
- DPackedFunc / DModule: `__slots__ = ("session",)`.
- Session: `__slots__ = ("_cache", "_import_python_module")`, and look up
the cache slot with `hasattr` instead of reading `self.__dict__`.
NVSHMEM build
- src/runtime/extra/contrib/nvshmem/dist_gemm.cu failed to compile under
USE_NVSHMEM = ON after the tvm-ffi migration: `GetDataSize` now lives in
namespace tvm::ffi, and the `LOG(FATAL)` macros are no longer in scope.
Qualify the call as `ffi::GetDataSize` and replace the
`if (worker == nullptr) LOG(FATAL) << ...` checks with
`TVM_FFI_ICHECK(worker != nullptr) << ...` (the idiom already used in this
file; it throws ffi::Error, so the behavior is unchanged). No logic change.
Test gating
- Add a `tvm.testing.requires_nvshmem` feature that probes the
`runtime.disco.nvshmem.init_nvshmem_uid` runtime function rather than the
cmake flag (a flag can be ON in a build that does not ship the runtime).
- test_session.py / test_nvshmem.py: skip at module level when the disco
runtime is absent (`tvm.runtime.disco is None`), so the socket-session
helpers they define are never reached and the modules skip cleanly instead
of erroring at collection.
- test_loader.py: skip at module level unless `runtime.disco.compiled_ccl`
reports "nccl" (the same source of truth as test_ccl.py), and require two
GPUs via tvm.testing.requires_multi_gpu.
- test_nvshmem.py: gate every test on NVSHMEM support and on the machine
having one CUDA device per worker; run each body in a freshly spawned
process with a timeout, because nvshmem_init may run only once per process
and disco worker-0 lives in the test process (pytest previously ran all
bodies in one process); replace the hand-rolled __main__ matrix with
tvm.testing.main().
f54f538 to
7f5c3bd
Compare
…st gating (apache#19736) The tvm_ffi Object metaclass now gives every subclass `__slots__ = ()`, so the Disco Python wrappers can no longer store instance attributes and every session construction fails with AttributeError. Declare the attributes each wrapper actually stores as named slots, fix the NVSHMEM `dist_gemm.cu` so TVM builds with `USE_NVSHMEM = ON`, and gate the disco tests on the disco runtime being present so they skip cleanly on builds (e.g. the pip wheel) that report `USE_NCCL` / `USE_NVSHMEM = ON` without shipping it. ### Session attribute storage - `DPackedFunc` / `DModule`: `__slots__ = ("session",)`. - `Session`: `__slots__ = ("_cache", "_import_python_module")` (cherry picked from commit b57d0b3)
…st gating (apache#19736) The tvm_ffi Object metaclass now gives every subclass `__slots__ = ()`, so the Disco Python wrappers can no longer store instance attributes and every session construction fails with AttributeError. Declare the attributes each wrapper actually stores as named slots, fix the NVSHMEM `dist_gemm.cu` so TVM builds with `USE_NVSHMEM = ON`, and gate the disco tests on the disco runtime being present so they skip cleanly on builds (e.g. the pip wheel) that report `USE_NCCL` / `USE_NVSHMEM = ON` without shipping it. ### Session attribute storage - `DPackedFunc` / `DModule`: `__slots__ = ("session",)`. - `Session`: `__slots__ = ("_cache", "_import_python_module")` (cherry picked from commit b57d0b3)
…st gating (#19736) The tvm_ffi Object metaclass now gives every subclass `__slots__ = ()`, so the Disco Python wrappers can no longer store instance attributes and every session construction fails with AttributeError. Declare the attributes each wrapper actually stores as named slots, fix the NVSHMEM `dist_gemm.cu` so TVM builds with `USE_NVSHMEM = ON`, and gate the disco tests on the disco runtime being present so they skip cleanly on builds (e.g. the pip wheel) that report `USE_NCCL` / `USE_NVSHMEM = ON` without shipping it. ### Session attribute storage - `DPackedFunc` / `DModule`: `__slots__ = ("session",)`. - `Session`: `__slots__ = ("_cache", "_import_python_module")`
…st gating (#19736) The tvm_ffi Object metaclass now gives every subclass `__slots__ = ()`, so the Disco Python wrappers can no longer store instance attributes and every session construction fails with AttributeError. Declare the attributes each wrapper actually stores as named slots, fix the NVSHMEM `dist_gemm.cu` so TVM builds with `USE_NVSHMEM = ON`, and gate the disco tests on the disco runtime being present so they skip cleanly on builds (e.g. the pip wheel) that report `USE_NCCL` / `USE_NVSHMEM = ON` without shipping it. ### Session attribute storage - `DPackedFunc` / `DModule`: `__slots__ = ("session",)`. - `Session`: `__slots__ = ("_cache", "_import_python_module")`
The tvm_ffi Object metaclass now gives every subclass
__slots__ = (), so the Disco Python wrappers can no longer store instance attributes and every session construction fails with AttributeError. Declare the attributes eachwrapper actually stores as named slots, fix the NVSHMEM
dist_gemm.cuso TVM builds withUSE_NVSHMEM = ON, and gate the disco tests on the disco runtime being present so they skip cleanly on builds (e.g. the pip wheel) that reportUSE_NCCL/USE_NVSHMEM = ONwithout shipping it.Session attribute storage
DPackedFunc/DModule:__slots__ = ("session",).Session:__slots__ = ("_cache", "_import_python_module")