Skip to content
Merged
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
91 changes: 90 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ tvm_option(USE_MSC "Enable Multi-System Compiler" OFF)
tvm_option(USE_MRVL "Build with MRVL TVM support" OFF)
tvm_option(USE_NVSHMEM "Build with NVSHMEM support" OFF)

# Python package options
tvm_option(TVM_BUILD_PYTHON_MODULE "Build Python module with scikit-build-core" ON)

# include directories
include_directories(${CMAKE_INCLUDE_PATH})
include_directories("include")
Expand Down Expand Up @@ -566,7 +569,6 @@ endif()

add_subdirectory(ffi)


if(TVM_DEBUG_WITH_ABI_CHANGE)
message(STATUS "Building with debug code that may cause ABI changes...")
target_compile_definitions(tvm_objs PRIVATE "TVM_DEBUG_WITH_ABI_CHANGE")
Expand Down Expand Up @@ -818,3 +820,90 @@ if(USE_ROCM AND USE_RCCL)
target_link_libraries(tvm PRIVATE rccl)
target_link_libraries(tvm_runtime PRIVATE rccl)
endif()

# Python package installation configuration
# This section ensures that all necessary files are installed for the Python wheel
if(TVM_BUILD_PYTHON_MODULE)
message(STATUS "Configuring Python package installation")

# Install Python source files
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/python/tvm"
DESTINATION "."
FILES_MATCHING
PATTERN "*.py"
PATTERN "*.pyi"
PATTERN "__pycache__" EXCLUDE
PATTERN "*.pyc" EXCLUDE
)

# Install compiled shared libraries
install(TARGETS tvm DESTINATION "tvm")
install(TARGETS tvm_runtime DESTINATION "tvm")

# Install third-party compiled dependencies
if(TARGET fpA_intB_gemm)
install(TARGETS fpA_intB_gemm DESTINATION "tvm")
endif()
if(TARGET flash_attn)
install(TARGETS flash_attn DESTINATION "tvm")
endif()

# Install minimal header files needed by Python extensions
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/tvm/runtime"
DESTINATION "tvm/include/tvm/runtime"
FILES_MATCHING
PATTERN "*.h"
)

# Install minimal CMake configuration
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils"
DESTINATION "tvm/cmake/utils"
FILES_MATCHING
PATTERN "*.cmake"
)

# Install CUTLASS headers only if available
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cutlass/include")
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cutlass/include"
DESTINATION "tvm/3rdparty/cutlass"
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
endif()

# Install minimal source files
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/runtime"
DESTINATION "tvm/src/runtime"
FILES_MATCHING
PATTERN "*.cc"
PATTERN "*.h"
)

# Install essential configuration files
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/configs"
DESTINATION "tvm/configs"
)

# Install licenses (required for distribution)
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/licenses"
DESTINATION "tvm/licenses"
)

# Install essential metadata files
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
"${CMAKE_CURRENT_SOURCE_DIR}/NOTICE"
DESTINATION "tvm"
)

message(STATUS "Python package installation configured")
endif()
1 change: 1 addition & 0 deletions cmake/modules/LibInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function(add_lib_info src_file)
TVM_INFO_USE_ROCM="${USE_ROCM}"
TVM_INFO_USE_RCCL="${USE_RCCL}"
TVM_INFO_USE_RPC="${USE_RPC}"
TVM_INFO_TVM_BUILD_PYTHON_MODULE="${TVM_BUILD_PYTHON_MODULE}"
TVM_INFO_USE_RTTI="${USE_RTTI}"
TVM_INFO_USE_RUST_EXT="${USE_RUST_EXT}"
TVM_INFO_USE_SORT="${USE_SORT}"
Expand Down
228 changes: 228 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,191 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[build-system]
requires = ["scikit-build-core>=0.10.0"]
build-backend = "scikit_build_core.build"

[project]
name = "tvm"
# Note: Call version.py to update the version before building the wheel
version = "0.22.0.dev0"
description = "Apache TVM: An End-to-End Deep Learning Compiler Stack"
readme = "README.md"
license = { text = "Apache-2.0" }
requires-python = ">=3.9"
authors = [
{ name = "Apache TVM Community", email = "dev@tvm.apache.org" }
]
keywords = ["machine learning", "compiler", "deep learning", "inference"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development :: Libraries :: Python Modules",
]
# Core dependencies - these are the minimum required for basic TVM functionality
dependencies = [
"cloudpickle",
"ml_dtypes",
"numpy",
"packaging",
"psutil",
"scipy",
"tornado",
"typing_extensions",
]

# Optional dependencies for different features
[project.optional-dependencies]
# Model importers
importer-coreml = ["coremltools"]
importer-keras = ["tensorflow", "tensorflow-estimator"]
importer-onnx = ["future", "onnx", "onnxoptimizer", "onnxruntime", "torch", "torchvision"]
importer-pytorch = ["torch", "torchvision"]
importer-tensorflow = ["tensorflow", "tensorflow-estimator"]
importer-tflite = ["tflite"]
importer-paddle = ["paddlepaddle"]

# AutoTVM and autoscheduler
autotvm = ["xgboost"]
autoscheduler = ["xgboost"]

# Development and testing
dev = [
"black",
"isort",
"mypy",
"pylint",
"pytest",
"pytest-xdist",
"pytest-cov",
"pytest-mock",
"pytest-benchmark",
"pytest-timeout",
"pytest-rerunfailures",
"pytest-repeat",
"pytest-xdist",
"pytest-cov",
"pytest-mock",
"pytest-benchmark",
"pytest-timeout",
"pytest-rerunfailures",
"pytest-repeat",
]

# All optional dependencies (excluding dev)
all = [
"coremltools",
"tensorflow",
"tensorflow-estimator",
"future",
"onnx",
"onnxoptimizer",
"onnxruntime",
"torch",
"torchvision",
"tflite",
"paddlepaddle",
"xgboost",
]

[project.urls]
Homepage = "https://tvm.apache.org/"
Documentation = "https://tvm.apache.org/docs/"
Repository = "https://github.com/apache/tvm"
"Bug Tracker" = "https://github.com/apache/tvm/issues"

[tool.scikit-build]
# Point to the root CMakeLists.txt
cmake.source-dir = "."
cmake.build-type = "Release"

# Configure the wheel to be Python version-agnostic
wheel.py-api = "py3"

# Build configuration
build-dir = "build"

# CMake configuration - ensure proper installation paths
cmake.args = [
"-DTVM_BUILD_PYTHON_MODULE=ON",
"-DTVM_FFI_BUILD_PYTHON_MODULE=OFF",
"-DTVM_USE_CUTLASS=OFF",
"-DTVM_USE_FLASH_ATTN=OFF",
"-DTVM_USE_LLVM=OFF",
"-DTVM_USE_CUDA=OFF",
"-DTVM_USE_OPENCL=OFF",
"-DTVM_USE_VULKAN=OFF",
"-DTVM_USE_METAL=OFF",
"-DTVM_USE_OPENGL=OFF",
"-DTVM_USE_RPC=OFF",
"-DTVM_USE_GRAPH_EXECUTOR=OFF",
"-DTVM_USE_PROFILER=OFF",
"-DTVM_USE_UTILS=OFF",
]

# Wheel configuration
wheel.packages = ["python/tvm"]

# Source distribution configuration
sdist.include = [
# Build files
"/CMakeLists.txt",
"/pyproject.toml",
"/cmake/**/*",
"/3rdparty/**/*",

# Source code
"/src/**/*.cc",
"/src/**/*.h",
"/include/**/*.h",

# Python source
"/python/tvm/**/*.py",
"/python/tvm/**/*.pyi",

# Documentation and metadata
"/docs/**/*",
"/LICENSE",
"/README.md",
"/NOTICE",

# Tests
"/tests/**/*",
]

sdist.exclude = [
"**/.git",
"**/.github",
"**/__pycache__",
"**/*.pyc",
"build",
"dist",
"**/3rdparty/*/docs",
"**/3rdparty/*/media",
"**/3rdparty/*/examples",
"**/3rdparty/*/test",
]

# Logging
logging.level = "INFO"

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v --tb=short"
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]

[tool.isort]
profile = "black"
src_paths = ["python", "tests/python"]
Expand Down Expand Up @@ -51,5 +236,48 @@ exclude = '''
'''

[tool.ruff]
# Enable pycodestyle (`E`), Pyflakes (`F`), and isort (`I`) codes
select = ["E", "F", "I"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I", "N", "UP", "W", "ARG", "B", "C4", "DTZ", "T10", "EM", "EXE", "FA", "ICN", "Q", "T20", "TID", "TCH", "RUF"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".darcs",
".git",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"3rdparty",
]

line-length = 100
indent-width = 4

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"


[tool.ruff.mccabe]
max-complexity = 10

[tool.ruff.isort]
known-first-party = ["tvm"]
1 change: 1 addition & 0 deletions src/support/libinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ TVM_DLL ffi::Map<ffi::String, ffi::String> GetLibInfo() {
{"USE_ROCM", TVM_INFO_USE_ROCM},
{"USE_RCCL", TVM_INFO_USE_RCCL},
{"USE_RPC", TVM_INFO_USE_RPC},
{"TVM_BUILD_PYTHON_MODULE", TVM_INFO_TVM_BUILD_PYTHON_MODULE},
{"USE_RTTI", TVM_INFO_USE_RTTI},
{"USE_RUST_EXT", TVM_INFO_USE_RUST_EXT},
{"USE_SORT", TVM_INFO_USE_SORT},
Expand Down
Loading