{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/flashattention-3-fast-and-accurate-attention","title":"FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision","arxiv_id":"2407.08608","date":"2024-07-11","proceeding":null,"authors":["Jay Shah","Ganesh Bikshandi","Ying Zhang","Vijay Thakkar","Pradeep Ramani","Tri Dao"],"abstract":"Attention, as a core layer of the ubiquitous Transformer architecture, is the bottleneck for large language models and long-context applications. FlashAttention elaborated an approach to speed up attention on GPUs through minimizing memory reads/writes. However, it has yet to take advantage of new capabilities present in recent hardware, with FlashAttention-2 achieving only 35% utilization on the H100 GPU. We develop three main techniques to speed up attention on Hopper GPUs: exploiting asynchrony of the Tensor Cores and TMA to (1) overlap overall computation and data movement via warp-specialization and (2) interleave block-wise matmul and softmax operations, and (3) block quantization and incoherent processing that leverages hardware support for FP8 low-precision. We demonstrate that our method, FlashAttention-3, achieves speedup on H100 GPUs by 1.5-2.0$\\times$ with FP16 reaching up to 740 TFLOPs/s (75% utilization), and with FP8 reaching close to 1.2 PFLOPs/s. We validate that FP8 FlashAttention-3 achieves 2.6$\\times$ lower numerical error than a baseline FP8 attention.","url_abs":"https://arxiv.org/abs/2407.08608v2","url_pdf":"https://arxiv.org/pdf/2407.08608v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"flashattention-3-fast-and-accurate-attention","repo_url":"https://github.com/dao-ailab/flash-attention","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"paper_slug":"flashattention-3-fast-and-accurate-attention","repo_url":"https://github.com/sandai-org/magiattention","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":null,"task_name":"GPU"},{"task_slug":"quantization","task_name":"Quantization"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"speed","method_name":"SPEED"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2407.08608","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.08608"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/dao-ailab/flash-attention","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/sandai-org/magiattention","reach":null}],"summary":{"ran":13,"ran_fixture":1,"ran_honours":2,"unverified":2},"by_repo_kind":{"official":{"samples":18,"ran":16,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"5ec949977c334f87","entry":"apply_rotary_emb_torch","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/layers/rotary.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/layers/rotary.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"5ec949977c334f87"}},{"code_sha256_prefix":"4afe00a5853d633f","entry":"attention_pytorch","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/cute/benchmark_flash_attention_fp8.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/cute/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"4afe00a5853d633f"}},{"code_sha256_prefix":"942ce4d7b0714c0a","entry":"attention_pytorch","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"benchmarks/benchmark_flash_attention.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/benchmarks/benchmark_flash_attention.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"942ce4d7b0714c0a"}},{"code_sha256_prefix":"cc628b160e090ba1","entry":"convert_blockmask","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/flash_blocksparse_attn_interface.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/flash_blocksparse_attn_interface.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"cc628b160e090ba1"}},{"code_sha256_prefix":"f29cb637db3ec374","entry":"efficiency","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/cute/benchmark_flash_attention_fp8.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/cute/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"f29cb637db3ec374"}},{"code_sha256_prefix":"b5de75d142329f03","entry":"efficiency","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"benchmarks/benchmark_flash_attention.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/benchmarks/benchmark_flash_attention.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"b5de75d142329f03"}},{"code_sha256_prefix":"7541ce9614862680","entry":"flash_attn_qkvpacked_func","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/flash_attn_interface.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/flash_attn_interface.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"7541ce9614862680"}},{"code_sha256_prefix":"e73bdfbda28da341","entry":"flops","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/cute/benchmark_flash_attention_fp8.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/cute/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"e73bdfbda28da341"}},{"code_sha256_prefix":"8d5fb28ca2f46eb8","entry":"flops","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"benchmarks/benchmark_flash_attention.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/benchmarks/benchmark_flash_attention.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"8d5fb28ca2f46eb8"}},{"code_sha256_prefix":"1586b639a5abd0b0","entry":"init_to_zero","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/flash_attn_triton.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/flash_attn_triton.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"1586b639a5abd0b0"}},{"code_sha256_prefix":"19ad2ccd82e378c1","entry":"maybe_contiguous","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/flash_attn_interface.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/flash_attn_interface.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"19ad2ccd82e378c1"}},{"code_sha256_prefix":"a8cf6124094beaab","entry":"pad_input","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/bert_padding.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/bert_padding.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a8cf6124094beaab"}},{"code_sha256_prefix":"163292f43a3c861b","entry":"rotate_half","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/layers/rotary.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/layers/rotary.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"163292f43a3c861b"}},{"code_sha256_prefix":"a0595f1c95cacf06","entry":"round_multiple","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/flash_attn_interface.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/flash_attn_interface.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a0595f1c95cacf06"}},{"code_sha256_prefix":"d84093c20a0ed8fd","entry":"unpad_input","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/bert_padding.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/bert_padding.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"d84093c20a0ed8fd"}},{"code_sha256_prefix":"62394c842aafb022","entry":"unpad_input_for_concatenated_sequences","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"flash_attn/bert_padding.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/flash_attn/bert_padding.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"62394c842aafb022"}},{"code_sha256_prefix":"a9519adef33152bb","entry":"convert_to_cudnn_type","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"hopper/benchmark_flash_attention_fp8.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/hopper/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a9519adef33152bb"}},{"code_sha256_prefix":"58ebcd8dbefa010d","entry":"cudnn_spda_setup","repo":"dao-ailab/flash-attention","repo_kind":"official","path":"hopper/benchmark_flash_attention_fp8.py","file_url":"https://github.com/dao-ailab/flash-attention/blob/HEAD/hopper/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"58ebcd8dbefa010d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}