xformers is a modular, performance-oriented library of transformer building blocks, designed to allow researchers and engineers to compose, experiment, and optimize transformer architectures more flexibly than monolithic frameworks. It abstracts components like attention layers, feedforward modules, normalization, and positional encoding, so you can mix and match or swap optimized kernels easily. One of its key goals is efficient attention: it supports dense, sparse, low-rank, and approximate attention mechanisms (e.g. FlashAttention, Linformer, Performer) via interchangeable modules. The library includes memory-efficient operator implementations in both Python and optimized C++/CUDA, ensuring that performance isn’t sacrificed for modularity. It also integrates with PyTorch seamlessly so you can drop in its blocks to existing models, replace default attention layers, or build new architectures from scratch. xformers includes training, deployment, and memory profiling tools.

Features

  • Modular transformer building blocks (attention, FFN, norms, position encodings)
  • Support for various efficient attention types (sparse, approximate, locality)
  • Optimized GPU kernels and fallback Python implementations
  • Seamless integration with PyTorch models and training loops
  • Profiling and benchmarking tools to compare throughput, memory, and latency
  • Support for mixing attention types in one model (hybrid architectures)

Project Samples

Project Activity

See All Activity >

Categories

AI Models

License

MIT License

Follow xFormers

xFormers Web Site

Other Useful Business Software
$300 Free Credits for Your Google Cloud Projects Icon
$300 Free Credits for Your Google Cloud Projects

Start building on Google Cloud with $300 in free credits. No commitment, no credit card required until you're ready to scale.

Launch your next project with $300 in free Google Cloud credits—no strings attached. Test, build, and deploy without risk. Use your credits across the entire Google Cloud platform to find what works best for your needs. After your credits are used, continue with always-free tier services. Only pay when you're ready to scale. Sign up in minutes and start exploring.
Start Free Trial
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of xFormers!

Additional Project Details

Operating Systems

Linux, Windows

Programming Language

Python

Related Categories

Python AI Models

Registered

2025-10-06