Build & Install
Installing / Rebuilding tilelang
TileLang-Sunrise includes TVM and tvm-ffi source directly. Build and install tvm-ffi before installing TileLang:
SETUPTOOLS_SCM_PRETEND_VERSION=0.1.11+sunrise.1 \
python -m pip install ./3rdparty/tvm_sunrise/3rdparty/tvm-ffi
pip install .
Or with verbose output for debugging build issues:
pip install . -v
uv pip install . also works if uv is available but is not required.
Build dependencies are declared in pyproject.toml and resolved automatically during pip install ..
If ccache is available, repeated builds only recompile changed C++ files.
Alternative: Development Build with --no-build-isolation
If you need faster iteration (e.g. calling cmake directly to recompile C++ without re-running the full pip install), install build dependencies first:
pip install -r requirements-dev.txt
pip install --no-build-isolation .
After this, you can invoke cmake --build build directly to recompile only changed C++ files. This is useful when iterating on C++ code.
Alternative: cmake + PYTHONPATH (recommended for C++ development)
For the fastest C++ iteration, bypass pip entirely and drive cmake directly:
# Configure from the self-contained source tree
cmake -S . -B build
# Build
cmake --build build -j$(nproc)
# Make the local tilelang package importable
export PYTHONPATH=$(pwd):$PYTHONPATH
After the initial configure, recompiling is just cmake --build build -j$(nproc). The runtime automatically discovers native libraries from build/lib/ when it detects a dev checkout (see tilelang/env.py).
Useful cmake options:
| Flag | Purpose |
|---|---|
-DUSE_CUDA=ON/OFF |
Enable/disable CUDA backend (ON by default) |
-DUSE_ROCM=ON |
Enable ROCm/HIP backend |
-DUSE_METAL=ON |
Enable Metal backend (default on macOS) |
-DCMAKE_BUILD_TYPE=Debug |
Debug build with TVM_LOG_DEBUG enabled |
Editable Installs
pip install -e . is a supported development install, and is what README.md, CONTRIBUTING.md, and docs/get_started/Installation.md recommend for development:
pip install -r requirements-dev.txt
pip install -e . -v --no-build-isolation
Notes specific to this repo's layout:
- When Python is run from the repo root, the local
./tilelangdirectory is imported instead of any copy installed intosite-packages(because the repo root is onsys.pathahead ofsite-packages). This is by design:tilelang/env.pydetects a dev checkout (when3rdparty/is not inside the package dir) and loads native libraries frombuild/lib/andbuild/tvm/, loggingLoading tilelang libs from dev root: <repo>/build. - Because of the above, both approaches resolve imports to the local
./tilelangwhen run from the repo root. Usepip install -e .when you want pip to manage package metadata/dependencies; usePYTHONPATH=$(pwd)only for the lighter-weight import-only workflow. - For pure C++ iteration (no Python metadata needed), the
cmake + PYTHONPATHflow above is faster and avoids re-running pip entirely.
TANG/PTPU extension
For a TANG build, enable USE_TANG=ON (or USE_TANG=1) and verify that
tvm.get_global_func("target.build.tilelang_tang", allow_missing=True) is registered before
debugging higher layers. Read references/tang-environment.md for the current repository CI entry
points, single-device preflight, cache isolation, and the source/build/import/runtime fingerprint to
record with a TANG result.
Running Tests
Most tests require a GPU.
python -m pytest testing/python/ -x
Run a specific test file or test case:
python -m pytest testing/python/language/test_tilelang_language_copy.py -x
python -m pytest testing/python/language/test_tilelang_language_copy.py -x -k "test_name"
For Metal-specific tests (requires macOS with Apple Silicon):
python -m pytest testing/python/metal/ -x