Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ set(USE_AOT_EXECUTOR OFF)
set(USE_PROFILER OFF)
set(USE_GTEST OFF)
set(USE_LIBBACKTRACE OFF)
set(BUILD_DUMMY_LIBTVM ON)
option(BUILD_DUMMY_LIBTVM
"Build a stub libtvm (runtime-only, no LLVM target codegen). \
OFF to enable model compilation via mlc_llm compile." ON)
if(BUILD_DUMMY_LIBTVM)
message(STATUS "BUILD_DUMMY_LIBTVM=ON: libtvm will be a runtime-only stub. "
"Sufficient for loading prebuilt rt.dylib artifacts. "
"To build a libtvm capable of `mlc_llm compile`, re-configure "
"with -DBUILD_DUMMY_LIBTVM=OFF -DUSE_LLVM=<llvm-config path>.")
Comment on lines +62 to +65

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The status message informs users that they can re-configure with -DBUILD_DUMMY_LIBTVM=OFF. However, line 58 uses set(BUILD_DUMMY_LIBTVM ON), which creates a normal variable that shadows any cache variable set via the command line (e.g., using -D). This means that passing -DBUILD_DUMMY_LIBTVM=OFF to cmake will have no effect on the build, as the local variable will override the cache value. To make this "escape hatch" functional, line 58 should be changed to an option() or a cache variable.

endif()
if(NOT DEFINED TVM_SOURCE_DIR)
if(DEFINED ENV{TVM_SOURCE_DIR})
set(TVM_SOURCE_DIR "$ENV{TVM_SOURCE_DIR}")
Expand Down
30 changes: 30 additions & 0 deletions docs/install/mlc_llm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,36 @@ This step is useful when you want to make modification or obtain a specific vers
# build mlc_llm libraries
cmake .. && make -j $(nproc) && cd ..

.. note::
The default source build sets ``BUILD_DUMMY_LIBTVM=ON``, producing a
runtime-only ``libtvm`` that is sufficient for loading prebuilt
``rt.dylib`` model artifacts but cannot drive ``mlc_llm compile``. To
build a ``libtvm`` capable of model compilation, install LLVM and
re-configure cmake with both flags below:

.. code-block:: bash
:caption: Build for model compilation (LLVM-enabled libtvm)

# macOS (Homebrew)
brew install llvm
cmake .. -DBUILD_DUMMY_LIBTVM=OFF \
-DUSE_LLVM="$(brew --prefix llvm)/bin/llvm-config --link-static"

# Linux (apt)
sudo apt install llvm-dev
cmake .. -DBUILD_DUMMY_LIBTVM=OFF \
-DUSE_LLVM="llvm-config --link-static"

Verify LLVM is linked into the resulting ``libtvm``:

.. code-block:: bash

# macOS: > 0 means LLVM is in; expected libtvm size ~250 MB
nm build/tvm/libtvm.dylib | grep -ci llvm

# Linux equivalent
nm build/tvm/libtvm.so | grep -ci llvm

**Step 3. Install via Python.** We recommend that you install ``mlc_llm`` as a Python package, giving you
access to ``mlc_llm.compile``, ``mlc_llm.MLCEngine``, and the CLI.
There are two ways to do so:
Expand Down