facebookresearch/xformers
Hackable and optimized Transformers building blocks, supporting a composable construction.
What it solves
Transformers are powerful but often slow and memory-hungry, especially attention mechanisms. Researchers waste time implementing and optimizing core components. xFormers provides ready-to-use, highly optimized building blocks so you can skip low-level engineering and focus on new ideas.
How it works
xFormers offers independent, customizable components such as memory-efficient exact attention, sparse and block-sparse attention, fused softmax, fused linear layers, fused layer norm, fused dropout, and fused SwiGLU. These pieces plug directly into your existing PyTorch code without boilerplate. The library relies on optimized kernels from MSLK, FlashAttention, PyTorch, and Triton to achieve speed and memory savings.
Who it’s for
Researchers and developers working on Transformer-based models in vision, NLP, and other domains. It suits anyone who wants state-of-the-art components that are not yet in mainstream libraries like PyTorch, while keeping iteration speed high.
Highlights
- Memory-efficient exact attention that can be up to 10x faster.
- Support for sparse and block-sparse attention.
- Fused operations like softmax, linear layers, layer norm, dropout, and SwiGLU.
- Domain-agnostic and customizable building blocks.
- Built with research-first mentality, including bleeding-edge components.
Related
- Project
- Project
- Project
- Project
- Project