A repository to unravel the language of GPUs, making their kernel conversations easy to understand
Python
216
75 commits
updated Jun 1, 2025
Triton Academy is an initiative to educate developers on writing efficient GPU kernels using Triton. It's a work in progress and it's goal is to provide:
🎓 Tutorials – Learn Triton step by step
🔍 Famous Triton Kernels detailed explanations
📐 Mathematic formulas and proofs behind backpropogation in kernels
📖 Documentation & Debugging – Official docs and best practices
🔬 Benchmarks – Performance comparisons with CUDA
Triton is an open-source programming language and compiler designed specifically for GPU programming. It aims to simplify the development of efficient GPU kernels by providing a higher-level abstraction than CUDA or other low-level GPU programming models.
Triton enables developers to write high-performance GPU code with Python-like syntax while automatically handling many low-level optimizations that would otherwise require significant expertise in GPU architecture. It was developed by OpenAI and is now widely used in machine learning and scientific computing applications.
While CUDA offers fine-grained control over GPU programming, it comes with several challenges:
Triton addresses these issues by:
Let’s expand on your example and provide comprehensive resources on Triton, details on Triton Academy, and how you can contribute!
import torch
import triton
import triton.language as tl
@triton.jit
def vector_add_kernel(X, Y, Z, N: tl.constexpr):
pid = tl.program_id(axis=0) # Get the program ID
block_size = 128 # Number of elements per block
offsets = pid * block_size + tl.arange(0, block_size) # Compute memory offsets
mask = offsets < N # Ensure we don’t go out of bounds
x = tl.load(X + offsets, mask=mask) # Load X
y = tl.load(Y + offsets, mask=mask) # Load Y
tl.store(Z + offsets, x + y, mask=mask) # Store the result
# Example usage
N = 1024
X = torch.randn(N, device="cuda")
Y = torch.randn(N, device="cuda")
Z = torch.empty(N, device="cuda")
grid = (N // 128,)
vector_add_kernel[grid](X, Y, Z, N=N)
print(Z) # Output: X + Y
Explanation:
• tl.program_id(axis=0) → Gets the program index
• tl.arange(0, block_size) → Generates thread-local indices
• tl.load and tl.store → Handle memory operations efficiently
1,176 followers · starred Mar 2025
475 followers · starred Mar 2025
125 followers · starred Oct 2025
183 followers · starred Apr 2025
A repository to unravel the language of GPUs, making their kernel conversations easy to understand
Python
216
75 commits
updated Jun 1, 2025
Triton Academy is an initiative to educate developers on writing efficient GPU kernels using Triton. It's a work in progress and it's goal is to provide:
🎓 Tutorials – Learn Triton step by step
🔍 Famous Triton Kernels detailed explanations
📐 Mathematic formulas and proofs behind backpropogation in kernels
📖 Documentation & Debugging – Official docs and best practices
🔬 Benchmarks – Performance comparisons with CUDA
Triton is an open-source programming language and compiler designed specifically for GPU programming. It aims to simplify the development of efficient GPU kernels by providing a higher-level abstraction than CUDA or other low-level GPU programming models.
Triton enables developers to write high-performance GPU code with Python-like syntax while automatically handling many low-level optimizations that would otherwise require significant expertise in GPU architecture. It was developed by OpenAI and is now widely used in machine learning and scientific computing applications.
While CUDA offers fine-grained control over GPU programming, it comes with several challenges:
Triton addresses these issues by:
Let’s expand on your example and provide comprehensive resources on Triton, details on Triton Academy, and how you can contribute!
import torch
import triton
import triton.language as tl
@triton.jit
def vector_add_kernel(X, Y, Z, N: tl.constexpr):
pid = tl.program_id(axis=0) # Get the program ID
block_size = 128 # Number of elements per block
offsets = pid * block_size + tl.arange(0, block_size) # Compute memory offsets
mask = offsets < N # Ensure we don’t go out of bounds
x = tl.load(X + offsets, mask=mask) # Load X
y = tl.load(Y + offsets, mask=mask) # Load Y
tl.store(Z + offsets, x + y, mask=mask) # Store the result
# Example usage
N = 1024
X = torch.randn(N, device="cuda")
Y = torch.randn(N, device="cuda")
Z = torch.empty(N, device="cuda")
grid = (N // 128,)
vector_add_kernel[grid](X, Y, Z, N=N)
print(Z) # Output: X + Y
Explanation:
• tl.program_id(axis=0) → Gets the program index
• tl.arange(0, block_size) → Generates thread-local indices
• tl.load and tl.store → Handle memory operations efficiently
1,176 followers · starred Mar 2025
475 followers · starred Mar 2025
125 followers · starred Oct 2025
183 followers · starred Apr 2025