{"id":97867,"date":"2026-08-30T14:50:49","date_gmt":"2026-08-30T06:50:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/97867.html"},"modified":"2026-08-30T14:50:49","modified_gmt":"2026-08-30T06:50:49","slug":"fia-flashattention-%e6%98%af-flashinfer-%e5%ba%93%e7%9a%84%e6%b3%a8%e6%84%8f%e5%8a%9b%e7%ae%97%e5%ad%90-tri-dao%e6%8f%90%e5%87%ba%e7%9a%84io-aware%e7%b2%be%e7%a1%ae%e6%b3%a8%e6%84%8f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/97867.html","title":{"rendered":"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e"},"content":{"rendered":"<h2>FIA \/ FlashAttention<\/h2>\n<p>FIA &#061; FlashInfer\u2011Attention&#xff0c;\u662f FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50&#xff1b;FlashAttention(FA) \u662fTri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002<\/p>\n<ul>\n<li>FlashAttention&#xff1a;\u504f\u5411\u8bad\u7ec3&#xff0c;\u517c\u987ePrefill\u63a8\u7406<\/li>\n<li>FIA(FlashInfer\u2011Attention)&#xff1a;\u4e13\u95e8\u9762\u5411LLM\u63a8\u7406&#xff08;Prefill&#043;Decode&#xff09;&#xff0c;\u5185\u90e8\u590d\u7528FA2\/FA3\u5206\u5757&#043;Online\u2011Softmax\u6838\u5fc3&#xff0c;\u4f46\u9488\u5bf9KV\u2011Cache\u3001\u5206\u9875\u5185\u5b58\u3001\u53d8\u957fbatch\u505a\u6574\u5957\u63a8\u7406\u4fa7\u6539\u9020\u3002<\/li>\n<\/ul>\n<h3>\u4e00\u3001FlashAttention&#xff08;FA\u20111\/2\/3&#xff09;\u6838\u5fc3\u539f\u7406<\/h3>\n<p>\u6807\u51c6Attention&#xff1a;<br \/>\n<span class=\"katex--display\"><span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\">Attention(Q,K,V)&#061;softmax(QKTd)V\\\\text{Attention}(Q,K,V)&#061;\\\\text{softmax}\\\\left(\\\\frac{QK^\\\\mathrm{T}}{\\\\sqrt d}\\\\right)V<\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 1em;vertical-align: -0.25em\"><\/span><span class=\"mord text\"><span class=\"mord\">Attention<\/span><\/span><span class=\"mopen\">(<\/span><span class=\"mord mathnormal\">Q<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.0715em\">K<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.2222em\">V<\/span><span class=\"mclose\">)<\/span><span class=\"mspace\" style=\"margin-right: 0.2778em\"><\/span><span class=\"mrel\">&#061;<\/span><span class=\"mspace\" style=\"margin-right: 0.2778em\"><\/span><\/span><span class=\"base\"><span class=\"strut\" style=\"height: 2.4684em;vertical-align: -0.95em\"><\/span><span class=\"mord text\"><span class=\"mord\">softmax<\/span><\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"minner\"><span class=\"mopen delimcenter\" style=\"top: 0em\"><span class=\"delimsizing size3\">(<\/span><\/span><span class=\"mord\"><span class=\"mopen nulldelimiter\"><\/span><span class=\"mfrac\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 1.5183em\"><span class=\"\" style=\"top: -2.1778em\"><span class=\"pstrut\" style=\"height: 3em\"><\/span><span class=\"mord\"><span class=\"mord sqrt\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.9322em\"><span class=\"svg-align\" style=\"top: -3em\"><span class=\"pstrut\" style=\"height: 3em\"><\/span><span class=\"mord mathnormal\" style=\"padding-left: 0.833em\">d<\/span><\/span><span class=\"\" style=\"top: -2.8922em\"><span class=\"pstrut\" style=\"height: 3em\"><\/span><span class=\"hide-tail\" style=\"min-width: 0.853em;height: 1.08em\"><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.1078em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"\" style=\"top: -3.23em\"><span class=\"pstrut\" style=\"height: 3em\"><\/span><span class=\"frac-line\" style=\"border-bottom-width: 0.04em\"><\/span><\/span><span class=\"\" style=\"top: -3.677em\"><span class=\"pstrut\" style=\"height: 3em\"><\/span><span class=\"mord\"><span class=\"mord mathnormal\">Q<\/span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right: 0.0715em\">K<\/span><span class=\"msupsub\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.8413em\"><span class=\"\" style=\"top: -3.063em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathrm mtight\">T<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.93em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><span class=\"mclose nulldelimiter\"><\/span><\/span><span class=\"mclose delimcenter\" style=\"top: 0em\"><span class=\"delimsizing size3\">)<\/span><\/span><\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.2222em\">V<\/span><\/span><\/span><\/span><\/span><\/span><br \/>\n\u76f4\u63a5\u7b97\u51fa\u5b8c\u6574 <span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\">N\u00d7NN\\\\times N<\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 0.7667em;vertical-align: -0.0833em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.109em\">N<\/span><span class=\"mspace\" style=\"margin-right: 0.2222em\"><\/span><span class=\"mbin\">\u00d7<\/span><span class=\"mspace\" style=\"margin-right: 0.2222em\"><\/span><\/span><span class=\"base\"><span class=\"strut\" style=\"height: 0.6833em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.109em\">N<\/span><\/span><\/span><\/span><\/span> score\u77e9\u9635\u5b58\u5165HBM&#xff0c;\u663e\u5b58 <span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\">O(N2)O(N^2)<\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 1.0641em;vertical-align: -0.25em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.0278em\">O<\/span><span class=\"mopen\">(<\/span><span class=\"mord\"><span class=\"mord mathnormal\" style=\"margin-right: 0.109em\">N<\/span><span class=\"msupsub\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.8141em\"><span class=\"\" style=\"top: -3.063em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">2<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mclose\">)<\/span><\/span><\/span><\/span><\/span>&#xff0c;\u5927\u91cfHBM\u8bfb\u5199&#xff0c;\u5185\u5b58\u5e26\u5bbd\u74f6\u9888\u3002<\/p>\n<p>FlashAttention\u4e09\u4ef6\u5957&#xff1a;<\/p>\n<li>Tiling\u5206\u5757&#xff1a;Q\/K\/V\u5207\u5c0f\u5757&#xff0c;\u5168\u90e8\u653e\u5728GPU\u7247\u4e0a\u9ad8\u901fSRAM&#xff08;Shared Memory&#xff09;\u8ba1\u7b97&#xff0c;\u4e0d\u5728HBM\u4fdd\u5b58\u5b8c\u6574(N\\\\times N)\u6ce8\u610f\u529b\u77e9\u9635\u3002<\/li>\n<li>Online\u2011Softmax&#xff08;\u5728\u7ebfSoftmax&#xff09;&#xff1a;\u5206\u5757\u6d41\u5f0f\u8fed\u4ee3\u7ef4\u62a4\u6bcf\u884c\u6700\u5927\u503c<span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\">mm<\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 0.4306em\"><\/span><span class=\"mord mathnormal\">m<\/span><\/span><\/span><\/span><\/span>\u4e0e\u5f52\u4e00\u5316\u5206\u6bcd<span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\">ll<\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 0.6944em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.0197em\">l<\/span><\/span><\/span><\/span><\/span>&#xff0c;\u52a8\u6001\u91cd\u7f29\u653e&#xff0c;\u5206\u5757\u4e5f\u80fd\u5f97\u5230\u548c\u5168\u5c40Softmax\u5b8c\u5168\u4e00\u81f4\u7ed3\u679c\u3002<\/li>\n<li>\u91cd\u8ba1\u7b97Recomputation&#xff1a;\u524d\u5411\u4e0d\u5b58\u4e2d\u95f4score&#xff0c;\u53cd\u5411\u91cd\u65b0\u8ba1\u7b97\u5c40\u90e8\u5757&#xff1b;\u589e\u52a0\u5c11\u91cfFLOPs&#xff0c;\u4f46\u6781\u5927\u51cf\u5c11HBM\u8bfb\u5199&#xff0c;\u6574\u4f53\u901f\u5ea6\u66f4\u5feb\u3002<\/li>\n<table>\n<tr>\u7248\u672c\u91cd\u70b9\u786c\u4ef6\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>FA\u20111<\/td>\n<td>\u57fa\u7840IO\u2011aware\u5206\u5757&#043;online softmax<\/td>\n<td>Ampere\u53ca\u4ee5\u4e0a<\/td>\n<td>\u8bad\u7ec3\u3001prefill<\/td>\n<\/tr>\n<tr>\n<td>FA\u20112<\/td>\n<td>\u66f4\u597d\u7ebf\u7a0b\u5757\u5212\u5206\u3001\u964d\u4f4e\u975eGEMM\u5f00\u9500<\/td>\n<td>A100\u6700\u4f18&#xff0c;\u652f\u6301Ada\/Hopper<\/td>\n<td>\u8bad\u7ec3\u4e3b\u529b&#xff0c;\u5e7f\u6cdb\u96c6\u6210<\/td>\n<\/tr>\n<tr>\n<td>FA\u20113<\/td>\n<td>Hopper\u4e13\u5c5e&#xff0c;WGMMA\u3001TMA\u5f02\u6b65\u6d41\u6c34\u7ebf\u3001FP8\u652f\u6301<\/td>\n<td>\u4ec5H100\/H200(Hopper)<\/td>\n<td>\u957f\u5e8f\u5217\u8bad\u7ec3\u3001prefill&#xff0c;FP8\u4f4e\u7cbe\u5ea6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u2705 FlashAttention\u662f\u7cbe\u786e\u6ce8\u610f\u529b&#xff0c;\u4e0d\u505a\u8fd1\u4f3c&#xff0c;\u6570\u5b66\u7b49\u4ef7\u6807\u51c6SDPA&#xff1b;\u539f\u751f\u5bf9Decode&#xff08;\u5355token\u751f\u6210&#xff09;\u652f\u6301\u5f31&#xff0c;KV\u2011cache\u9700\u8981\u4e0a\u5c42\u81ea\u5df1\u5904\u7406\u3002<\/p>\n<h3>\u4e8c\u3001FIA&#xff08;FlashInfer\u2011Attention&#xff09;<\/h3>\n<p>FlashInfer\u662f\u4f2f\u514b\u5229&#043;\u5b57\u8282\u63a8\u51fa\u7684\u63a8\u7406\u4e13\u7528kernel\u5e93&#xff0c;FIA\u5c31\u662f\u5b83\u7684\u6ce8\u610f\u529b\u7b97\u5b50\u96c6\u5408&#xff0c;\u5e95\u5c42\u590d\u7528FlashAttention\u5206\u5757\u7b97\u6cd5&#xff0c;\u4f46\u89e3\u51b3\u7ebf\u4e0a\u63a8\u7406\u771f\u5b9e\u75db\u70b9&#xff1a;\u5206\u9875KV\u2011Cache\u3001\u53d8\u957fbatch\u3001\u5927\u91cf\u5e76\u53d1Decode\u8bf7\u6c42\u3001\u8d1f\u8f7d\u4e0d\u5747\u8861\u3001MLA\/GQA\u3001\u7a00\u758fKV\u3001CUDAGraph\u9002\u914d\u3002<\/p>\n<h4>FIA\u5173\u952e\u80fd\u529b&#xff08;FA\u539f\u751f\u7f3a\u5c11&#xff09;<\/h4>\n<li>Prefill &#043; Decode\u4e24\u5957\u4e13\u7528kernel\n<ul>\n<li>Prefill&#xff1a;\u76f4\u63a5\u8c03\u7528FA\u20112\/FA\u20113\u6a21\u677f\u505aPrompt\u7f16\u7801&#xff1b;<\/li>\n<li>Flash\u2011Decoding&#xff1a;\u4e13\u95e8Decode\u7b97\u5b50&#xff0c;<span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\">QQ<\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 0.8778em;vertical-align: -0.1944em\"><\/span><span class=\"mord mathnormal\">Q<\/span><\/span><\/span><\/span><\/span>\u4ec51\u884c&#xff08;\u65b0\u751f\u6210token&#xff09;&#xff0c;\u5206\u5757\u904d\u5386\u5168\u90e8KV\u2011Cache&#xff0c;online\u2011softmax\u505a\u5f52\u7ea6&#xff0c;\u4e0d\u9700\u8981\u91cd\u5efa\u5b8c\u6574\u6ce8\u610f\u529b\u77e9\u9635\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u652f\u6301PageAttention\u5206\u9875KV\u2011Cache&#xff1a;KV\u4e0d\u5728\u8fde\u7eed\u663e\u5b58&#xff0c;\u6309page\u788e\u7247\u5316\u5b58\u50a8&#xff08;vLLM\/SGLang\u5e95\u5c42&#xff09;&#xff0c;FIA\u53ef\u4ee5\u76f4\u63a5\u5728\u975e\u8fde\u7eed\u5185\u5b58\u4e0a\u8dd1\u5206\u5757\u6ce8\u610f\u529b&#xff0c;\u4e0d\u9700\u8981\u62f7\u8d1d\u6210\u8fde\u7eedtensor\u3002<\/li>\n<li>Plan\u2011Run\u89e3\u8026\u8c03\u5ea6\n<ul>\n<li>Plan\u9636\u6bb5&#xff1a;\u9884\u5904\u7406\u53d8\u957f\u5e8f\u5217&#xff0c;\u505a\u8d1f\u8f7d\u5747\u8861\u3001block\u5206\u914d&#xff1b;<\/li>\n<li>Run\u9636\u6bb5&#xff1a;\u6279\u91cf\u6267\u884c&#xff1b;\u89e3\u51b3\u4e0d\u540c\u8bf7\u6c42\u957f\u5ea6\u4e0d\u4e00\u5bfc\u81f4GPU\u7ebf\u7a0b\u7a7a\u95f2\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u539f\u751f\u6df1\u5ea6\u9002\u914dGQA\/MQA\/MLA&#xff08;DeepSeek&#xff09;&#xff0c;Head\u2011Query\u878d\u5408&#xff0c;Cascade\u5206\u5c42KV\u7f13\u5b58&#xff0c;\u652f\u6301JIT\u81ea\u5b9a\u4e49\u6ce8\u610f\u529b\u53d8\u4f53\u3001FP8\/FP4\u91cf\u5316\u3001CUDAGraph\u6355\u83b7&#xff0c;\u652f\u6301AMD ROCm\u3002<\/li>\n<h3>\u4e09\u3001FlashAttention vs FIA(FlashInfer\u2011Attention)\u5bf9\u6bd4<\/h3>\n<table>\n<tr>\u5bf9\u6bd4\u9879FlashAttention(FA)FIA(FlashInfer\u2011Attention)<\/tr>\n<tbody>\n<tr>\n<td>\u5b9a\u4f4d<\/td>\n<td>\u8bad\u7ec3\u4f18\u5148&#xff0c;\u517c\u987eprefill\u63a8\u7406<\/td>\n<td>\u63a8\u7406\u670d\u52a1\u4e13\u7528&#xff1a;prefill &#043; decode\u5b8c\u6574\u94fe\u8def<\/td>\n<\/tr>\n<tr>\n<td>Decode\u652f\u6301<\/td>\n<td>\u5f88\u5dee&#xff0c;\u9700\u8981\u4e0a\u5c42\u81ea\u5df1\u5c01\u88c5KV\u2011Cache<\/td>\n<td>\u539f\u751fFlash\u2011Decoding\u9ad8\u6027\u80fddecode kernel<\/td>\n<\/tr>\n<tr>\n<td>KV\u2011Cache\u5185\u5b58\u5e03\u5c40<\/td>\n<td>\u53ea\u652f\u6301\u8fde\u7eedtensor<\/td>\n<td>\u652f\u6301\u5206\u9875&#xff08;\u975e\u8fde\u7eed&#xff09;KV Cache&#xff08;vLLM\/SGLang&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Batch\u5f62\u6001<\/td>\n<td>\u504f\u5411\u56fa\u5b9ashape\u8bad\u7ec3batch<\/td>\n<td>\u9ad8\u5ea6\u4f18\u5316\u53d8\u957f\u3001\u53c2\u5dee\u4e0d\u9f50\u63a8\u7406batch&#xff0c;\u8d1f\u8f7d\u5747\u8861\u8c03\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>MLA\/GQA<\/td>\n<td>\u57fa\u7840GQA\u652f\u6301<\/td>\n<td>\u6df1\u5ea6\u4f18\u5316MLA\u3001Head\u2011Query\u878d\u5408\u3001\u524d\u7f00\u5171\u4eab<\/td>\n<\/tr>\n<tr>\n<td>FP8<\/td>\n<td>FA3\u4ec5Hopper<\/td>\n<td>Hopper\/Ampere\u90fd\u6709FP8\u63a8\u7406kernel<\/td>\n<\/tr>\n<tr>\n<td>\u53cd\u5411\u4f20\u64ad<\/td>\n<td>\u5b8c\u6574\u3001\u9ad8\u6027\u80fd&#xff08;\u8bad\u7ec3\u5fc5\u9700&#xff09;<\/td>\n<td>\u51e0\u4e4e\u4e0d\u7528\u53cd\u5411&#xff0c;\u53ea\u505a\u524d\u5411\u63a8\u7406<\/td>\n<\/tr>\n<tr>\n<td>\u5178\u578b\u4f7f\u7528\u573a\u666f<\/td>\n<td>LLM\u9884\u8bad\u7ec3\u3001\u5fae\u8c03\u3001prefill<\/td>\n<td>\u7ebf\u4e0aLLM\u670d\u52a1\u3001\u9ad8\u5e76\u53d1\u63a8\u7406\u3001\u957f\u4e0a\u4e0b\u6587\u751f\u6210<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7b80\u5355\u7406\u89e3&#xff1a;<\/p>\n<ul>\n<li>\u505a\u8bad\u7ec3&#xff1a;\u4f18\u5148FlashAttention\u20112\/3<\/li>\n<li>\u505a\u7ebf\u4e0a\u63a8\u7406\u90e8\u7f72&#xff1a;\u4f18\u5148FlashInfer(FIA)&#xff0c;\u5185\u90e8\u4f1a\u590d\u7528FA\u7684prefill\u8ba1\u7b97\u903b\u8f91&#xff0c;\u4f46decode\u3001\u5206\u9875KV\u3001\u8c03\u5ea6\u5c42\u5168\u90e8\u589e\u5f3a\u3002<\/li>\n<\/ul>\n<h3>\u56db\u3001\u4ee3\u7801\u6781\u7b80\u793a\u4f8b<\/h3>\n<h4>FlashAttention<\/h4>\n<p><span class=\"token keyword\">import<\/span> flash_attn<br \/>\n<span class=\"token comment\"># \u8bad\u7ec3\/prefill&#xff0c;\u652f\u6301causal\u63a9\u7801<\/span><br \/>\nout <span class=\"token operator\">&#061;<\/span> flash_attn<span class=\"token punctuation\">.<\/span>flash_attn_qkvpacked_func<span class=\"token punctuation\">(<\/span>qkv<span class=\"token punctuation\">,<\/span> dropout_p<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0.0<\/span><span class=\"token punctuation\">,<\/span> causal<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h4>FlashInfer(FIA)\u63a8\u7406&#xff08;Decode\u9636\u6bb5&#xff0c;\u5206\u9875KV Cache&#xff09;<\/h4>\n<p><span class=\"token keyword\">import<\/span> flashinfer<br \/>\n<span class=\"token comment\"># plan\u9636\u6bb5\u505a\u8c03\u5ea6<\/span><br \/>\nplan <span class=\"token operator\">&#061;<\/span> flashinfer<span class=\"token punctuation\">.<\/span>BatchDecodePlan<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\nplan<span class=\"token punctuation\">.<\/span>plan<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token comment\"># run&#xff1a;\u6279\u91cf\u89e3\u7801&#xff0c;\u76f4\u63a5\u8bfb\u5206\u9875KV\u2011Cache<\/span><br \/>\nout <span class=\"token operator\">&#061;<\/span> flashinfer<span class=\"token punctuation\">.<\/span>batch_decode_with_paged_kv_cache<span class=\"token punctuation\">(<\/span>q<span class=\"token punctuation\">,<\/span> kv_cache<span class=\"token punctuation\">,<\/span> plan<span class=\"token punctuation\">)<\/span><\/p>\n<h3>\u4e94\u3001\u9762\u8bd5\u6838\u5fc3\u8003\u70b9\u603b\u7ed3<\/h3>\n<li>FlashAttention\u4e0d\u662f\u51cf\u5c11FLOPs&#xff0c;\u800c\u662f\u51cf\u5c11HBM\u8bfb\u5199&#xff1b;\u74f6\u9888\u662f\u5185\u5b58\u5e26\u5bbd\u800c\u975e\u7b97\u529b\u3002<\/li>\n<li>Online\u2011Softmax&#xff1a;\u5206\u5757\u573a\u666f\u4e0b\u8fed\u4ee3\u66f4\u65b0max\u4e0esum&#xff0c;\u5b9e\u73b0\u6d41\u5f0fsoftmax&#xff0c;\u662f\u5206\u5757\u8ba1\u7b97\u7684\u6570\u5b66\u57fa\u7840\u3002<\/li>\n<li>\u524d\u5411\u4e0d\u4fdd\u5b58score\u77e9\u9635&#xff0c;\u53cd\u5411\u901a\u8fc7**\u91cd\u8ba1\u7b97&#xff08;recompute&#xff09;**\u6362\u56de\u663e\u5b58&#xff0c;\u8ba1\u7b97\u6362IO\u3002<\/li>\n<li>FA\u64c5\u957f\u8bad\u7ec3\u548cprefill&#xff1b;\u539f\u751f\u4e0d\u64c5\u957fDecode\u5355token\u751f\u6210&#xff1b;\u63a8\u7406\u573a\u666fFIA(FlashInfer)\u505a\u6269\u5c55&#xff0c;\u5b9e\u73b0Flash\u2011Decoding &#043; PageKV\u2011Cache\u3002<\/li>\n<li>FA3\u4e3aHopper\u67b6\u6784\u505a\u786c\u4ef6\u6d41\u6c34\u7ebf\u4f18\u5316&#xff0c;WGMMA&#043;TMA\u91cd\u53e0\u8ba1\u7b97\u4e0e\u5185\u5b58\u62f7\u8d1d&#xff0c;FP8\u63a8\u7406\u52a0\u901f\u3002<\/li>\n<p>\u5982\u679c\u4f60\u9700\u8981&#xff0c;\u6211\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63a8\u5bfcOnline\u2011Softmax\u6570\u5b66\u516c\u5f0f&#xff0c;\u6216\u8005Flash\u2011Decoding\u7b97\u6cd5\u8be6\u89e3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FIA \/ FlashAttentionFIA  FlashInfer\u2011Attention&#xff0c;\u662f FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50&#xff1b;FlashAttention(FA) \u662fTri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002<br \/>\nFlashAttention&#xff1a;\u504f\u5411\u8bad\u7ec3&#xff0c;\u517c\u987ePrefill\u63a8\u7406FIA(FlashInfer\u2011Attention)&#xff1a;\u4e13\u95e8\u9762\u5411LLM\u63a8\u7406&#xff08;PrefillDecode&amp;#x<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,50,427],"topic":[],"class_list":["post-97867","post","type-post","status-publish","format-standard","hentry","category-server","tag-codingplan","tag-50","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/97867.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"FIA \/ FlashAttentionFIA FlashInfer\u2011Attention&#xff0c;\u662f FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50&#xff1b;FlashAttention(FA) \u662fTri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 FlashAttention&#xff1a;\u504f\u5411\u8bad\u7ec3&#xff0c;\u517c\u987ePrefill\u63a8\u7406FIA(FlashInfer\u2011Attention)&#xff1a;\u4e13\u95e8\u9762\u5411LLM\u63a8\u7406&#xff08;PrefillDecode&amp;#x\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/97867.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-30T06:50:49+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97867.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/97867.html\",\"name\":\"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-30T06:50:49+00:00\",\"dateModified\":\"2026-08-30T06:50:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/97867.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/97867.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97867.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/97867.html","og_locale":"zh_CN","og_type":"article","og_title":"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"FIA \/ FlashAttentionFIA FlashInfer\u2011Attention&#xff0c;\u662f FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50&#xff1b;FlashAttention(FA) \u662fTri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 FlashAttention&#xff1a;\u504f\u5411\u8bad\u7ec3&#xff0c;\u517c\u987ePrefill\u63a8\u7406FIA(FlashInfer\u2011Attention)&#xff1a;\u4e13\u95e8\u9762\u5411LLM\u63a8\u7406&#xff08;PrefillDecode&amp;#x","og_url":"https:\/\/www.wsisp.com\/helps\/97867.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-30T06:50:49+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/97867.html","url":"https:\/\/www.wsisp.com\/helps\/97867.html","name":"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-30T06:50:49+00:00","dateModified":"2026-08-30T06:50:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/97867.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/97867.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/97867.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"FIA \/ FlashAttention \u662f **FlashInfer \u5e93\u7684\u6ce8\u610f\u529b\u7b97\u5b50 Tri Dao\u63d0\u51fa\u7684IO\u2011Aware\u7cbe\u786e\u6ce8\u610f\u529b\u7b97\u6cd5\u5e93\u3002 \uff1e - **FlashAttention\uff1a\u504f\u5411\u8bad\u7ec3\uff0c\u517c\u987e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=97867"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97867\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=97867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=97867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=97867"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=97867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}