Registry / ai-ml / ring-flash-attn

ring-flash-attn

JSON →
library0.1.8pypypiunverified

Ring attention implementation with flash attention for efficient long-context LLM training. Supports distributed memory and compute parallelism. Current version: 0.1.8, actively maintained on GitHub, weekly releases.

pip install ring-flash-attn
INSTALL
IMPORT
SIG · RING-FLASH-ATTN
R
ring-flash-attn
ai-mlpythonv0.1.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ring_flash_attn_func
from ring_flash_attn import ring_flash_attn_func
from ring_flash_attn import ring_flash_attn_func

Basic usage: compute ring flash attention with default settings. Requires CUDA and flash-attn installed.

import torch from ring_flash_attn import ring_flash_attn_func batch_size = 4 seqlen = 8192 nheads = 8 headdim = 128 dtype = torch.bfloat16 device = 'cuda' q = torch.randn(batch_size, seqlen, nheads, headdim, dtype=dtype, device=device) k = torch.randn(batch_size, seqlen, nheads, headdim, dtype=dtype, device=device) v = torch.randn(batch_size, seqlen, nheads, headdim, dtype=dtype, device=device) out = ring_flash_attn_func(q, k, v) print(out.shape)
Debug
Known issues
breakingtorch.compile compatibility: the ring flash attention function may not compile correctly with torch.compile. Use eager mode.
fix
Avoid applying torch.compile to models using ring_flash_attn_func; rely on native eager execution.
affects: all
gotchaSequence length must be divisible by the number of GPUs when using distributed ring attention.
fix
Ensure seqlen % world_size == 0 before calling the function.
affects: all
deprecatedThe old import path from 'ring_flash_attn.ring_flash_attn' is deprecated; use top-level import from 'ring_flash_attn'.
fix
Use 'from ring_flash_attn import ring_flash_attn_func' instead.
affects: >=0.1.0
Upgrade
Version history
0.1.8latest on PyPI · released Sep 10, 2025
Audit
Dependencies
flash-attnoptionalRequired for flash attention kernels; optional but recommended.
torchrequiredCore dependency for tensor operations and distributed communication.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
ring-flash-attn — pip install ring-flash-attn · libregistry