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.
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.
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.
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 →
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.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
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.