Commit Graph

119 Commits

Author SHA1 Message Date
Justin Lebar
2a3746bac5 [BUILD] use ninja (#2318) 2023-09-18 15:30:06 -05:00
Philippe Tillet
3452615d79 [BUILD] Reverted ptxas change and fixed bug in cache key computation (#1971) 2023-07-19 20:58:24 -07:00
Philippe Tillet
8207eabd7b [FRONTEND][OPTIMIZER] small perf improvements (#1945) 2023-07-14 15:11:36 -07:00
Daniyal khan
b70d07aafe [BUILD][DOCS] updated setup.py and documentation (#1930) 2023-07-11 11:46:28 -07:00
Goran Flegar
938a6754b4 [BUILD] Export compile commands (#1854)
This can be used by IDEs to figure out how to correctly compile
individual sources and offer semantic code completion.
2023-06-28 14:11:59 +00:00
Wang Weihan
4d3a92f1b8 [BUILD] Make sure always build_ext first (#1819)
The third-party backend might install its python package to the
`triton/third_party` python package during the build process. But the
`build_py` could be executed before the `build_ext`, and then `build_py`
would only copy the `packages` defined in the `setup.py` w/o the
third-party related packages as the third-party backend has not been
built, which is triggered by `build_ext`. Therefore, this PR refined the
build order a little bit to ensure `build_ext` always happens before
`build_py`.
2023-06-22 13:32:03 -07:00
Philippe Tillet
b24dc19741 [FRONTEND] cleaned up symbol names (#1782) 2023-06-14 18:55:32 -07:00
Wang Weihan
b27a91a113 [FRONTEND] Enable triton to support register thirdparty backend at runtime (#1643)
This PR intends to provide a mechanism to support a third-party backend
at runtime to generate the backend-specific code.

The mechanism provided a common class to abstract the third-party
backend logic and two essential functions to register and get the
third-party backend at runtime.

- `BaseBackend`: A common class to abstract the third-party backend
logic
- `register_backend`: Register a third-party backend with a given device
type
- `get_backend`: Get the third-party backend with a given device type

Generally, a third-party backend must inherit from `BaseBackend` and
implement all the member functions according to the backend
characteristics. As long as the backend implementation is ready, the
third-party backend can invoke `register_backend` to register it under a
given device. During the kernel compilation and execution, the mechanism
will get the registered backend to generate the kernel and launcher code
for a given device.

This PR added a dummy backend to simulate a third-party backend and
demonstrate the usage.

-
[test_device_backend.py](https://github.com/openai/triton/pull/1643/files#diff-bbe4d50624f2d11bf17c878a1ed4d422918c124c182cf9357b993240c385bea1):
To define a third-party backend and register the backend
-
[ExtensionBackend](https://github.com/openai/triton/pull/1643/files#diff-bbe4d50624f2d11bf17c878a1ed4d422918c124c182cf9357b993240c385bea1R123):
Inherit from the `BaseBackend` and implement some specific logic like
[filter out some compile
stages](https://github.com/openai/triton/pull/1643/files#diff-bbe4d50624f2d11bf17c878a1ed4d422918c124c182cf9357b993240c385bea1R129-R135)
- [Register the `ExtensionBackend` for
`CPU`](https://github.com/openai/triton/pull/1643/files#diff-bbe4d50624f2d11bf17c878a1ed4d422918c124c182cf9357b993240c385bea1R279)
  
-
[extension_backend.c](https://github.com/openai/triton/pull/1643/files#diff-169c1d08b3a0a7b343cfa3258fbc32b47e0f6c46305a112652fa1bdaaec89d29):
To provide the utility function to load kernel binary and get the
backend properties.
2023-06-09 09:09:59 -07:00
Ingo Müller
0c4de8ab72 [DEPENDENCIES] Update LLVM to 17.0.0 (c5dede880d17) and port changes. (#1668)
This depends on a [pending LLVM
release](https://github.com/ptillet/triton-llvm-releases/pull/10).

* Implement setCalleeFromCallable in CallOp.
* Cast type to ShapedType for various getters.
* Improve TritonDialect::materializeConstant due to breaking change in
constructor of arith::ConstantOp.
* Add OpaqueProperties argument in inferReturnTypes.

Co-authored-by: Philippe Tillet <phil@openai.com>
2023-05-15 21:51:14 -07:00
Michaël Benesty
858a2f0a5e [FRONTEND] Added interpreter mode (#1573)
Simple mechanism to run Triton kernels on PyTorch for debugging purpose
(upstream from Kernl).

Todo:
- random grid iteration
- support of atomic ops
- more unit tests
- cover new APIs?
2023-05-08 14:28:20 -07:00
Philippe Tillet
d338521b65 [SETUP] Removing torch as a test dependency (#1632)
circular dependency is causing troubles now that our interpreter depends
on torch 2.0 ...
2023-05-07 12:29:19 -07:00
Philippe Tillet
ec242430d1 [THIRD_PARTY] bumped ptxas version to 12.1.105 (#1574) 2023-04-24 16:49:31 -07:00
peterbell10
c71bf73f24 [BUILD] Use a persistent directory for cmake (#1548)
Fixes #1545

`build_temp` is a temporary directory which `distutils` used to keep in
the `./build` directory, but when `pyproject.toml` is present `pip` now
puts it in `/tmp` and removes it at the end of the build.

Instead, this creates a new permanent directory like
`python/build/cmake.linux_x86_64-cpython-3.8` (the old name but with
cmake instead of temp).

While I was looking at the verbose pip output, I also noticed a bunch of
warnings like
```
Python recognizes 'triton/runtime.backends' as an importable package,
but it is not listed in the `packages` configuration of setuptools.

'triton/runtime.backends' has been automatically added to the distribution only
because it may contain data files, but this behavior is likely to change
in future versions of setuptools (and therefore is considered deprecated).
```

So I've also added these to the packages list.

---------

Co-authored-by: Keren Zhou <kerenzhou@openai.com>
2023-04-20 16:38:44 -07:00
Daniil Fukalov
a90a2d864f [BUILD] Add ability to build with clang+lld. (#1544)
This way reduces build time with assertions enabled LLVM and
dramatically speeds up triton's build with a "debug" LLVM.

Co-authored-by: Philippe Tillet <phil@openai.com>
2023-04-18 21:20:12 +00:00
Philippe Tillet
e5c7d2a83c [FRONTEND] cleaned up language; added frontend function for globaltimer special register (#1525) 2023-04-14 15:29:27 -07:00
Philippe Tillet
c0d86d3b04 [RUNTIME] refactor driver (#1515)
Improved separation between different backends
2023-04-12 23:50:44 -07:00
Phil Tillet
d7d62ddae9 Revert "[BUILD] Fixed typo in setup.py"
This reverts commit 2931bb8195.
2023-04-11 20:12:22 -07:00
Phil Tillet
2931bb8195 [BUILD] Fixed typo in setup.py 2023-04-11 20:09:09 -07:00
Philippe Tillet
e0d6f5f4f5 [BUILD] updated LLVM binaries (#1504)
Co-authored-by: Christian Sigg <csigg@google.com>
2023-04-11 00:14:00 -07:00
Eta
577cafff0a [BUILD] Add missing subpackages to build (#1475)
The `triton/compiler`, `triton/runtime/driver`, and `triton/third_party`
subpackages were missing from the distribution built with the old
`setup.py` after #1464, causing an immediate error upon importing Triton
with a non-editable installation. This change adds the missing Python
subpackages and moves `triton/third_party` inclusion to `MANIFEST.in`,
where it will automatically be included in wheels due to the existing
`include_package_data` setup flag.
2023-04-04 22:41:08 -07:00
Philippe Tillet
053af4e9f8 [FRONTEND] Refactor file hierarchy (#1464)
The purpose of this PR is to remove some circular dependencies and
separate concerns better in the frontend. It's still not perfect --
`triton.compile` still includes a few runtime architecture-specific
component, but at least much better than before.

This PR still assumes that AMD only supports empty kernels right now.
Other PRs will follow to make the frontend supports multiple devices in
a more modular way.
2023-04-02 12:07:08 -07:00
Francisco Massa
c1b057eee9 [FRONTEND] Add option to specify number of compilation threads during Triton compilation (#1450)
On some machines, the amount of available RAM might not be enough to
compile Triton with `2 * num_cpus` parallelism. For example, CircleCI's
`large` instance can't handle Triton compilation as is due to
insufficient memory.

Instead, I propose to take PyTorch's approach where we can define a
[`MAX_JOBS` env
var](0e4ddc2b40/tools/setup_helpers/cmake.py (L366-L368))
that gives the user the possibility to reduce (or increase) the
parallelism during compilation.

Co-authored-by: Philippe Tillet <phil@openai.com>
2023-03-31 11:34:18 -07:00
Philippe Tillet
fe76b12354 [BUILD] Back to cmake >= 3.18 (#1428) 2023-03-27 16:47:34 -07:00
Xuehai Pan
c52219b5c3 [SETUP] avoid using deprecated distutils (#1400)
Module [`distutils`](https://docs.python.org/3/library/distutils.html)
is deprecated and will be removed in Python 3.12.

Ref:

- `distutils` documentation:

> ##
[distutils](https://docs.python.org/3/library/distutils.html#module-distutils)
— Building and installing Python modules
>
[distutils](https://docs.python.org/3/library/distutils.html#module-distutils)
is deprecated with removal planned for Python 3.12.

- PEP 632 – Deprecate distutils module:

> [PEP 632 – Deprecate distutils
module](https://peps.python.org/pep-0632)

------

This PR removes references to `distutils` and replaces them with
[`packaging`](https://pypi.org/project/packaging) and[
`sysconfig`](https://docs.python.org/3/library/sysconfig.html).
Alleviate potential breakage in the modern Python packaging system.

Changes:

- Removes references to `distutils` and replaces them with
[`packaging`](https://pypi.org/project/packaging) and[
`sysconfig`](https://docs.python.org/3/library/sysconfig.html)
- Add `cmake` and `package` in `build-system.requires` to install
necessary build dependencies prior to calling `setup.py`.
- Minor changes: `multiprocessing.cpu_count() -> os.cpu_count()` and add
PyPI classifiers.

---------

Co-authored-by: Philippe Tillet <phil@openai.com>
2023-03-27 10:37:47 -07:00
Philippe Tillet
7c7b769e37 [SETUP] Fixed dependencies (#1389) 2023-03-22 16:15:35 -07:00
Philippe Tillet
e4b2d1bc3d [FRONTEND][BACKEND] no longer using indices for loops (#1370) 2023-03-19 14:57:50 -07:00
Stonepia
109b5e2729 [BUILD] Fix the build bug when user use system package of llvm by setting LLVM_SYSPATH (#1336)
When the user set the `LLVM_SYSPATH` to use custom build llvm, it will
throw the error because there is no version.txt under the custom build
one.

This PR skips the version check If the `LLVM_SYSPATH` is set.

---------

Co-authored-by: Philippe Tillet <phil@openai.com>
2023-03-15 13:28:19 -07:00
Phil Tillet
773c29cfaa [BUILD] Fix comment typo 2023-03-07 16:47:30 -08:00
Phil Tillet
305f99e614 [BUILD] Fixed typo in setup.py 2023-03-07 15:45:36 -08:00
Philippe Tillet
c34b32866b [BUILD] re-download package if version has changed (#1294) 2023-03-07 10:15:35 -08:00
Philippe Tillet
ff94e34430 [TESTS][BUILD] now using llvm @ 8e5a41e8271f (#1282)
Now we also use the FileTest utility packaged with llvm pre-built binaries
2023-03-05 17:23:00 -08:00
Keren Zhou
77c145cec8 [BUILD] Bump cmake requirement to >= 3.20 and format CMakeLists.txt (#1276)
cc @malfet
2023-03-03 11:43:09 -08:00
Phil Tillet
c7581c9a91 [PACKAGING] bump dev version to 2.1.0 2023-03-02 21:52:30 -08:00
BillSchumacher
6b44d31ae4 [BUILD] windows and cmake compatibility. (#1214)
Make cmake happier, it doesn't like multiple target_link_library
definitions for the same name.

Use find_package instead on Windows for dlfcn-win32. 
Set LLVM_SYS_PATH on Windows for python setup.

Debug build almost working, AlwaysCreate error thrown still.
2023-02-19 09:51:50 +00:00
Christian Sigg
9ef4b5d773 Rebase to LLVM-head. (#1200)
Rebase to
37b7a60cd7
2023-02-17 13:16:11 -08:00
Philippe Tillet
969331aedd [BUILD] fixed setup.py on older glibc (#1206) 2023-02-16 19:43:18 -08:00
Christian Sigg
fc7a8e3581 Rebase Triton to LLVM-15. (#1070)
This PR rebases Triton from LLVM-14 to LLVM-15. Most changes are
mechanical, except for the analysis framework changes.
2023-02-16 06:40:53 -08:00
Nikita Shulga
ebbd9a5df3 [BUILD] remove unused global var (#1161)
`package_data` is no longer referenced from anywhere.

Use `third_party/**/*` wildcard to package contents of subfolders
2023-02-08 05:23:05 +00:00
Stonepia
a13ddf08e2 [FRONTEND] Fix bug when the _SYSPATH is set. (#1156) 2023-02-06 18:02:42 +00:00
Emil Masoumi
dff43abbb9 [Build] Prevent excessive hyphens from causing build errors. (#1151)
Prevents excessive hyphens from causing build errors on non-Windows
machines.
2023-02-04 00:22:57 -08:00
Philippe Tillet
43798ab27e [BUILD] Restored wheels workflow (#1146)
- Dependent CUDA files (ptxas, cuda.h, libdevice.bc.10) are now packaged in
`triton/third_party/cuda`. `ptxas` is downloaded from conda repo at
install time.
- Can now be built with old glibc (as that used by manylinux2014)
2023-02-03 16:22:10 -08:00
Nikita Shulga
e9446c7ce3 [BUILD] Add ability to bundle CUDA dependencies (#1100) 2023-01-27 09:55:49 -08:00
Edward Z. Yang
cf0ae2ed76 [BUILD] Still build even if lit is not installed on user's system (#1095)
Otherwise it fails with

```
File "setup.py", line 147, in build_extension
    "-DLLVM_EXTERNAL_LIT=" + lit_dir,`
TypeError: can only concatenate str (not "NoneType") to str
```

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
2023-01-25 12:55:59 -08:00
Da Yan
0f5c6e619c [BUILD] Add the missing triton/impl to setup.py (#1042) 2023-01-09 19:03:45 +00:00
fdrocha
194ba103b1 [BUILD] Fixed error when compiling in systems with multiple versions of python installed (#1019) 2022-12-29 15:10:34 -08:00
Philippe Tillet
20100a7254 Merge triton-mlir branch - Complete rewrite of the backend from scratch (#1004)
This PR merges the `triton-mlir` branch, in which we have been quietly
rewriting the Triton backend from scratch to increase maintainability,
stability and ultimately performance. Changes to the runtime are
minimal, and this new version aims to remain backward-compatible with
the previous commit. The legacy backend is now officially deprecated,
but can still be accessed via the `legacy-backend` tag.

Co-authored-by: Keren Zhou <kerenzhou@openai.com>
Co-authored-by: Yan Chunwei <yanchunwei@outlook.com>
Co-authored-by: goostavz <109190422+goostavz@users.noreply.github.com>
Co-authored-by: Shintaro Iwasaki <siwasaki@fb.com>
Co-authored-by: Yan Da <dyanab@connect.ust.hk>
Co-authored-by: Jun Yang <yangjunpro@gmail.com>
Co-authored-by: Ian Bearman <ianb@microsoft.com>
Co-authored-by: Jason Ansel <jansel@jansel.net>
Co-authored-by: Qingyi Liu <qingyil@nvidia.com>
Co-authored-by: ben-zhang-609 <110140741+ben-zhang-609@users.noreply.github.com>
Co-authored-by: Chenggang Zhao <lyricz@yeah.net>
Co-authored-by: ben-zhang-609 <benzh609@gmail.com>
Co-authored-by: dongdongl <dongdongl@nvidia.com>
2022-12-21 01:30:50 -08:00
Yang Hau
8650b4d1cb [DRIVER] Fix typos (#939) 2022-12-02 11:13:46 -08:00
Shintaro Iwasaki
3ac929b48b [BUILD] Download pybind11 in setup.py (#703)
Based on the discussion in #700, this PR enables downloading pybind11 in
`setup.py` without `git submodule` instead of copy-pasting pybind11
code. The downloaded pybind11 will be in `~/.triton/pybind` (like
`llvm`).
2022-09-23 15:54:07 -07:00
Philippe Tillet
25e1b36785 Revert "[pybind11] Use git-submodule for pybind11" (#701)
Reverts openai/triton#699
2022-09-23 12:25:38 -07:00
Shintaro Iwasaki
61d104ab3a [FRONTEND] Use git-submodule for pybind11 (#699)
This PR changes the `pybind11` source code management from copy-paste to
a package controlled by git-submodule.

See the discussion in #694 for details.
2022-09-23 09:55:03 -07:00