#140 · Primary category: Deep Learning Frameworks
rotary-embedding-torch
Implementation of Rotary Embeddings, from the Roformer paper, in Pytorch
Project last updated:06/20/26
GitHub Stars
821
Forks
67
Contributors
5
License
MIT
Why we included this project
Rotary position embeddings have become the default way modern transformer models encode sequence order, and this library packages that technique into a small, focused PyTorch utility you can drop into your own attention code. You instantiate a RotaryEmbedding, rotate your queries and keys, and keep your existing attention loop, which makes it easy to add RoPE without pulling in a full framework. It covers the edge cases that tend to bite in practice: offsetting positions when you have key/value caches at inference, axial embeddings for video or image transformers, and length extrapolation via XPos. There's also a fused Flash Attention path that applies the rotation in a single kernel, with a reference fallback when Triton isn't available. If you're writing custom attention or testing positional encoding variants, this is a well-scoped building block that won't drag in a heavyweight dependency.
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.