A lightweight triton-based General Matrix Multiplication (GEMM) library.
See the code[!IMPORTANT] This project is intended for research purposes only. Use it at your own risk and discretion.
Triton is a language and compiler for writing highly efficient ML primitives, one of the most common primitive is matrix-multiplication. Triton typically builds these primitives using just-in-time (JIT) compilation, and relies on functionality such as @triton.autotune to create efficient variants of the primitives. Autotune evaluates all the possible configurations defined by the user to produce a kernel perfect for a given inputs.
Our work, tritonBLAS, removes the need for autotune and heuristics, and instead uses an analytical model to predict the correct configuration for common algorithms such as Matrix Multiplication. We believe this technique is also extensible to other dense, static, well-defined primitives in the Deep-learning applications.
Because there is now no need for autotuning or heuristcis, we now produce a library that is;
tritonBLAS currently requires a dependency on a few C++ files from hipBLASLt, which it will automatically fetch. Run the following to setup a docker container with rocm/pytorch:latest-release and a fresh triton install:
docker compose up --build -d
docker attach tritonBLAS-dev
pip3 install -e .
export PYTHONPATH=$(pwd)/include/:$PYTHONPATH
Run a simple example:
cd examples
python3 example_matmul.py
Borrows from performant variants of BLAS interfaces such as hipBLASLt and cuBLASLt, where the user initiates an initial call to set up some arguments and learn from the matrix descriptors before calling the actual matmul.
tritonblas.OrigamiMatmulSelector(m, n, k, a_dtype, b_dtype, c_dtype, device) → OrigamiMatmulSelector
Parameters:
Returns:
OrigamiMatmulSelector: An object containing a precomputed kernel configuration optimized for the provided matrix dimensions.tritonblas.matmul_lt(input,other,*,out=None,selector,enable_streamk=False) → Tensor
OrigamiMatmulSelector, providing optimal tiling and launch parameters.False.torch.matmul (work-in-progress)Borrows from familiar pytorch API (torch.matmul) making integration within larger models and applications seamless.
tritonblas.matmul(input,other,*,out=None,enable_streamk=False) → Tensor
Parameters
Keyword Arguments
False.As we work on supporting other BLAS and ML primitives and data types, we will update this document to reflect that.
| Transpose (A/B) | TF32 | FP32 | FP16 | BF16 | FP8 | FP4 |
|---|---|---|---|---|---|---|
| T/N | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| N/T | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| T/T | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| N/N | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
The official list of developers and contributors is available here: CONTRIBUTORS. We welcome contributions! Please see our Contributing Guide for details on how to set up your development environment and contribute to the project.
Need help? We're here to support you! Here are a few ways to get in touch:
We welcome your feedback and contributions!
This project is licensed under the MIT License - see the LICENSE file for details.
Python
100.0%
A lightweight triton-based General Matrix Multiplication (GEMM) library.
See the code[!IMPORTANT] This project is intended for research purposes only. Use it at your own risk and discretion.
Triton is a language and compiler for writing highly efficient ML primitives, one of the most common primitive is matrix-multiplication. Triton typically builds these primitives using just-in-time (JIT) compilation, and relies on functionality such as @triton.autotune to create efficient variants of the primitives. Autotune evaluates all the possible configurations defined by the user to produce a kernel perfect for a given inputs.
Our work, tritonBLAS, removes the need for autotune and heuristics, and instead uses an analytical model to predict the correct configuration for common algorithms such as Matrix Multiplication. We believe this technique is also extensible to other dense, static, well-defined primitives in the Deep-learning applications.
Because there is now no need for autotuning or heuristcis, we now produce a library that is;
tritonBLAS currently requires a dependency on a few C++ files from hipBLASLt, which it will automatically fetch. Run the following to setup a docker container with rocm/pytorch:latest-release and a fresh triton install:
docker compose up --build -d
docker attach tritonBLAS-dev
pip3 install -e .
export PYTHONPATH=$(pwd)/include/:$PYTHONPATH
Run a simple example:
cd examples
python3 example_matmul.py
Borrows from performant variants of BLAS interfaces such as hipBLASLt and cuBLASLt, where the user initiates an initial call to set up some arguments and learn from the matrix descriptors before calling the actual matmul.
tritonblas.OrigamiMatmulSelector(m, n, k, a_dtype, b_dtype, c_dtype, device) → OrigamiMatmulSelector
Parameters:
Returns:
OrigamiMatmulSelector: An object containing a precomputed kernel configuration optimized for the provided matrix dimensions.tritonblas.matmul_lt(input,other,*,out=None,selector,enable_streamk=False) → Tensor
OrigamiMatmulSelector, providing optimal tiling and launch parameters.False.torch.matmul (work-in-progress)Borrows from familiar pytorch API (torch.matmul) making integration within larger models and applications seamless.
tritonblas.matmul(input,other,*,out=None,enable_streamk=False) → Tensor
Parameters
Keyword Arguments
False.As we work on supporting other BLAS and ML primitives and data types, we will update this document to reflect that.
| Transpose (A/B) | TF32 | FP32 | FP16 | BF16 | FP8 | FP4 |
|---|---|---|---|---|---|---|
| T/N | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| N/T | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| T/T | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| N/N | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
The official list of developers and contributors is available here: CONTRIBUTORS. We welcome contributions! Please see our Contributing Guide for details on how to set up your development environment and contribute to the project.
Need help? We're here to support you! Here are a few ways to get in touch:
We welcome your feedback and contributions!
This project is licensed under the MIT License - see the LICENSE file for details.
Python
100.0%