optimizing-attention-flash

Optimize transformer attention with Flash Attention for PyTorch workflows.

1.0k|117|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/OpenLAIR/dr-claw --skill optimizing-attention-flash-openlair
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: optimizing-attention-flash
Source: https://github.com/OpenLAIR/dr-claw/tree/main/skills/optimization/flash-attention
Command: npx skills add https://github.com/OpenLAIR/dr-claw --skill optimizing-attention-flash-openlair

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Flash Attention optimizes transformer attention to deliver 2-4x speedups and 10-20x memory reductions.

Core Features & Use Cases

  • Reduces memory footprint of self-attention for long-context models.
  • Enables faster training and inference on sequences longer than 512 tokens.
  • Supports PyTorch native SDPA, the flash-attn library, H100 FP8, and sliding window attention.

Quick Start

Enable Flash Attention in your transformer model to achieve faster forward passes and lower memory usage on long sequences.

Frequently Asked Questions about optimizing-attention-flash

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize PyTorch transformer attention for long-context sequences?

Flash Attention optimizes transformer attention for long contexts to deliver 2-4x speedups and 10-20x memory reductions. It reduces the memory footprint of self-attention for long-context models.

What is the best way to reduce memory usage for transformers with sequences over 512 tokens?

Flash Attention reduces memory usage by 10-20x and enables faster training and inference on sequences longer than 512 tokens where memory or latency is a concern.

Does Flash Attention work with PyTorch native SDPA and the H100 FP8 architecture?

Flash Attention supports PyTorch native SDPA, the flash-attn library, H100 FP8, sliding window attention, and multi-query attention across PyTorch-based workflows.

How do I enable Flash Attention in my transformer model for faster forward passes?

Enabling Flash Attention in your transformer model achieves faster forward passes and lower memory usage on long sequences using the flash-attn, torch, and transformers dependencies.

When should I not use Flash Attention for my transformer workflow?

Flash Attention is specifically designed for transformers with long contexts exceeding 512 tokens, and requires the flash-attn, torch, and transformers dependencies to function properly.