[Doc] Build from source instructions incomplete - missing Python environment setup and library path configuration
Documentation
Suggestion
The current build-from-source documentation lacks several critical setup steps, particularly regarding Python environment configuration and library path management. The guide assumes the build artifacts will be automatically discoverable by Python, which is not the case. I recommend adding explicit instructions for:
- Installing required Python dependencies (
apache-tvm-ffi,numpy, etc.) - Setting up
PYTHONPATHandDYLD_LIBRARY_PATH/LD_LIBRARY_PATH - Verifying the TVM installation before testing MLC-LLM
- Troubleshooting common runtime errors
Bug
- Link to the buggy documentation/tutorial: https://llm.mlc.ai/docs/install/mlc_llm.html#option-2-build-from-source
- Description of the bug:
The documentation stops at the
cmakeandmakesteps, but the built MLC-LLM is not functional as a Python package without additional setup. After following the documentation exactly:
Missing TVM Python package: The guide mentions "TVM's Python package needs to be in
PYTHONPATH" but doesn't specify thatapache-tvm-ffimust be installed via pip, nor does it show the correctPYTHONPATHconfiguration for the local TVM build.Missing library path configuration: Even after setting
PYTHONPATH, the system fails to findlibtvm_runtime.dylib(on macOS) becauseDYLD_LIBRARY_PATHis not set. The documentation doesn't mention this at all.Missing numpy dependency: The TVM import fails with
ModuleNotFoundError: No module named 'numpy'- this is not listed as a requirement in the documentation.Runtime malloc error: After fixing all path issues and dependencies, the command
python -m mlc_llm -hcrashes with:malloc: *** error for object 0x600001720008: pointer being freed was not allocatedThis suggests a more serious issue that the documentation cannot help resolve. The user is left stuck at the final step.
Suggested Resolution:
- Add comprehensive post-build setup instructions covering:
pip install numpy apache-tvm-ffi export PYTHONPATH=$PWD/3rdparty/tvm/python:$PWD/python:$PYTHONPATH export DYLD_LIBRARY_PATH=$PWD/build/lib:$DYLD_LIBRARY_PATH # macOS # or export LD_LIBRARY_PATH=$PWD/build/lib:$LD_LIBRARY_PATH # Linux - Add verification steps to test the installation incrementally:
python -c "import tvm; print(tvm.__version__)" python -c "from mlc_llm import MLCEngine" - Note the minimum required Python version and potential compatibility issues
- The malloc error indicates either a version mismatch between the compiled libraries and the Python package, or a build configuration issue that should be documented as a known issue with a workaround
Source: mlc-ai/mlc-llm