Skip to content

[Feature Request][Maint] Stop shiping 3rdparty in wheel and eliminate manual sys.path handling for library finding #1142

@XuehaiPan

Description

@XuehaiPan

Required prerequisites

  • I have searched the Issue Tracker that this hasn't already been reported. (comment there if it has.)

Motivation

Currently, we pack all contents of 3rdparty in the wheel file:

tilelang/pyproject.toml

Lines 90 to 92 in 7d389a4

# NOTE: The mapping below places the contents of '3rdparty' inside 'tilelang/3rdparty' in the wheel.
# This is necessary to find TVM shared libraries at runtime.
"tilelang/3rdparty" = "3rdparty"

which occupy the major part of the wheel (see #1108 (comment)):

Here are the contents of a wheel built from a fresh git clone:

$ unzip tilelang-*.whl

$ du -d 1 -h tilelang | sort -rh
662M    tilelang
592M    tilelang/3rdparty
 65M    tilelang/lib
3.3M    tilelang/src
408K    tilelang/language
292K    tilelang/carver
212K    tilelang/jit
128K    tilelang/intrinsics
 88K    tilelang/quantize
 64K    tilelang/contrib
 60K    tilelang/autotuner
 52K    tilelang/utils
 36K    tilelang/transform
 36K    tilelang/layout
 36K    tilelang/engine
 32K    tilelang/tileop
 32K    tilelang/primitives
 24K    tilelang/tools
 24K    tilelang/cache
 20K    tilelang/profiler
8.0K    tilelang/common
4.0K    tilelang/testing
4.0K    tilelang/math

$ du -d 1 -h tilelang/3rdparty | sort -rh
592M    tilelang/3rdparty
406M    tilelang/3rdparty/tvm
149M    tilelang/3rdparty/cutlass
 38M    tilelang/3rdparty/composable_kernel

Also, we handle editable and normal installation differently with manual sys.path handling:

tilelang/tilelang/env.py

Lines 22 to 42 in 7d389a4

TL_ROOT = os.path.dirname(os.path.abspath(__file__))
TL_LIBS = [TL_ROOT, os.path.join(TL_ROOT, 'lib')]
TL_LIBS = [i for i in TL_LIBS if os.path.exists(i)]
DEV = False
THIRD_PARTY_ROOT = os.path.join(TL_ROOT, '3rdparty')
if not os.path.exists(THIRD_PARTY_ROOT):
DEV = True
tl_dev_root = os.path.dirname(TL_ROOT)
dev_lib_root = os.path.join(tl_dev_root, 'build')
TL_LIBS = [dev_lib_root, os.path.join(dev_lib_root, 'tvm')]
THIRD_PARTY_ROOT = os.path.join(tl_dev_root, '3rdparty')
logger.warning(f'Loading tilelang libs from dev root: {dev_lib_root}')
assert TL_LIBS and all(
os.path.exists(i) for i in TL_LIBS), f'tilelang lib root do not exists: {TL_LIBS}'
for lib in TL_LIBS:
if lib not in sys.path:
sys.path.insert(0, lib)

That is fragile and forbids us from sorting the imports in the code because the code can only work with a specific execution order.

Solution

No response

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions