A domain-specific language based on Triton but providing higher-level abstraction.
Project description
NineToothed
NineToothed is a Triton-based domain-specific language (DSL). By introducing tensor-oriented meta-programming (TOM), it makes writing high-performance GPU kernels easier.
Installation
We can use pip to install ninetoothed.
pip install ninetoothed
After successfully running the above command, ninetoothed will be installed. However, to fully utilize its capabilities, you also need to install a deep learning framework supported by ninetoothed. For trial purposes, we recommend installing torch.
Usage
Thanks to tensor-oriented meta-programming, NineToothed can be written using the arrange-and-apply paradigm, which involves separately defining arrangement, application, and tensors, and then integrating them using ninetoothed.make to generate the kernel.
Matrix Multiplication
Here is the code we need for matrix multiplication:
import ninetoothed
import ninetoothed.language as ntl
from ninetoothed import Tensor, block_size
BLOCK_SIZE_M = block_size()
BLOCK_SIZE_N = block_size()
BLOCK_SIZE_K = block_size()
def arrangement(input, other, output):
output_arranged = output.tile((BLOCK_SIZE_M, BLOCK_SIZE_N))
input_arranged = input.tile((BLOCK_SIZE_M, BLOCK_SIZE_K))
input_arranged = input_arranged.tile((1, -1))
input_arranged = input_arranged.expand((-1, output_arranged.shape[1]))
input_arranged.dtype = input_arranged.dtype.squeeze(0)
other_arranged = other.tile((BLOCK_SIZE_K, BLOCK_SIZE_N))
other_arranged = other_arranged.tile((-1, 1))
other_arranged = other_arranged.expand((output_arranged.shape[0], -1))
other_arranged.dtype = other_arranged.dtype.squeeze(1)
return input_arranged, other_arranged, output_arranged
def application(input, other, output):
accumulator = ntl.zeros(output.shape, dtype=ntl.float32)
for k in range(input.shape[0]):
accumulator += ntl.dot(input[k], other[k])
output = accumulator
tensors = (Tensor(2), Tensor(2), Tensor(2))
kernel = ninetoothed.make(arrangement, application, tensors)
Useful Links
License
This project is distributed under the Apache-2.0 license. See the included LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ninetoothed-0.24.0.tar.gz.
File metadata
- Download URL: ninetoothed-0.24.0.tar.gz
- Upload date:
- Size: 57.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bc5e6e7993187380cf6c7e24818b9e506ca9e992e609ea57112aa9f0cd67f5e
|
|
| MD5 |
c4b2dba88a8b6c14b53e1f8ec623c9a6
|
|
| BLAKE2b-256 |
c585e780e59335ca48be089d867e1d9240c44d6eaaa47050d425c067283f187f
|
Provenance
The following attestation bundles were made for ninetoothed-0.24.0.tar.gz:
Publisher:
publish-to-pypi.yml on InfiniTensor/ninetoothed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ninetoothed-0.24.0.tar.gz -
Subject digest:
8bc5e6e7993187380cf6c7e24818b9e506ca9e992e609ea57112aa9f0cd67f5e - Sigstore transparency entry: 1186194222
- Sigstore integration time:
-
Permalink:
InfiniTensor/ninetoothed@963e14c85a2cbdde5f010f9265db6695076f7268 -
Branch / Tag:
refs/tags/v0.24.0 - Owner: https://github.com/InfiniTensor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@963e14c85a2cbdde5f010f9265db6695076f7268 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ninetoothed-0.24.0-py3-none-any.whl.
File metadata
- Download URL: ninetoothed-0.24.0-py3-none-any.whl
- Upload date:
- Size: 39.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2715141dfae2e1e310b627104f9a61bf834eef4940dec80874745b75112e67f9
|
|
| MD5 |
317bfa1a68db9ca4ea103cc7f89bcd67
|
|
| BLAKE2b-256 |
5d25c82282c632cc801b972d28f9c0fcadbd67a4c00b8f8191028acbaeba8baf
|
Provenance
The following attestation bundles were made for ninetoothed-0.24.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on InfiniTensor/ninetoothed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ninetoothed-0.24.0-py3-none-any.whl -
Subject digest:
2715141dfae2e1e310b627104f9a61bf834eef4940dec80874745b75112e67f9 - Sigstore transparency entry: 1186194230
- Sigstore integration time:
-
Permalink:
InfiniTensor/ninetoothed@963e14c85a2cbdde5f010f9265db6695076f7268 -
Branch / Tag:
refs/tags/v0.24.0 - Owner: https://github.com/InfiniTensor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@963e14c85a2cbdde5f010f9265db6695076f7268 -
Trigger Event:
push
-
Statement type: