ring-flash-attn
Ring attention implementation with flash attention.
What it is and what it does
Ring-flash-attn implements ring attention—a technique for distributing attention computation across multiple GPUs—by combining it with flash attention's memory-efficient kernels. It provides several variants: basic ring attention, zigzag ring attention (more compute-balanced), stripe attention, and llama3-style context parallelism, each available in batch and varlen (packed sequence) modes. The package includes a model adapter to substitute standard flash attention with ring attention during distributed training.
The main use case is training large language models on multi-GPU clusters where you want to parallelize the attention computation across devices rather than just the model parameters. It trades off some per-GPU throughput for the ability to train with longer sequences or larger models by distributing the attention workload. The varlen API supports packed sequences (multiple samples concatenated), and the llama3 variant is recommended for most varlen use cases as it offers lower memory overhead and better precision.
Use it for:
- Train large language models on multi-GPU clusters with sequence lengths that exceed single-GPU memory by distributing attention computation across devices.
- Implement context parallelism in transformer training to reduce per-GPU memory pressure and enable longer context windows.
- Optimize attention computation in distributed training when you have NVLink connectivity between GPUs and want to balance compute utilization.
- Integrate ring attention into existing model training pipelines via the provided adapter without major code refactoring.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements ring attention with flash attention for distributed multi-GPU training, enabling efficient sequence parallelism across devices with variants for different compute patterns and sequence packing strategies.
Yes, if you are training large language models on multi-GPU clusters and need distributed attention parallelism. The package has low install friction, permissive licensing, and active (though aging) maintenance. However, it is specialized infrastructure code—not a general-purpose library—and requires a distributed training setup with multiple GPUs to be useful. Verify compatibility with your environment before committing to production use.
Install
ring-flash-attn on PyPI
pip
pip install ring-flash-attnuv
uv add ring-flash-attnpoetry
poetry add ring-flash-attnInstalling ring-flash-attn
Before you install
Low install friction; pure Python wheel. Maintenance status is aging—last commit was 2025-09-10 and the project has not released since initial 0.1.8 version in 2024-09-20, though the repository remains active with 1044 stars.
License in practice
MIT license (permissive); you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install ring-flash-attn
from ring_flash_attn import substitute_hf_flash_attn, update_ring_flash_attn_params
# Initialize distributed training and substitute flash attention
substitute_hf_flash_attn(group, heads_k_stride=1)
update_ring_flash_attn_params(cu_seqlens, group)
Requires multi-GPU distributed setup with NCCL backend; NVLink between GPUs recommended for high performance. Designed for training frameworks with distributed support.
Verify before relying
- Whether the package has undeclared runtime dependencies (fact sheet lists zero but description references external libraries).
- Current stability and whether 0.1.8 is considered production-ready or still experimental.
- Compatibility with specific versions of external dependencies beyond Python >=3.8.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 338 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 215,903/month — #9,390 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ring_flash_attn-0.1.8-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
flash-attnProvides optimized GPU implementations of…
permissive · top 15,000 on PyPI
fa3-fwdProvides a lightweight Flash-Attention-3…
permissive · top 15,000 on PyPI
flash-attn-4GPU-accelerated attention mechanism…
permissive · top 5,000 on PyPI
nvidia-cusparselt-cu12Provides NVIDIA's cuSPARSELt CUDA library for…
unclear · top 5,000 on PyPI
nvidia-cusparselt-cu13Provides NVIDIA's CUDA library for…
unclear · top 1,000 on PyPI
CoLT5-attentionImplements conditionally routed efficient…
permissive · top 15,000 on PyPI
local-attentionImplements local windowed attention for…
permissive · top 15,000 on PyPI
torchtitantorchtitan is a PyTorch-native platform for…
permissive · top 15,000 on PyPI
fla-coreProvides hardware-efficient implementations of…
permissive · top 15,000 on PyPI