This document describes the validated native bring-up flow for the structured RISC-V backend on an SG2044 machine. It is intentionally separate from the generic installation guide because this path uses a real RISC-V host, a Buddy / LLVM toolchain, and a native GCC sysroot instead of the usual x86 or GPU development environment.
The validated flow is:
TileLang -> MLIR Linalg -> MLIR vector / RVV lowering- native host shared library build with the RISC-V GCC toolchain
- execution on SG2044
This document is about native execution on SG2044.
Clone the repository with its bundled dependencies, including the TileKernels
submodule used by the RISC-V operator-library tests:
git clone --recursive https://github.com/tile-ai/tilelang.git tilelang-riscv
cd tilelang-riscvIf you already cloned the repository without submodules, run:
git submodule update --init --recursiveActivate the Python environment and export the toolchain variables:
source ~/.venv-buddy/bin/activate
export TILELANG_RISCV_LLVM_ROOT=/path/to/buddy-mlir/llvm/build
export Z3_ROOT=/path/to/.local/z3
export CC=/path/to/gcc
export CXX=/path/to/g++
export PATH=/path/to/gcc-bin:$TILELANG_RISCV_LLVM_ROOT/bin:$Z3_ROOT/bin:$PATH
export LIBRARY_PATH=/path/to/gcc-lib64/lp64d:/path/to/gcc-libgcc/lp64d${LIBRARY_PATH:+:$LIBRARY_PATH}
export TVM_FFI_DISABLE_TORCH_C_DLPACK=1
export CMAKE_ARGS="-DUSE_CUDA=OFF -DUSE_ROCM=OFF"Notes:
Z3_ROOTis required whenz3-solverwheels are unavailable onriscv64- if the native toolchain uses a split
lib64/lp64dlayout, include it inLIBRARY_PATHor CMake's compiler sanity check can fail on-lgcc_s TVM_FFI_DISABLE_TORCH_C_DLPACK=1avoids first-import JIT building of the optional Torch DLPack extensiontorch-c-dlpack-extis skipped onriscv64; the validated SG2044 flow uses TVM FFI without that optional prebuilt extension
Install the Python-side build dependencies first:
pip install scikit-build-core cython patchelf setuptools_scm cloudpickle pytestInstall the vendored TVM FFI package from the source tree:
cd tilelang-riscv
pip install ./3rdparty/tvm/3rdparty/tvm-ffi --no-build-isolation --no-depsThen install TileLang itself in editable mode:
cd tilelang-riscv
pip install -e . --no-build-isolation -vThe SG2044 path depends on a few implementation details that are already wired into this tree:
- use
target="riscv"as the backend name - toolchain discovery covers sibling Buddy builds such as
../buddy-mlir/llvm/build - the RISC-V host wrapper passes
--gcc-toolchainand--sysrootwhen it detects/opt/gcc-native - RISC-V builds disable TVM's alternative linker selection because
ld.lldfailed on the validated SG2044 toolchain
If you need to rebuild after source changes, the same editable install command is sufficient:
cd tilelang-riscv
pip install -e . --no-build-isolation -vThe validated native test set is:
cd tilelang-riscv
pytest testing/python/riscv/test_riscv_target_parse.py -q
pytest testing/python/riscv/test_riscv_toolchain.py -q
pytest testing/python/riscv/test_riscv_tladapter_pipeline.py -q
pytest testing/python/riscv/test_riscv_cache.py -q
pytest testing/python/riscv/codegen_ops -q
pytest testing/python/riscv/TileKernels -qUseful extended runtime checks:
pytest testing/python/riscv/test_riscv_jit_runtime.py -q
pytest testing/python/riscv/test_riscv_artifact_export.py -qtest_riscv_jit_runtime.py and test_riscv_artifact_export.py exercise broader
runtime and artifact-export paths and may expose additional toolchain or runtime
issues beyond the smoke set above.
- If configuration fails with a Z3 lookup error, check that
Z3_ROOTpoints to a prefix containingincludeandlib - If the first CMake configure fails on
-lgcc_s, verify that the toolchain'slib64/lp64ddirectory is present inLIBRARY_PATH - If runtime shared library linking fails, verify that
CC,CXX, and/opt/gcc-native/sysrootare all present - If
tvm_ffiimport fails, reinstall the vendored package from3rdparty/tvm/3rdparty/tvm-ffi - If first import becomes slow or tries to build extra Torch extensions, keep
TVM_FFI_DISABLE_TORCH_C_DLPACK=1