You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "tqchen (via GitHub)" <gi...@apache.org> on 2026/04/29 19:57:01 UTC
[PR] [REFACTOR] Delete src/support/libinfo.cc; replace with runtime FFI-registry env query [tvm]
tqchen opened a new pull request, #19477:
URL: https://github.com/apache/tvm/pull/19477
## Summary
`support.GetLibInfo` exposed ~30 build-time `TVM_INFO_*` strings (git hash, LLVM/MLIR versions, every `USE_*` flag). Real callers reduce to "is this feature enabled?" — better answered at runtime. `USE_CUDA=ON` does not mean a CUDA device is loadable; runtime discovery is the actual signal. Git versioning is already tracked via `tvm.__version__`.
Changes:
- Delete `src/support/libinfo.cc`, `cmake/modules/LibInfo.cmake`, `tests/lint/check_cmake_options.py`, and the `check-cmake-options` pre-commit hook.
- Delete `tvm.support.libinfo()` (no shim — callers migrate to runtime discovery).
- Add `tvm.support.detect_active_modules()` which queries the FFI global function registry for `ffi.Module.create.<kind>` registrations (cuda, vulkan, opencl). `describe()` now prints active runtimes instead of CMake build flags.
- Migrate 5 in-tree callers: `_get_targets()` uses `cudnn.exists()` / `tvm.runtime.enabled()` for CUDNN and Hexagon; `_cmake_flag_enabled()` is rewritten as a static map from cmake flag names to `tvm.runtime.enabled()` or FFI-registry probes; `clml_sdk_version()` uses the existing `relax.get_openclml_version` FFI global; `test_clml_ops.py` uses the new helper.
After this PR: `src/support/` is header-only.
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [REFACTOR] Delete src/support/libinfo.cc; replace with runtime FFI-registry env query [tvm]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #19477:
URL: https://github.com/apache/tvm/pull/19477#discussion_r3163819276
##########
python/tvm/testing/utils.py:
##########
@@ -1086,11 +1086,40 @@ def _has_cpu_feat(features):
def _cmake_flag_enabled(flag):
- flag = tvm.support.libinfo()[flag]
-
- # Because many of the flags can be library flags, we check if the
- # flag is not disabled, rather than checking if it is enabled.
- return flag.lower() not in ["off", "false", "0"]
+ # Maps cmake USE_* option names to runtime probes.
+ # Device backends: tvm.runtime.enabled("<kind>") returns True iff the
+ # runtime module factory is registered (ffi.Module.create.<kind>).
+ # Contrib libraries: probe a known FFI global that only registers when
+ # the feature was compiled in.
+ # Grep hint: grep -rn 'ffi.Module.create.' src/ python/
+ _flag_to_device_kind = {
+ "USE_CUDA": "cuda",
+ "USE_OPENCL": "opencl",
+ "USE_VULKAN": "vulkan",
+ "USE_METAL": "metal",
+ "USE_ROCM": "rocm",
+ "USE_HEXAGON": "hexagon",
+ "USE_WEBGPU": "webgpu",
+ "USE_LLVM": "llvm",
+ "USE_RPC": "rpc",
+ }
+ _flag_to_global_func = {
+ "USE_CUDNN": "tvm.contrib.cudnn.exists",
+ "USE_CUBLAS": "tvm.contrib.cublas.matmul",
+ "USE_NCCL": "tvm.contrib.nccl.init_nccl_uid",
+ "USE_HIPBLAS": "tvm.contrib.hipblas.matmul",
+ "USE_CLML": "relax.is_openclml_runtime_enabled",
+ "USE_NNAPI_CODEGEN": "relax.ext.nnapi",
+ "USE_CUTLASS": "relax.ext.cutlass",
+ }
+ if flag in _flag_to_device_kind:
+ return tvm.runtime.enabled(_flag_to_device_kind[flag])
+ if flag in _flag_to_global_func:
+ return tvm.get_global_func(_flag_to_global_func[flag], allow_missing=True) is not None
+ raise RuntimeError(
+ f"_cmake_flag_enabled: unknown flag '{flag}'. "
+ "Add an entry to _flag_to_device_kind or _flag_to_global_func."
+ )
Review Comment:

For performance, the dictionaries `_flag_to_device_kind` and `_flag_to_global_func` should be defined at the module level instead of inside the `_cmake_flag_enabled` function. This will prevent them from being recreated on every function call, which can be frequent during test collection.
As a first step, I've renamed them to follow the convention for module-level constants (UPPER_SNAKE_CASE). Please move their definitions outside the function.
```python
# Maps cmake USE_* option names to runtime probes.
# Device backends: tvm.runtime.enabled("<kind>") returns True iff the
# runtime module factory is registered (ffi.Module.create.<kind>).
# Contrib libraries: probe a known FFI global that only registers when
# the feature was compiled in.
# Grep hint: grep -rn 'ffi.Module.create.' src/ python/
_FLAG_TO_DEVICE_KIND = {
"USE_CUDA": "cuda",
"USE_OPENCL": "opencl",
"USE_VULKAN": "vulkan",
"USE_METAL": "metal",
"USE_ROCM": "rocm",
"USE_HEXAGON": "hexagon",
"USE_WEBGPU": "webgpu",
"USE_LLVM": "llvm",
"USE_RPC": "rpc",
}
_FLAG_TO_GLOBAL_FUNC = {
"USE_CUDNN": "tvm.contrib.cudnn.exists",
"USE_CUBLAS": "tvm.contrib.cublas.matmul",
"USE_NCCL": "tvm.contrib.nccl.init_nccl_uid",
"USE_HIPBLAS": "tvm.contrib.hipblas.matmul",
"USE_CLML": "relax.is_openclml_runtime_enabled",
"USE_NNAPI_CODEGEN": "relax.ext.nnapi",
"USE_CUTLASS": "relax.ext.cutlass",
}
if flag in _FLAG_TO_DEVICE_KIND:
return tvm.runtime.enabled(_FLAG_TO_DEVICE_KIND[flag])
if flag in _FLAG_TO_GLOBAL_FUNC:
return tvm.get_global_func(_FLAG_TO_GLOBAL_FUNC[flag], allow_missing=True) is not None
raise RuntimeError(
f"_cmake_flag_enabled: unknown flag '{flag}'. "
"Add an entry to _FLAG_TO_DEVICE_KIND or _FLAG_TO_GLOBAL_FUNC."
)
```
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [REFACTOR] Delete src/support/libinfo.cc; replace with runtime FFI-registry env query [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #19477:
URL: https://github.com/apache/tvm/pull/19477
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org