Skip to content
orchestra-research avatar

Optimizing Attention Flash

Flash Attention drop-in for transformers that cuts attention memory and speeds up long-sequence training and inference.

CCM score
59 of 100
skills.sh installs
1.1K
GitHub stars
14.9K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers PyTorch native F.scaled_dot_product_attention and the flash-attn library, with a step-by-step integration checklist and benchmarking workflow
  • Includes three workflows: enabling the backend in an existing model, using flash_attn_func for multi-query and sliding-window attention, and FlashAttention-3 FP8 on H100
  • Verifies correctness by comparing outputs against standard attention, with a float16 tolerance of under 1e-3
  • Designed for transformers with sequences over 512 tokens, GPU out-of-memory errors in attention, or slow inference

Install

$ npx -y skills add orchestra-research/ai-research-skills --skill optimizing-attention-flash -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Flash Attention - Fast Memory-Efficient Attention

Quick start

Flash Attention provides 2-4x speedup and 10-20x memory reduction for transformer attention through IO-aware tiling and recomputation.

PyTorch native (easiest, PyTorch 2.2+):

import torch
import torch.nn.functional as F

q = torch.randn(2, 8, 512, 64, device='cuda', dtype=torch.float16)  # [batch, heads, seq, dim]
k = torch.randn(2, 8, 512, 64, device='cuda', dtype=torch.float16)
v = torch.randn(2, 8, 512, 64, device='cuda', dtype=torch.float16)

# Automatically uses Flash Attention if available
out = F.scaled_dot_product_attention(q, k, v)

flash-attn library (more features):

pip install flash-attn --no-build-isolation
from flash_attn import flash_attn_func

# q, k, v: [batch, seqlen, nheads, headdim]
out = flash_attn_func(q, k, v, dropout_p=0.0, causal=True)

Common workflows

Workflow 1: Enable in existing PyTorch model

Copy this checklist:

Flash Attention Integration:
- [ ] Step 1: Check PyTorch version (≥2.2)
- [ ] Step 2: Enable Flash Attention backend
- [ ] Step 3: Verify speedup with profiling
- [ ] Step 4: Test accuracy matches baseline

Details

Repository
github.com/orchestra-research/ai-research-skills
Categories
Data Science & Analytics, AI Agents & LLM Apps
First seen
Jun 3, 2026

Questions

What does the optimizing-attention-flash skill do?

optimizing-attention-flash speeds up transformer attention with Flash Attention, reporting 2-4x speedup and 10-20x memory reduction through IO-aware tiling and recomputation. It supports PyTorch native SDPA, the flash-attn library, H100 FP8 and sliding window attention.

When should I use optimizing-attention-flash instead of standard attention?

The optimizing-attention-flash skill is aimed at training or running transformers with sequences longer than 512 tokens, or at GPU memory problems caused by attention. Its own guidance says standard attention is better for sequences under 256 tokens, where the overhead is not worth it.

How do I install the optimizing-attention-flash skill?

Run npx -y skills add orchestra-research/ai-research-skills --skill optimizing-attention-flash -y in your project to install optimizing-attention-flash. Once installed, the agent can apply Flash Attention to your existing PyTorch attention code.

What does optimizing-attention-flash need to run?

optimizing-attention-flash expects PyTorch 2.2 or newer and an NVIDIA GPU, since Flash Attention does not run on CPU. The flash-attn library is needed for advanced features, and H100 FP8 support requires an H100 or H800 GPU.

More from orchestra-research/ai-research-skills

All 92

Similar to Optimizing Attention Flash

More Data Science & Analytics