Agent skill · AI & Agents

optimizing-attention-flash

Optimizes transformer attention with Flash Attention for 2-4x speedup and 10-20x memory reduction. Use when training/running transformers with long sequences (>512 tokens), encountering GPU memory issues with attention, or need faster inference. Supports PyTorch native SDPA, flash-attn library, H100 FP8, and sliding window attention.

Orchestra-Researchgithub.com/Orchestra-ResearchGitHub ↗
claude-codecodexMIT
Install
npx skills add Orchestra-Research/AI-Research-SKILLs --skill flash-attention --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 3
SKILL.md size: 10 KB
Bundled scripts: none
Version: 1.0.0
Declared author: Orchestra Research
Requires: [flash-attn, torch, transformers]
Path: 10-optimization/flash-attention/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 11,391
Language: TeX
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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+)**: ```python 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)**: ```bash pip install flash-attn --no-build-isolation ``` ```python 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 ``` **Step 1: Check

What's inside
Steps it walks through
  1. Quick start
  2. Common workflows
  3. Workflow 1: Enable in existing PyTorch model
  4. Workflow 2: Use flash-attn library for advanced features
  5. Workflow 3: H100 FP8 optimization (FlashAttention-3)
  6. When to use vs alternatives
  7. Common issues
  8. Advanced topics
  9. Hardware requirements
  10. Resources
Ships with 2 files
  • references/benchmarks.md
  • references/transformers-integration.md
Commands it runs
pip install flash-attn --no-build-isolation
python -c "import torch; print(torch.__version__)"
Should be ≥2.2.0
pip install --upgrade torch
NVIDIA GPUs (CUDA 12.0+)
Verify installation
python -c "from flash_attn import flash_attn_func; print('Success')"
nvidia-smi --query-gpu=name --format=csv
Should show "H100" or "H800"
FP8 support included for H100
More from AI-Research-SKILLs
All skills →
About this skill
What does the optimizing-attention-flash skill do?

Optimizes transformer attention with Flash Attention for 2-4x speedup and 10-20x memory reduction. Use when training/running transformers with long sequences (>512 tokens), encountering GPU memory issues with attention, or need faster inference. Supports PyTorch native SDPA, flash-attn library, H100 FP8, and sliding window attention.

How do I install it?

Run `npx skills add Orchestra-Research/AI-Research-SKILLs --skill flash-attention --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From Orchestra-Research/AI-Research-SKILLs, a repository with 11,391 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going