Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9e31f6b
Move Python build system to root directory
mgorny Apr 2, 2025
af98b69
Delay downloading dependencies until CMake build command
mgorny Apr 2, 2025
8efcbf1
Add missing files to source distribution
mgorny Apr 2, 2025
f33ee49
Remove `triton/_C/include` symlink
mgorny Apr 3, 2025
93146d2
Future-proof against wheel removing bdist_wheel command
mgorny Apr 3, 2025
349e890
Update path in wheels workflow
mgorny Apr 3, 2025
4f24e68
Remove `third_party/proton/proton/_C/include` symlink too
mgorny Apr 3, 2025
1322da6
Update release workflow to build proper sdist
mgorny Apr 3, 2025
0ca799d
Force fixed version into sdist
mgorny Apr 3, 2025
1943ccf
Update install instructions and Makefile for changed paths
mgorny Apr 5, 2025
ee7b993
Include docs in sdist as well
mgorny Apr 8, 2025
27e7a15
Temporarily enable artifact upload
mgorny Apr 8, 2025
6cad0d8
Remove explicit dependency on wheel
mgorny Apr 8, 2025
ce81f97
Use setuptools.find_packages()
mgorny Apr 8, 2025
c267d86
Remove unnecessary mkdir
mgorny Apr 9, 2025
0c677ab
Remove unnecessary explicit package data logic
mgorny Apr 9, 2025
9a688e2
Defer copying backends until build
mgorny Apr 9, 2025
6ff18a7
Include more test-related files in sdist
mgorny Apr 9, 2025
3a576d0
Revert "Defer copying backends until build"
mgorny Apr 9, 2025
f6a99a9
Install subpackages from third-party without symlinks
mgorny Apr 9, 2025
a9e85f7
Remove unused imports
mgorny Apr 10, 2025
28455b1
Revert "Temporarily enable artifact upload"
mgorny Apr 10, 2025
76d368d
add artifact upload
mgorny Apr 10, 2025
8afcacd
Add __init__.py to amd backend to fix editable installs
mgorny Apr 11, 2025
1893dc6
Use entry points to locate backends
mgorny Apr 11, 2025
b249ecc
Return to using symlinks for editable installs
mgorny Apr 21, 2025
cd61e2d
Use modern setuptools backend
mgorny Apr 21, 2025
93b876f
Add a fallback for ancient setuptools
mgorny Apr 21, 2025
74a93c5
Merge branch 'main' into python-sdist
atalman Apr 23, 2025
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
25 changes: 13 additions & 12 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,31 @@ jobs:
tag_or_branch="${tag_or_branch#refs/heads/}"
# replace directory separators with _ in branch name
tag_or_branch="${tag_or_branch//\//_}"
if [[ ${tag_or_branch} == v* ]]; then
# strip trailing v from tag name
tag_or_branch="${tag_or_branch#v}"
# important: version must be fixed in setup.py
sed -i -e "s:^TRITON_VERSION = .*:TRITON_VERSION = '${tag_or_branch}':" setup.py || exit 1
fi
echo "RELEASE_NAME=triton-$tag_or_branch" >> "$GITHUB_ENV"
echo "RELEASE_FILE=triton-$tag_or_branch.tar.gz" >> "$GITHUB_ENV"
- name: Create source distribution
run: |
# Create new folder with specified name so extracting the archive yields that
rm -rf "/tmp/$RELEASE_NAME"
cp -r "$PWD" "/tmp/$RELEASE_NAME"
mv "/tmp/$RELEASE_NAME" .
# Cleanup
find "$RELEASE_NAME" -name '.git*' -exec rm -rv {} \; || true
# Create archive
tar -czf "$RELEASE_FILE" "$RELEASE_NAME"
echo "Created source archive $RELEASE_FILE with content: $(ls -a "$RELEASE_NAME")"
pip install build || exit 1
python -m build -s || exit 1
cd dist || exit 1
release_file=( *.tar.gz )
echo "RELEASE_FILE=${release_file}" >> "$GITHUB_ENV"
- name: Upload source distribution for release
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v2
with:
files: ${{env.RELEASE_FILE}}
files: dist/${{env.RELEASE_FILE}}
- name: Upload source distribution to GHA artifacts for release tags
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'rc') }}
uses: actions/[email protected]
with:
name: ${{ env.RELEASE_FILE }}
path: ${{ env.RELEASE_FILE }}
path: dist/${{ env.RELEASE_FILE }}
- name: Set output
id: release_name
run: echo "name=release_name::${{ env.RELEASE_NAME }}.tar.gz" >> "${GITHUB_OUTPUT}"
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ jobs:
export CIBW_BUILD="cp3{9,10,11,12,13,13t}-manylinux_${{ matrix.config.arch }}"
export CIBW_SKIP="cp{35,36,37,38}-*"
export CIBW_FREE_THREADED_SUPPORT=1
python3 -m cibuildwheel python --output-dir wheelhouse
python3 -m cibuildwheel . --output-dir wheelhouse

Copy link
Collaborator

@atalman atalman Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @mgorny
Please add this action before trying to use Azure (since its failing):

- uses: actions/upload-artifact@v4
        with:
          name: cibw-wheels-manylinux_2_28_${{ matrix.config.arch }}-wheels-upload
          path: ./wheelhouse/*.whl

It will allow us to get the wheels from the workflow on this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-manylinux_2_28_${{ matrix.config.arch }}-wheels-upload
path: ./wheelhouse/*.whl

- name: Install Azure CLI
if: ${{ steps.check-version.outputs.new_commit == 'true' }}
Expand Down
18 changes: 18 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
graft bin
graft cmake
graft docs
graft include
graft lib
graft python/src
graft python/test
graft python/triton/backends/amd
graft python/triton/backends/nvidia
graft python/triton/tools/extra/cuda
graft test
graft third_party
graft unittest
include CMakeLists.txt
include Makefile
include python/build_helpers.py
include python/requirements.txt
include python/test-requirements.txt
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dev-install-torch:

.PHONY: dev-install-triton
dev-install-triton:
$(PYTHON) -m pip install -e python --no-build-isolation -v
$(PYTHON) -m pip install -e . --no-build-isolation -v

.PHONY: dev-install
.NOPARALLEL: dev-install
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ git clone https://github.com/triton-lang/triton.git
cd triton

pip install -r python/requirements.txt # build-time dependencies
pip install -e python
pip install -e .
```

Or with a virtualenv:
Expand All @@ -84,7 +84,7 @@ python -m venv .venv --prompt triton
source .venv/bin/activate

pip install -r python/requirements.txt # build-time dependencies
pip install -e python
pip install -e .
```

# Building with a custom LLVM
Expand Down Expand Up @@ -124,7 +124,7 @@ arbitrary LLVM version.
$ LLVM_INCLUDE_DIRS=$LLVM_BUILD_DIR/include \
LLVM_LIBRARY_DIR=$LLVM_BUILD_DIR/lib \
LLVM_SYSPATH=$LLVM_BUILD_DIR \
pip install -e python
pip install -e .

# Tips for building

Expand All @@ -139,7 +139,7 @@ arbitrary LLVM version.
can be changed anytime.

- If you're running out of memory when building Triton, specify the `MAX_JOBS`
environment variable (to the `pip install -e python` command) to limit the
environment variable (to the `pip install -e .` command) to limit the
number of jobs.

- Pass `--no-build-isolation` to `pip install` to make nop builds faster.
Expand All @@ -150,7 +150,7 @@ arbitrary LLVM version.
(probably because, in our build, users don't invoke cmake directly, but
instead use setup.py). Teach vscode how to compile Triton as follows.

- Do a local build. Run command `pip install -e python`
- Do a local build. Run command `pip install -e .`
- Get the full path to the `compile_commands.json` file produced by the build:
`find python/build -name 'compile_commands.json' | xargs readlink -f`.
You might get a full path similar to `/Users/{username}/triton/python/build/cmake.macosx-11.1-arm64-cpython-3.12/compile_commands.json`
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = ["setuptools>=40.8.0", "wheel", "cmake>=3.18", "ninja>=1.11.1"]
requires = ["setuptools>=40.8.0", "cmake>=3.18", "ninja>=1.11.1", "pybind11>=2.13.1"]
build-backend = "setuptools.build_meta"

[tool.yapf]
based_on_style = "pep8"
Expand All @@ -9,6 +10,12 @@ each_dict_entry_on_separate_line=false
split_before_named_assigns = false
split_complex_comprehension = true

# We're incrementally switching from autopep8 to ruff.
[tool.autopep8]
aggressive = 1
ignore = "E501,E701,E731,W690,W503"
max_line_length = 88

[tool.ruff]
line-length = 120

Expand Down
2 changes: 1 addition & 1 deletion python/build_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def get_cmake_dir():
plat_name = sysconfig.get_platform()
python_version = sysconfig.get_python_version()
dir_name = f"cmake.{plat_name}-{sys.implementation.name}-{python_version}"
cmake_dir = Path(get_base_dir()) / "python" / "build" / dir_name
cmake_dir = Path(get_base_dir()) / "build" / dir_name
cmake_dir.mkdir(parents=True, exist_ok=True)
return cmake_dir
15 changes: 0 additions & 15 deletions python/pyproject.toml

This file was deleted.

1 change: 0 additions & 1 deletion python/triton/_C/include

This file was deleted.

22 changes: 11 additions & 11 deletions python/triton/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import importlib
import inspect
import os
import sys
from dataclasses import dataclass
from .driver import DriverBase
from .compiler import BaseBackend

if sys.version_info >= (3, 10):
from importlib.metadata import entry_points
else:
from importlib_metadata import entry_points


def _find_concrete_subclasses(module, base_class):
ret = []
Expand All @@ -27,16 +32,11 @@ class Backend:

def _discover_backends():
backends = dict()
root = os.path.dirname(__file__)
for name in os.listdir(root):
if not os.path.isdir(os.path.join(root, name)):
continue
if name.startswith('__'):
continue
compiler = importlib.import_module(f"triton.backends.{name}.compiler")
driver = importlib.import_module(f"triton.backends.{name}.driver")
backends[name] = Backend(_find_concrete_subclasses(compiler, BaseBackend),
_find_concrete_subclasses(driver, DriverBase))
for ep in entry_points().select(group="triton.backends"):
compiler = importlib.import_module(f"{ep.value}.compiler")
driver = importlib.import_module(f"{ep.value}.driver")
backends[ep.name] = Backend(_find_concrete_subclasses(compiler, BaseBackend),
_find_concrete_subclasses(driver, DriverBase))
return backends


Expand Down
Loading
Loading