Skip to content

[REFACTOR] Delete src/support/libinfo.cc; replace with runtime FFI-registry env query#19477

Open
tqchen wants to merge 3 commits intoapache:mainfrom
tqchen:tvm-phase-out-libinfo
Open

[REFACTOR] Delete src/support/libinfo.cc; replace with runtime FFI-registry env query#19477
tqchen wants to merge 3 commits intoapache:mainfrom
tqchen:tvm-phase-out-libinfo

Conversation

@tqchen
Copy link
Copy Markdown
Member

@tqchen tqchen commented Apr 29, 2026

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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the libinfo infrastructure, which previously mirrored CMake configuration flags into the TVM runtime via generated C++ code. The changes include the deletion of LibInfo.cmake, libinfo.cc, and the associated linting scripts. This functionality is replaced by dynamic probing of the FFI registry and runtime modules to determine feature availability and versions. Feedback was provided regarding the performance of the new _cmake_flag_enabled utility, suggesting that its internal mapping dictionaries be moved to the module level to avoid redundant allocations during test execution.

Comment thread python/tvm/testing/utils.py Outdated
@tqchen tqchen force-pushed the tvm-phase-out-libinfo branch from c4a3ed8 to 1bc95e6 Compare April 29, 2026 21:54
tqchen added 3 commits April 30, 2026 00:08
…gistry env query

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 by runtime device /
feature discovery (USE_CUDA=ON does not mean a CUDA device is
loadable; runtime probe is the actual signal).  Git versioning is
already tracked via tvm.__version__.

Replace tvm.support.libinfo() with tvm.support.detect_active_modules()
which queries the FFI global function registry for
ffi.Module.create.<kind> registrations on a minimal key set
(cuda, vulkan, opencl).  describe() now prints active runtimes
instead of CMake build flags.

Migrate the 5 in-tree callers: _get_targets() in testing/utils.py now
uses cudnn.exists() / tvm.runtime.enabled() for CUDNN and Hexagon;
_cmake_flag_enabled() is rewritten as a static mapping 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.

Deletes ~323 lines C++, the LibInfo CMake module, the
check_cmake_options lint, and the corresponding pre-commit hook.
src/support/ becomes header-only.
…on Feature directly

The _cmake_flag_enabled translation table was naming-convention
noise — each "cmake flag X" entry just maps to "probe Y" via
tvm.runtime.enabled() or tvm.get_global_func().  Carry the runtime
check directly on each Feature via run_time_check, matching the
pattern already used by requires_x86_amx.

Removes the cmake_flag attribute from Feature, the
_cmake_flag_enabled translator, and the one out-of-tree caller in
contrib/hexagon/_ci_env_check.py.  ~16 Feature instances rewritten
to use run_time_check lambdas calling tvm.runtime.enabled("<kind>")
or tvm.get_global_func() probes directly.

No build-flag introspection remains in the testing utility layer.
…r cmake_flag removal

Phase-out of cmake_flag in c201020 moved per-backend availability probes from
compile_time_check (which gates compile-only tests in _compile_only_marks()) to
run_time_check (which is only evaluated in _run_only_marks(), i.e. compile-and-run
tests).  This left compile-only tests — @requires_metal(support_required="compile-only"),
@requires_vulkan(support_required="compile-only") — without any gate on whether the
backend is compiled in.

On the CPU CI node (Linux, USE_METAL=OFF), the three metal compile-only tests
no longer got skipped.  They ran and hit "xcrun: not found" (Apple's Xcode tool)
because Metal codegen requires macOS toolchain.

Fix: add compile_time_check matching run_time_check for every Feature that
previously used cmake_flag.  tvm.runtime.enabled("<kind>") and
tvm.get_global_func(…) are already the correct compile-time probes — they return
True iff the backend was compiled into the TVM shared library, which is exactly
what the old cmake_flag check provided.  The compile_time_check = run_time_check
pairing restores the original behaviour for all six support_required modes.
@tqchen tqchen force-pushed the tvm-phase-out-libinfo branch from 1bc95e6 to 052f46e Compare April 30, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants