skillfed

ring-flash-attn

Ring attention implementation with flash attention.

ring-flash-attn v0.1.8 215.9K downloads/30d#9,390 on PyPI1,044
Permissive license AGING released

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-attn

uv

uv add ring-flash-attn

poetry

poetry add ring-flash-attn

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

ring attention flash attentiondistributed sequence parallelismmulti-gpu attention optimizationcontext parallelism trainingvarlen packed attention
distributed-trainingattention-optimizationsequence-parallelism

More Artificial Intelligence packages

Further reading