#161 · Primary category: Deep Learning Frameworks
native-sparse-attention-pytorch
Implementation of the sparse attention pattern proposed by the Deepseek team in their "Native Sparse Attention" paper
Project last updated:08/15/25
GitHub Stars
811
Forks
52
Contributors
5
License
MIT
Why we included this project
Transformer training costs grow quadratically with context length, and this library is a direct, pip-installable answer: it reproduces the sparse attention scheme DeepSeek laid out in their Native Sparse Attention paper. You instantiate a SparseAttention module, set a few hyperparameters for the sliding window and the compression and selection blocks, and swap it in where you would normally use full attention. Because the kernels are built on Triton and PyTorch's Flex Attention rather than hand-written CUDA, the code doubles as a readable reference for prototyping hardware-aligned sparse attention. The bundled Enwik8 language-modeling example trains the module end to end, so teams testing long-context efficiency can see it work before committing to a production kernel.
Articles for this project
No articles for this project yet.
To suggest a topic or contribute an article, contact us.
Related projects in this category
tensorflow
An Open Source Machine Learning Framework for Everyone
pytorch
Tensors and Dynamic neural networks in Python with strong GPU acceleration
keras
Deep Learning for humans
nanoGPT
The simplest, fastest repository for training/finetuning medium-sized GPTs.
ray
Ray is an AI compute engine. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.