← All stories
● Covered by 1 source · 1 reportMedium impact1 neutral

FlashAttention Kernel Automatically Deduced from 25 Lines of SQL

🔄 Updated 7d ago
New to BrevFeed? We gather this story from every outlet covering it into one summary — ranked by real-world impact, not just the latest headline — so you never miss what matters. What is BrevFeed? →

Key points

  • FlashAttention kernel deduced from 25 lines of SQL.
  • Uses einfold query optimizer for SQL plan rewriting.
  • Avoids storing N×N scores, improving efficiency.
  • Applies to causal attention with gradient.
  • Supports multiple SQL engines.

SQL-Based FlashAttention Deduction

A new development demonstrates the automatic deduction of the FlashAttention kernel from a concise SQL query, approximately 25 lines long. This process enables the efficient computation of the attention mechanism, a core component of transformer models, directly from a SQL definition.

Leveraging einfold for Optimization

The deduction relies on einfold, a query optimizer designed to rewrite SQL plans into array algorithms. This tool interprets the SQL definition of attention, which typically involves sums over joins, and transforms it into an optimized plan that mirrors the FlashAttention approach. This optimization is crucial for performance, especially with large datasets.

Efficiency Gains in Attention Computation

The standard SQL approach to attention computation would store all N×N scores, leading to significant memory overhead. By using einfold, the system computes the same result without storing these intermediate scores. It achieves this by streaming blocks of keys past blocks of queries and maintaining a running softmax, a technique central to FlashAttention's efficiency.

Implications for AI Development

This method applies to causal attention, including its gradient, and is compatible with several SQL engines. The ability to define and optimize complex AI kernels like FlashAttention using a high-level language like SQL could simplify development and deployment for researchers and engineers working with large language models and other transformer-based architectures.

✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →

The daily brief

One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.

One email a day. Unsubscribe in one click, any time.

Today's brief

Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.

~4 min · 3 stories · Nov 07

▶ Play today's brief Listen on Spotify

New every morning, and the back catalogue is archived by date.

Reporting from

A new method automatically deduces the FlashAttention kernel from approximately 25 lines of SQL code. This is achieved using einfold, a query optimizer that rewrites SQL plans into array algorithms, allowing for efficient computation of attention without storing all N×N scores.