optimizing-attention-flash

Apply Flash Attention to transformer models for reduced memory usage and increased speed.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/t2ance/dr-claw-plugin --skill optimizing-attention-flash-t2ance
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: optimizing-attention-flash
Source: https://github.com/t2ance/dr-claw-plugin/tree/main/plugins/ml-training-stack/skills/optimization/flash-attention
Command: npx skills add https://github.com/t2ance/dr-claw-plugin --skill optimizing-attention-flash-t2ance

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Optimizes transformer attention performance by applying Flash Attention to reduce memory usage and increase speed.

Core Features & Use Cases

  • High-performance attention: 2-4x speedups and significant memory reductions for long sequences.
  • Flexible backends & features: Supports PyTorch native SDPA, the flash-attn library, FP8 on H100, multi-query attention, and sliding window attention.
  • Practical scenarios: Ideal for training and inference of models with long contexts (>512 tokens) on CUDA GPUs where memory is a bottleneck.

Quick Start

Run a quick experiment enabling the Flash Attention backend on your transformer model to observe speed and memory improvements.

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 transformer attention for long sequences to reduce memory usage?▼

Optimize transformer attention by applying Flash Attention to reduce memory usage and achieve 2-4x speedups during training or inference with long sequences exceeding 512 tokens on CUDA GPUs.

What is the best way to speed up PyTorch transformer models with long context windows?▼

The best way to speed up PyTorch transformer models is enabling flexible attention backends like PyTorch native SDPA or the flash-attn library, which significantly reduce memory bottlenecks for long-context requirements.

Does Flash Attention work with FP8 and H100 GPUs for inference acceleration?▼

Yes, Flash Attention works with FP8 on H100 GPUs, providing a specialized backend to maximize hardware acceleration and memory efficiency during transformer model training and inference.

Can I use multi-query attention and sliding window attention with Flash Attention?▼

Yes, you can use multi-query attention (MQA) and sliding window attention options through a front-end integration that enables these specific backends for your transformer models.

When should I apply Flash Attention to my transformer model?▼

Apply Flash Attention when memory is a bottleneck during training or inference of transformer models with long contexts exceeding 512 tokens on CUDA GPUs, delivering significant memory reductions and speed improvements.