โ† All Projects

GPU Computing & Systems

KernelForge

Custom GPU Kernels: Fused Attention & FP8 GEMM in Triton

TritonCUDAFlashAttentionFP8GEMMGPU KernelsPyTorch
๐Ÿ”’ Private Repo

Problem

Standard PyTorch attention and GEMM operations repeatedly materialize large intermediate tensors to global GPU memory (HBM), bottlenecking training at memory bandwidth rather than compute throughput.

Solution

Implemented a fused attention kernel that tiles Q, K, V into on-chip SRAM computing online softmax without writing the full NxN attention matrix to HBM. Built a block-quantized FP8 GEMM kernel with per-tile scale factors.

Architecture

Triton programs on a 2D grid over sequence tiles. Each program block loads a Q tile and iterates K/V tiles from SRAM, maintains running softmax statistics for numerically stable online normalization, and accumulates weighted V without global memory I/O.

Real-World Impact

Fused attention kernel runs 2.1x faster than PyTorch SDPA at sequence length 2048. FP8 GEMM reduced memory footprint by 50% vs FP32 with less than 0.3% perplexity degradation.

Challenges Faced

Numerically stable online softmax across SRAM tiles without global reduction; FP8 scale overflow in quantized accumulation.

Key Learnings

Roofline model analysis, GPU memory hierarchy mechanics, Triton programming model, and hardware-aware optimization.

Engineering Metrics

2.1x faster than PyTorch SDPA at seq_len=204894% peak memory bandwidth utilizationFP8 GEMM: 50% memory reduction <0.3% perplexity deltaCompute-bound above 512 token sequence length

Demo / Screenshots

Screenshots coming soon: contact me for a demo

โ† Previous

LightServe

Next โ†’

NanoAlign