Drop xFormers' memory-efficient attention into an existing PyTorch Transformer model to cut GPU memory usage on long sequences.
Speed up training of a large language model or vision Transformer by replacing standard attention with optimized GPU kernels.
Use the SwiGLU or fused linear layer components to reduce compute cost in a custom model architecture.
| facebookresearch/xformers | megvii-basedetection/yolox | livekit/agents | |
|---|---|---|---|
| Stars | 10,456 | 10,457 | 10,463 |
| Language | Python | Python | Python |
| Setup difficulty | hard | moderate | moderate |
| Complexity | 4/5 | 3/5 | 3/5 |
| Audience | researcher | researcher | developer |
Figures from each repo's GitHub metadata at analysis time.
Requires a CUDA-capable Nvidia GPU, AMD support is experimental, PyTorch version must match the prebuilt package exactly or you must compile from source.
xFormers is a Python library from Meta's research team that provides building blocks for working with Transformer models, which are the architecture behind most modern AI language and vision systems. The library is aimed at researchers and engineers who want to experiment with or optimize these models without being limited to what ships in standard tools like PyTorch. The core value the library offers is speed and memory efficiency. Transformer models, especially large ones, require a lot of GPU memory and computation. xFormers includes custom GPU code (called kernels) that makes certain operations faster or less memory-hungry than the standard implementations. The most prominent example is its memory-efficient attention operation, which the README claims can be up to 10 times faster than a standard approach while still producing exact results, not an approximation. Beyond attention, the library includes optimized versions of other common operations used inside these models: layer normalization, dropout combined with activation functions, a fused linear layer, and a component called SwiGLU used in some newer architectures. These components are designed to be used independently, so you can drop one into an existing project without having to adopt the whole library. Installation requires a compatible version of PyTorch and a CUDA-capable GPU (NVIDIA hardware on Linux or Windows). AMD GPU support is listed as experimental. The library is also available from source if you need to pair it with a specific PyTorch version not covered by the prebuilt packages. The project is primarily a research tool and is used across both language and vision work at Meta. It carries a BSD-style open-source license and includes attribution to several other open-source projects whose code or ideas it builds on.
A Python library from Meta with optimized GPU building blocks for Transformer models, offering memory-efficient attention and other components that make AI models faster and less memory-hungry than standard PyTorch implementations.
Mainly Python. The stack also includes Python, PyTorch, CUDA.
BSD-style license, use, modify, and distribute freely including for commercial purposes, with attribution to the original authors.
Setup difficulty is rated hard, with roughly 1h+ to a first successful run.
Mainly researcher.
This repo across BitVibe Labs
Verify against the repo before relying on details.