SKILL

optimization-flash-attention

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.

Target: Learning & research. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original English text

Topics in the source

  • Flash Attention - Fast Memory-Efficient Attention
  • Quick start
  • Common workflows
  • Workflow 1: Enable in existing PyTorch model
  • Workflow 2: Use flash-attn library for advanced features
  • Workflow 3: H100 FP8 optimization (FlashAttention-3)
  • When to use vs alternatives
  • Common issues

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+): flash-attn library (more features): Copy this checklist: Step 1: Check PyTorch version If 512 tokens. Step 4: Test accuracy matches baseline For multi-query attention, sliding window, or H100 FP8. Copy this checklist: Step 1: Install flash-attn library Step 2: Modify attention code Step 3: Enable advanced features Multi-query attention (shared K/V across heads): Sliding window attention (local attention): Step 4: Benchmark performance For maximum performance on H100 GPUs. Step 1: Verify H100 GPU Step 2: Install flash-attn with FP8 support Step 3: Convert inputs to FP8 Step 4: Run with FP8 attention Use Flash Attention when: Training transformers with sequences >512 tokens Running inference with long context (>2K tokens) GPU memory constrained (OOM with standard attention) Need 2-4x speedup without accuracy loss Using PyTorch 2.2+ or can install flash-attn Use alternatives instead: Standard attention: Sequences 2K tokens: 3-4x speedup Check sequence length is sufficient. Issue: RuntimeError: CUDA error Verify G

This is an excerpt. Refer to the complete source and its current requirements.

Source repository
davila7/claude-code-templates
Source file
cli-tool/components/skills/ai-research/optimization-flash-attention/SKILL.md
Fixed revision
21be197f100a12b8d0dd9a211cc244c8179f84d3
Read the complete original documentation ↗

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: davila7/claude-code-templates · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:43.297Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.