facebookresearch/xformers

Hackable and optimized Transformers building blocks, supporting a composable construction.

What it solves

It provides a toolbox of highly optimized, customizable building blocks for Transformer models, reducing the boilerplate code and performance bottlenecks typically found in mainstream libraries. It specifically addresses the need for faster iteration and lower memory usage during AI research in domains like NLP and computer vision.

How it works

xFormers implements bleeding-edge components and custom CUDA kernels to maximize speed and memory efficiency. It offers specialized operations—such as memory-efficient exact attention and fused layers—that go beyond standard PyTorch primitives, while still being able to dispatch to other libraries when necessary.

Who it’s for

AI researchers and developers working with Transformer architectures who need high-performance components for vision, NLP, and other domain-agnostic applications.

Highlights

  • Memory-efficient exact attention: Capable of being up to 10x faster than standard implementations.
  • Fused operations: Includes fused softmax, linear layers, layer norm, dropout, and SwiGLU to reduce overhead.
  • Advanced attention mechanisms: Supports sparse and block-sparse attention.
  • Research-focused: Provides access to components not yet available in mainstream libraries.

Related

  • Project
  • Project
  • Project
  • Project
  • Project