---
title: "FlashAttention-2 (NL)"
source: "https://systems-analysis.info/int/FlashAttention-2_(NL)"
wiki: "systems-analysis.info/int"
article: "FlashAttention-2_(NL)"
language: "nl"
categories:
  - "Category:Dutch"
  - "Category:Large language models"
  - "Category:Machine learning"
revision_id: 2207
wiki_created_at: 2026-09-06T23:00:17Z
wiki_modified_at: 2026-09-06T23:00:17Z
downloaded_at: 2026-09-07T22:49:50Z
---

# FlashAttention-2 (NL)

**FlashAttention-2** — dit is een verbeterd algoritme voor het berekenen van het aandachtsmechanisme (attention) in grote taalmodellen (LLM). Het algoritme werd ontwikkeld door **Tri Dao** en onderzoekers van de Stanford University en werd gepresenteerd in juli 2023<sup>[\[1\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_main-1)</sup>. Het belangrijkste doel is het aanzienlijk versnellen van het trainen en de inferentie van transformer-modellen door efficiënter gebruik van GPU-hardwarebronnen, terwijl de volledige identiteit van de berekeningen met het standaard aandachtsmechanisme behouden blijft, dat wil zeggen **zonder verlies van nauwkeurigheid**.

FlashAttention-2 is de logische opvolger van het algoritme **FlashAttention**, dat in 2022 door hetzelfde team werd gepresenteerd. De nieuwe versie lost het probleem van onvolledige GPU-belasting op dat bij de voorganger werd waargenomen, en bereikt een bijna tweevoudige snelheidswinst ten opzichte van de eerste versie.

## Achtergrond: het probleem van attention in transformers

Het standaard self-attention-mechanisme vormt een knelpunt bij het werken met lange tekstsequenties in transformers. De rekenkundige complexiteit en het geheugenverbruik groeien **kwadratisch** (O(N²)) afhankelijk van de lengte van de sequentie (N), wat ernstige beperkingen oplegt aan de maximale contextlengte en de schaalbaarheid van LLM's<sup>[\[1\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_main-1)</sup>.

Om dit probleem op te lossen werd in 2022 het algoritme **FlashAttention** gepresenteerd<sup>[\[2\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-huggingface_optim-2)</sup>. De belangrijkste ideeën:

- **Rekening houden met de geheugenhi­ërarchie van de GPU (IO-awareness)**: Het algoritme minimaliseert kostbare lees- en schrijfbewerkingen tussen het trage GPU-geheugen (HBM) en het snelle statische geheugen op de chip (SRAM).
- **Blokverwer­king (tiling)**: Berekeningen worden opgesplitst in kleine blokken (tiles) die in het snelle SRAM worden verwerkt, waardoor het volledig materialiseren van de aandachtsmatrix in het geheugen wordt vermeden.

Dit maakte het mogelijk om **lineaire** geheugengroei (O(N)) en een versnelling van 2–4 maal ten opzichte van standaardimplementaties te bereiken<sup>[\[2\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-huggingface_optim-2)</sup>. FlashAttention werd wijdverbreid toegepast en droeg bij aan het ontstaan van modellen met aanzienlijk vergroot contextvenster, bijvoorbeeld van 2–4 duizend tokens (GPT-3) tot 128 duizend (GPT-4) en meer<sup>[\[3\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-tridao_blog_fa3-3)</sup>. Zo versnelde het gebruik van FlashAttention in het model **Falcon-40B** de inferentie met een factor 3 en de algehele generatieprestaties met een factor 5 vergeleken met GPT-3<sup>[\[4\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-e2e_analysis-4)</sup>.

## Ontwikkeling en doelstellingen van FlashAttention-2

Ondanks het succes maakte de eerste versie van FlashAttention de GPU-rekenbronnen niet volledig benut. Op videokaarten van het type **NVIDIA A100** bereikte de prestatie slechts **25–40%** van het theoretische maximum (FLOPs/s)<sup>[\[1\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_main-1)</sup>. De belangrijkste oorzaak was de suboptimale belasting van de Streaming Multiprocessors en overbodige bewerkingen met gedeeld geheugen<sup>[\[5\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-openreview_fa2-5)</sup>.

Het doel van **FlashAttention-2** was het verder versnellen van berekeningen door middel van efficiëntere parallellisatie van het werk en het minimaliseren van hulpbewerkingen. Het algoritme werd volledig herschreven met behulp van laagniveau-primitieven van de bibliotheek **NVIDIA CUTLASS 3.x** om maximale prestaties te bereiken<sup>[\[6\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-hazyresearch_blog-6)</sup>.

## Technische architectuur en werkingsprincipes

FlashAttention-2 introduceert drie belangrijke verbeteringen voor hogere parallelliteit en efficiëntie<sup>[\[1\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_main-1)</sup>:

### 1. Minimalisering van niet-matrixbewerkingen

Het algoritme vermindert het aantal hulpbewerkingen met drijvende komma die geen matrixvermenigvuldiging zijn (non-matmul FLOPs). Omdat de tensor cores van de GPU geoptimaliseerd zijn voor matrixbewerkingen (GEMM) en deze tot 16 maal sneller uitvoeren, maakt deze wijziging het mogelijk om het grootste deel van de tijd de meest productieve GPU-eenheden te benutten.

### 2. Verbeterde parallelliteit

In de originele FlashAttention werd het werk aan één attention-"head" niet geparallelliseerd, wat leidde tot inactiviteit bij lange sequenties en kleine batchgroottes. FlashAttention-2 introduceert **inter-blok parallellisatie**: berekeningen voor één attention-head worden nu verdeeld over verschillende Streaming Multiprocessors van de GPU, wat de bezettingsgraad aanzienlijk verhoogt.

### 3. Geoptimaliseerde werkverdeling binnen een blok

Op het niveau van één rekenblok werd het werk herverdeeld over groepen threads (warps) om de gegevensuitwisseling via het gedeelde geheugen (shared memory) te verminderen. Dit verlaagt het aantal overbodige lees- en schrijfbewerkingen die nodig zijn voor de Softmax-normalisatie.

## Prestaties en efficiëntie

Dankzij de architectuurverbeteringen vertoont FlashAttention-2 een aanzienlijke prestatiewinst:

- **Tweevoudige versnelling**: Het algoritme werkt ongeveer **2 maal sneller** vergeleken met de eerste versie van FlashAttention<sup>[\[1\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_main-1)</sup>.
- **Hoge GPU-benutting**: Op de GPU **NVIDIA A100** wordt **50–73%** van de theoretische maximale doorvoer (TFLOPs) bereikt, wat dicht in de buurt komt van de efficiëntie van geoptimaliseerde matrixvermenigvuldigingsbewerkingen (GEMM)<sup>[\[1\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_main-1)</sup>.
- **Recordsnelheid van berekeningen**:
  - Op de GPU **A100** wordt een snelheid van wel **225 TFLOP/s** bereikt in een end-to-end trainingscyclus van een GPT-achtig model, wat overeenkomt met 72% benutting van de rekenkernen. Ter vergelijking: standaard attention belastte de GPU onder dezelfde omstandigheden met minder dan 100 TFLOP/s<sup>[\[7\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_pdf-7)</sup>.
  - Op de GPU **H100** bereikt de prestatie **335 TFLOP/s**<sup>[\[7\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_pdf-7)</sup>.

Deze prestatiewinst maakt het bijvoorbeeld mogelijk om een model met een contextvenster van **16k** tokens te trainen in dezelfde tijd die vroeger nodig was voor een venster van **8k** tokens<sup>[\[5\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-openreview_fa2-5)</sup>. Belangrijk is dat het algoritme **nauwkeurig** en deterministisch blijft, zodat de toepassing ervan de kwaliteit van de voorspellingen van het model niet beïnvloedt<sup>[\[8\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-raschka_blog-8)</sup>.

## Toepassing en integratie in het ecosysteem

FlashAttention-2 is snel een standaardinstrument geworden in het LLM-ecosysteem. Het is geïntegreerd in vele populaire frameworks en bibliotheken:

- **PyTorch**: Systeemeigen ondersteuning.
- **Hugging Face Transformers**: Ondersteuning wordt ingeschakeld via de parameter \`attn_implementation="flash_attention_2"\` bij het laden van een model<sup>[\[9\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-linkedin_younes-9)</sup>. Compatibel met tientallen architecturen (GPT, Llama, Falcon, BERT en anderen)<sup>[\[10\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-huggingface_gpu_infer-10)</sup>.
- **TensorRT-LLM**, **xFormers** en **Triton**: Het algoritme is geïmplementeerd voor deze platformen, wat wijdverbreid gebruik mogelijk maakt<sup>[\[7\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_pdf-7)</sup>.

De integratie maakt het eenvoudig om FlashAttention-2 te combineren met andere optimalisatiemethoden, zoals kwantisering (GPTQ, QLoRA) en efficiënt fine-tuning (PEFT)<sup>[\[9\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-linkedin_younes-9)</sup>.

## Vergelijking met latere versies

### FlashAttention-3

Het onderzoek op het gebied van attention-optimalisatie gaat door. In juli 2024 presenteerde Tri Dao **FlashAttention-3**, gericht op het benutten van de mogelijkheden van de GPU-architectuur **NVIDIA Hopper** (H100/H200). Belangrijkste nieuwe functies<sup>[\[3\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-tridao_blog_fa3-3)</sup>:

- **Ondersteuning voor FP8**: Maakt gebruik van 8-bit drijvende-kommaberekeningen voor verdere versnelling.
- **Asynchrone bewerkingen**: Maakt efficiënter gebruik van de asynchrone mogelijkheden van de GPU.

FlashAttention-3 levert een versnelling van **1,5–2 maal** ten opzichte van FlashAttention-2 op de GPU H100, met een prestatie van wel **740 TFLOP/s** (75% van het theoretische maximum)<sup>[\[11\]](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_note-arxiv_fa3-11)</sup>.

## Literatuur

- Dao, T. (2023). *FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning*. arXiv:2307.08691.
- Dao, T. et al. (2022). *FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness*. arXiv:2205.14135.
- Shah, J. et al. (2024). *FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision*. arXiv:2407.08608.
- Kwon, W. et al. (2023). *Efficient Memory Management for Large Language Model Serving with PagedAttention*. arXiv:2309.06180.
- Ye, Z. et al. (2025). *FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving*. arXiv:2501.01005.
- Chen, Y. et al. (2023). *FlashDecoding++: Faster Large Language Model Inference on GPUs*. arXiv:2311.01282.
- Liu, Y. et al. (2024). *FastAttention: Extending FlashAttention-2 to NPUs and Low-Resource GPUs*. OpenReview: 76NYyOrnfk.
- Dege, P. et al. (2025). *FlashMLA-ETAP: Efficient Transpose Attention Pipeline for Accelerating MLA Inference on NVIDIA H20 GPUs*. arXiv:2506.01969.
- Wang, G. et al. (2024). *FlashMask: Efficient and Rich Mask Extension of FlashAttention*. OpenReview: rog0J435OO.
- Abbott, V.; Zardini, G. (2025). *FlashAttention on a Napkin: A Diagrammatic Approach to Deep Learning IO-Awareness*. arXiv:2412.03317.

## Noten

1.  <span id="cite_note-arxiv_main-1">↑ <sup>[1.0](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_main_1-0)</sup> <sup>[1.1](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_main_1-1)</sup> <sup>[1.2](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_main_1-2)</sup> <sup>[1.3](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_main_1-3)</sup> <sup>[1.4](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_main_1-4)</sup> <sup>[1.5](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_main_1-5)</sup> Дао, Три. «FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning». *arXiv:2307.08691* \[cs.LG\], 17 июля 2023 г. <a href="https://arxiv.org/abs/2307.08691" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-huggingface_optim-2">↑ <sup>[2.0](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-huggingface_optim_2-0)</sup> <sup>[2.1](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-huggingface_optim_2-1)</sup> «Optimizing LLMs for Speed and Memory». *Hugging Face Documentation*. <a href="https://huggingface.co/docs/transformers/v4.42.0/en/llm_tutorial_optimization" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-tridao_blog_fa3-3">↑ <sup>[3.0](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-tridao_blog_fa3_3-0)</sup> <sup>[3.1](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-tridao_blog_fa3_3-1)</sup> Дао, Три. «FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision». *Tri Dao's Blog*. <a href="https://tridao.me/blog/2024/flash3/" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-e2e_analysis-4">[↑](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-e2e_analysis_4-0) «FlashAttention vs FlashAttention-2 - an Analysis». *E2E Networks Blog*. <a href="https://www.e2enetworks.com/blog/shades-of-attention-flashattention-vs-flashattention-2-a-comprehensive-study" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-openreview_fa2-5">↑ <sup>[5.0](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-openreview_fa2_5-0)</sup> <sup>[5.1](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-openreview_fa2_5-1)</sup> «FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning». *OpenReview*. <a href="https://openreview.net/forum?id=mZn2Xyh9Ec" class="external autonumber" rel="nofollow">[5]</a></span>
6.  <span id="cite_note-hazyresearch_blog-6">[↑](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-hazyresearch_blog_6-0) «FlashAttention-2». *Hazy Research, Stanford University*. <a href="https://hazyresearch.stanford.edu/blog/2023-07-17-flash2" class="external autonumber" rel="nofollow">[6]</a></span>
7.  <span id="cite_note-arxiv_pdf-7">↑ <sup>[7.0](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_pdf_7-0)</sup> <sup>[7.1](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_pdf_7-1)</sup> <sup>[7.2](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_pdf_7-2)</sup> Дао, Три. «FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning» (PDF). *arXiv:2307.08691*. <a href="https://arxiv.org/pdf/2307.08691.pdf" class="external autonumber" rel="nofollow">[7]</a></span>
8.  <span id="cite_note-raschka_blog-8">[↑](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-raschka_blog_8-0) Рашка, Себастьян. «Llama 2 and FlashAttention 2». *Ahead of AI Magazine*. <a href="https://magazine.sebastianraschka.com/p/research-highlights-in-three-sentences" class="external autonumber" rel="nofollow">[8]</a></span>
9.  <span id="cite_note-linkedin_younes-9">↑ <sup>[9.0](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-linkedin_younes_9-0)</sup> <sup>[9.1](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-linkedin_younes_9-1)</sup> Белькада, Юнес. «Faster and more memory efficient models with Flash Attention 2!». *LinkedIn*. <a href="https://www.linkedin.com/posts/younes-belkada-b1a903145_flashattention-llms-activity-7112061650106474496-1dzz" class="external autonumber" rel="nofollow">[9]</a></span>
10. <span id="cite_note-huggingface_gpu_infer-10">[↑](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-huggingface_gpu_infer_10-0) «GPU inference». *Hugging Face Documentation*. <a href="https://huggingface.co/docs/transformers/v4.39.0/perf_infer_gpu_one" class="external autonumber" rel="nofollow">[10]</a></span>
11. <span id="cite_note-arxiv_fa3-11">[↑](https://systems-analysis.info/int/FlashAttention-2_(NL)#cite_ref-arxiv_fa3_11-0) Дао, Три, и др. «FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision». *arXiv:2407.08608* \[cs.LG\], 11 июля 2024 г. <a href="https://arxiv.org/abs/2407.08608" class="external autonumber" rel="nofollow">[11]</a></span>
