[Paper Review] Implementing and Optimizing the Scaled Dot-Product Attention on Streaming Dataflow
This paper presents a memory-optimized implementation of scaled dot-product attention (SDPA) on streaming dataflow accelerators by reordering operations to balance dataflow latencies. It achieves full throughput with only O(1) intermediate memory—eliminating the O(N) memory overhead of standard implementations—through algorithmic restructuring inspired by FlashAttention, validated via cycle-accurate simulation on a Dataflow Abstract Machine.
Transformer models serve as the backbone of many state-ofthe-art language models, and most use the scaled dot-product attention (SDPA) mechanism to capture relationships between tokens. However, the straightforward implementation of SDPA has quadratic compute and memory complexity with respect to the sequence length. On processor architectures such as GPUs and TPUs, there is a robust body of prior work. However, little work has been performed on non-processor architectures.In this work, we show how the architecture and execution model of Streaming Dataflow Accelerators can help tackle this challenge. We first define abstract hardware that adopts a streaming execution model, and we implement a cycle-accurate simulator of the abstract hardware using the Dataflow Abstract Machine simulation framework. Second, we implement the naive SDPA algorithm on this abstract hardware and show it requires linear (O(N)) intermediate memory. Third, we then modify the naive algorithm, taking inspiration from prior processor-oriented works, by reordering the multiplication and division operations. Finally, we map the modified algorithm to abstract hardware, and confirm that the implementation computes SDPA at full throughput while only using a constant amount (O(1)) of intermediate memory.
Motivation & Objective
- To address the quadratic memory complexity of scaled dot-product attention (SDPA) in non-processor architectures like streaming dataflow accelerators.
- To enable full-throughput SDPA execution on streaming dataflow hardware with minimal intermediate memory usage.
- To demonstrate that algorithmic reordering of operations can eliminate O(N)-sized FIFOs required in naive streaming implementations.
- To validate that O(1) intermediate memory is sufficient for full-throughput SDPA via cycle-accurate simulation.
Proposed method
- Define an abstract streaming dataflow hardware model based on Parallel Patterns, including Map, Reduce, Scan, and MemReduce nodes.
- Implement a cycle-accurate simulator using the Dataflow Abstract Machine (DAM) framework to verify functional correctness and memory usage.
- Map the naive SDPA algorithm to the abstract hardware, confirming O(N) intermediate memory due to unbalanced latencies in divergent dataflow paths.
- Reorder operations in the softmax and matrix multiplication steps using the distributive property to balance computation latencies across paths.
- Replace row-wise reductions with running max and running sum operations, enabling rescaling via delta terms to maintain numerical stability.
- Map the optimized algorithm to the abstract hardware, using only short FIFOs (depth 2) and confirming O(1) intermediate memory usage at full throughput.

Experimental results
Research questions
- RQ1Can SDPA be implemented on streaming dataflow accelerators with intermediate memory complexity below O(N)?
- RQ2What algorithmic modifications are required to balance divergent dataflow paths and eliminate large FIFOs?
- RQ3Can the memory footprint be reduced to O(1) while maintaining full throughput and numerical stability?
- RQ4How does reordering the division and multiplication operations in softmax affect memory and latency in a streaming execution model?
Key findings
- The naive SDPA implementation on streaming dataflow hardware requires O(N) intermediate memory due to unbalanced latencies in divergent dataflow paths.
- By reordering the division operation in softmax and using running max and running sum, the algorithm achieves balanced latencies across dataflow paths.
- The optimized algorithm eliminates the need for O(N)-deep FIFOs by replacing row-wise reductions with element-wise scan operations and rescaling via delta terms.
- The final implementation achieves full throughput with only O(1) intermediate memory, confirmed via cycle-accurate simulation on the Dataflow Abstract Machine.
- The method maintains numerical stability through scaling and rescaling techniques, similar to FlashAttention, while operating within a streaming execution model.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.