{"id":23720,"date":"2024-12-27T10:57:13","date_gmt":"2024-12-27T02:57:13","guid":{"rendered":"https:\/\/aif.amtbbs.org\/?p=23720"},"modified":"2024-12-27T10:57:13","modified_gmt":"2024-12-27T02:57:13","slug":"4%e6%af%94%e7%89%b9%e9%87%8f%e5%8c%96%e4%b8%89%e5%80%8d%e5%8a%a0%e9%80%9f%e4%b8%8d%e6%8e%89%e7%82%b9%ef%bc%81%e6%b8%85%e5%8d%8e%e5%8d%b3%e6%8f%92%e5%8d%b3%e7%94%a8%e7%9a%84sageattention%e8%bf%8e","status":"publish","type":"post","link":"https:\/\/aif.amtbbs.org\/index.php\/2024\/12\/27\/23720\/","title":{"rendered":"4\u6bd4\u7279\u91cf\u5316\u4e09\u500d\u52a0\u901f\u4e0d\u6389\u70b9\uff01\u6e05\u534e\u5373\u63d2\u5373\u7528\u7684SageAttention\u8fce\u6765\u5347\u7ea7"},"content":{"rendered":"<div><img data-dominant-color=\"8e8c92\" data-has-transparency=\"false\" style=\"--dominant-color: #8e8c92;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-23722\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/4f55799e-3cdc-4101-aab5-5a0ccb0b2f29-300x167-1.png\" width=\"300\" height=\"167\" alt=\"\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/4f55799e-3cdc-4101-aab5-5a0ccb0b2f29-300x167-1.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/4f55799e-3cdc-4101-aab5-5a0ccb0b2f29-300x167-1-150x84.png 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/div>\n<div><\/div>\n<div class=\"article-desc\">\u8fd1\u65e5\uff0c\u9648\u952e\u98de\u56e2\u961f\u8fdb\u4e00\u6b65\u63d0\u51fa\u4e86 4-Bit \u7684\u5373\u63d2\u5373\u7528 Attention\uff08SageAttention2\uff09\uff0c\u76f8\u8f83\u4e8e FlashAttention2 \u548c xformers \u5206\u522b\u5b9e\u73b0\u4e86 3 \u500d\u4ee5\u53ca 4.5 \u500d\u7684\u5373\u63d2\u5373\u7528\u7684\u63a8\u7406\u52a0\u901f\uff0c\u4e14\u5728\u89c6\u9891\u3001\u56fe\u50cf\u3001\u6587\u672c\u751f\u6210\u7b49\u5927\u6a21\u578b\u4e0a\u5747\u4fdd\u6301\u4e86\u7aef\u5230\u7aef\u7684\u7cbe\u5ea6\u8868\u73b0\u3002<\/div>\n<div id=\"postspictures\" class=\"article-content\">\n<div id=\"container\" class=\"container am-engine\" data-v-1d7a5742=\"\" data-element=\"root\">\n<p><strong>\u8bba\u6587\u5171\u540c\u7b2c\u4e00\u4f5c\u8005\u5f20\u91d1\u6d9b\u3001\u9ec4\u6d69\u5cf0\u5206\u522b\u6765\u81ea\u6e05\u534e\u5927\u5b66\u8ba1\u7b97\u673a\u7cfb\u548c\u4ea4\u53c9\u4fe1\u606f\u7814\u7a76\u9662\uff0c\u8bba\u6587\u901a\u8baf\u4f5c\u8005\u9648\u952e\u98de\u526f\u6559\u6388\u53ca\u5176\u4ed6\u5408\u4f5c\u4f5c\u8005\u5747\u6765\u81ea\u6e05\u534e\u5927\u5b66\u8ba1\u7b97\u673a\u7cfb\u3002<\/strong><\/p>\n<p>\u5927\u6a21\u578b\u4e2d\uff0c\u7ebf\u6027\u5c42\u7684\u4f4e\u6bd4\u7279\u91cf\u5316\u5df2\u7ecf\u9010\u6b65\u843d\u5730\u3002\u7136\u800c\uff0c\u5bf9\u4e8e\u6ce8\u610f\u529b\u6a21\u5757\uff0c\u76ee\u524d\u51e0\u4e4e\u5404\u4e2a\u6a21\u578b\u90fd\u8fd8\u5728\u7528\u9ad8\u7cbe\u5ea6\uff08\u4f8b\u5982 FP16 \u6216 FP32\uff09\u7684\u6ce8\u610f\u529b\u8fd0\u7b97\u8fdb\u884c\u8bad\u7ec3\u548c\u63a8\u7406\u3002\u5e76\u4e14\uff0c\u968f\u7740\u5927\u578b\u6a21\u578b\u9700\u8981\u5904\u7406\u7684\u5e8f\u5217\u957f\u5ea6\u4e0d\u65ad\u589e\u52a0\uff0cAttention\uff08\u6ce8\u610f\u529b\u8fd0\u7b97\uff09\u7684\u65f6\u95f4\u5f00\u9500\u9010\u6e10\u6210\u4e3a\u4e3b\u8981\u5f00\u9500\u3002<\/p>\n<p>\u6b64\u524d\uff0c\u6e05\u534e\u5927\u5b66\u9648\u952e\u98de\u56e2\u961f\u63d0\u51fa\u7684 8-Bit \u7684\u5373\u63d2\u5373\u7528 Attention\uff08SageAttention\uff09\uff0c\u5c06 Attention \u4e2d\u7684 QK^T \u91cf\u5316\u81f3 INT8\uff0c\u5c06 PV \u4fdd\u6301\u4e3a FP16 \u7cbe\u5ea6\u5e76\u4f7f\u7528 FP16 \u7cbe\u5ea6\u7684\u77e9\u9635\u4e58\u6cd5\u7d2f\u52a0\u5668\uff0c\u540c\u65f6\u63d0\u51fa Smooth K \u6280\u672f\u4fdd\u6301\u4e86\u91cf\u5316 Attention \u7684\u7cbe\u5ea6\uff0c\u5b9e\u73b0\u4e86 2 \u500d\u52a0\u901f\u4e8e FlashAttention2\uff0c\u4e14\u5728\u5404\u7c7b\u5927\u6a21\u578b\u4e0a\u5747\u4fdd\u6301\u4e86\u7aef\u5230\u7aef\u7684\u7cbe\u5ea6\u8868\u73b0\u3002<\/p>\n<p>\u76ee\u524d\uff0cSageAttention \u5df2\u7ecf\u88ab\u4e1a\u754c\u53ca\u793e\u533a\u5e7f\u6cdb\u5730\u4f7f\u7528\u4e8e\u5404\u79cd\u5f00\u6e90\u53ca\u5546\u4e1a\u5927\u6a21\u578b\u4e2d\uff0c\u6bd4\u5982 CogvideoX\u3001Mochi\u3001Flux\u3001Llama3\u3001Qwen \u7b49\u3002<\/p>\n<p>\u8fd1\u65e5\uff0c\u9648\u952e\u98de\u56e2\u961f\u8fdb\u4e00\u6b65\u63d0\u51fa\u4e86 4-Bit \u7684\u5373\u63d2\u5373\u7528 Attention\uff08SageAttention2\uff09\uff0c\u76f8\u8f83\u4e8e\u00a0FlashAttention2 \u548c xformers \u5206\u522b\u5b9e\u73b0\u4e86\u00a0<strong>3\u00a0<\/strong>\u500d\u4ee5\u53ca<strong>\u00a04.5<\/strong>\u00a0\u500d\u7684<strong>\u5373\u63d2\u5373\u7528<\/strong>\u7684\u63a8\u7406\u52a0\u901f\uff0c\u4e14\u5728\u89c6\u9891\u3001\u56fe\u50cf\u3001\u6587\u672c\u751f\u6210\u7b49\u5927\u6a21\u578b\u4e0a<strong>\u5747\u4fdd\u6301\u4e86\u7aef\u5230\u7aef\u7684\u7cbe\u5ea6\u8868\u73b0<\/strong>\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s7.51cto.com\/oss\/202412\/26\/298cd1c77ea8661f56068826c8058cce8d6bc9.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<ul data-id=\"ua73dd4b-eJU0D2j3\">\n<li data-id=\"ld70c578-Y5dkQhR4\">\u8bba\u6587\u6807\u9898\uff1aSageAttention2: Efficient Attention with Thorough Outlier Smoothing and Per-thread INT4 Quantization<\/li>\n<li data-id=\"ld70c578-Wj1cXffg\">\u8bba\u6587\u94fe\u63a5\uff1ahttps:\/\/arxiv.org\/abs\/2411.10958<\/li>\n<li data-id=\"ld70c578-JQ7Bn5ZL\">\u5f00\u6e90\u4ee3\u7801\uff1ahttps:\/\/github.com\/thu-ml\/SageAttention<\/li>\n<\/ul>\n<h4>\u5373\u63d2\u5373\u7528\u4e3e\u4f8b<\/h4>\n<p>SageAttention2 \u5b9e\u73b0\u4e86\u9ad8\u6548\u7684 Attention \u7b97\u5b50\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5373\u63d2\u5373\u7528\u7684\u63a8\u7406\u52a0\u901f\u3002\u8f93\u5165\u4efb\u610f Q, K, V \u77e9\u9635\uff0cSageAttention2 \u53ef\u4ee5\u5feb\u901f\u8fd4\u56de Attention Output (O)\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s9.51cto.com\/oss\/202412\/26\/b48728708b2ab0cd202479b890fe0197171b8b.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u5177\u4f53\u6765\u8bf4\uff0cSageAttention2 \u4f7f\u7528\u8d77\u6765\u5f88\u65b9\u4fbf\uff0c\u514b\u9686\u4ed3\u5e93\uff08git clone\u00a0<a href=\"https:\/\/github.com\/thu-ml\/SageAttention\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/thu-ml\/SageAttention<\/a>\uff09\u5e76\u6267\u884c python setup.py install \u540e\uff0c\u53ea\u9700\u4e00\u884c\u4ee3\u7801\u4fbf\u53ef\u4ee5\u5f97\u5230 Attention \u7684\u8f93\u51fa\uff0c\u53ef\u4ee5\u4f7f\u7528\u8be5\u63a5\u53e3\u65b9\u4fbf\u5730\u66ff\u6362\u4efb\u610f\u6a21\u578b\u4e2d\u7684 Attention \u51fd\u6570\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s6.51cto.com\/oss\/202412\/26\/e7f48fb218fe94de8c3369b84f4f2470686882.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u6548\u679c\u4e0a\uff0c\u4ee5\u5f00\u6e90\u89c6\u9891\u751f\u6210\u6a21\u578b CogvideoX-1.5-5B \u4e3a\u4f8b\uff0c\u4f7f\u7528 SageAttention2 \u53ef\u4ee5\u7aef\u5230\u7aef\u52a0\u901f\u00a0<strong>1.8\u00a0<\/strong>\u500d\uff0c\u4e14\u751f\u6210\u7684\u89c6\u9891\u65e0\u635f\uff1a<\/p>\n<p><img data-dominant-color=\"568694\" data-has-transparency=\"true\" style=\"--dominant-color: #568694;\" loading=\"lazy\" decoding=\"async\" class=\"has-transparency alignnone size-full wp-image-23723\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/49eb0ab2087ff506036446f105f2a58b88ece8.png\" width=\"733\" height=\"403\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/49eb0ab2087ff506036446f105f2a58b88ece8.png 733w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/49eb0ab2087ff506036446f105f2a58b88ece8-300x165.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/49eb0ab2087ff506036446f105f2a58b88ece8-150x82.png 150w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/p>\n<p>\u4f7f\u7528\u5168\u7cbe\u5ea6 Attention<\/p>\n<p><img data-dominant-color=\"578795\" data-has-transparency=\"true\" style=\"--dominant-color: #578795;\" loading=\"lazy\" decoding=\"async\" class=\"has-transparency alignnone size-full wp-image-23724\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/463b11486a77df8861c420545e3f3ed3a9c8e8.png\" width=\"722\" height=\"408\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/463b11486a77df8861c420545e3f3ed3a9c8e8.png 722w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/463b11486a77df8861c420545e3f3ed3a9c8e8-300x170.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/463b11486a77df8861c420545e3f3ed3a9c8e8-150x85.png 150w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/p>\n<p>\u4f7f\u7528 SageAttention2<\/p>\n<p>\u66f4\u91cd\u8981\u7684\u662f\uff0cSageAttention2 \u63d0\u4f9b\u4e86\u6bd4 SageAttention \u66f4\u5e7f\u6cdb\u7684\u786c\u4ef6\u652f\u6301\u3002\u9664\u4e86\u5728 RTX 4090 \u4e0a\u53ef\u4ee5 3 \u500d\u52a0\u901f\u4e8e FlashAttention \u5916\uff0c\u5728 L20\u3001L40\u3001L40S \u53ef\u4ee5\u5b9e\u73b0 2 \u500d\u7684\u52a0\u901f\uff0c\u5728 A100\u3001A800\u3001A6000 \u4e0a\u53ef\u4ee5\u5b9e\u73b0 1.45-1.6 \u500d\u7684\u52a0\u901f\uff08\u57fa\u4e8e SageAttention\uff09\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u7814\u7a76\u56e2\u961f\u5c06\u4ece\u524d\u8a00\u3001\u6311\u6218\u3001\u65b9\u6cd5\u4ee5\u53ca\u5b9e\u9a8c\u6548\u679c\u56db\u4e2a\u65b9\u9762\u4ecb\u7ecd SageAttention2\uff08\u603b\u4f53\u6d41\u7a0b\u56fe\u5982\u4e0b\u56fe\uff09\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s9.51cto.com\/oss\/202412\/26\/292219192dd1610e311337cdd8d8b9e8688b2c.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<h4>\u524d\u8a00<\/h4>\n<p>\u968f\u7740\u5927\u6a21\u578b\u9700\u8981\u5904\u7406\u7684\u5e8f\u5217\u957f\u5ea6\u8d8a\u6765\u8d8a\u957f\uff0cAttention \u7684\u901f\u5ea6\u4f18\u5316\u53d8\u5f97\u8d8a\u6765\u8d8a\u91cd\u8981\u3002\u4e0b\u56fe\u5c55\u793a\u4e86\u4e00\u4e2a\u6807\u51c6\u7684 Transformer \u6a21\u578b\u4e2d\u5404\u8fd0\u7b97\u7684\u65f6\u95f4\u5360\u6bd4\u968f\u5e8f\u5217\u957f\u5ea6\u7684\u53d8\u5316\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s5.51cto.com\/oss\/202412\/26\/9897ab176d8b0246f993896897b11fba4f454a.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u6307\u4ee3\u6ce8\u610f\u529b\u8fd0\u7b97\u4e2d\u7684\u77e9\u9635\uff0c\u6211\u4eec\u5148\u56de\u987e\u4e00\u4e0b\u6ce8\u610f\u529b\u7684\u8ba1\u7b97\u516c\u5f0f\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s2.51cto.com\/oss\/202412\/26\/65b0c1e56dd29b3642718932e26d368c22b384.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u5c3d\u7ba1 SageAttention \u63d0\u51fa\u5c06 Q\uff0cK \u91cf\u5316\u81f3 INT8\uff0c\u5c06 P\uff0cV \u4fdd\u6301 FP16 \u7cbe\u5ea6\u4e14\u91c7\u7528 FP16 \u7684\u77e9\u9635\u4e58\u6cd5\u7d2f\u52a0\u5668\u6765\u52a0\u5feb Attention \u7684\u901f\u5ea6\u3002\u7136\u800c\uff0c\u8fd9\u6837\u505a\u7684\u7f3a\u70b9\u662f\uff1a1\uff09INT8 \u7684\u77e9\u9635\u4e58\u6cd5\u53ea\u8fbe\u5230\u4e86\u4e00\u534a\u7684 INT4 \u77e9\u9635\u4e58\u6cd5\u7684\u901f\u5ea6\uff0c2\uff09\u4f7f\u7528 FP16 \u7684\u4e58\u6cd5\u7d2f\u52a0\u5668\u7684 FP16 \u7684\u77e9\u9635\u4e58\u6cd5\u7684\u52a0\u901f\u53ea\u5728 RTX4090 \u548c RTX3090 \u663e\u5361\u4e0a\u6709\u6548\u3002<\/p>\n<p>\u4e3a\u4e86\u514b\u670d\u4e0a\u8ff0\u7f3a\u70b9\uff0cSageAttention2 \u63d0\u51fa\u5c06 Q, K \u91cf\u5316\u81f3 INT4\uff0c\u5e76\u5c06 P, V \u91cf\u5316\u81f3 FP8 \u6765\u52a0\u901f Attention\u3002\u7136\u800c\uff0c\u8fd9\u6837\u505a\u7684\u6311\u6218\u662f\u5f88\u5927\u7684\u3002<\/p>\n<h4>4-Bit \u6ce8\u610f\u529b\u91cf\u5316\u6709\u4ec0\u4e48\u95ee\u9898\uff1f<\/h4>\n<p>\u7814\u7a76\u56e2\u961f\u53d1\u73b0\u76f4\u63a5\u5c06\u6ce8\u610f\u529b\u8fd0\u7b97\u4e2d\u7684 Q, K \u91cf\u5316\u4e3a INT4 \u540e\u5c06\u4f1a\u5bfc\u81f4\u5728\u51e0\u4e4e\u6240\u6709\u6a21\u578b\u548c\u4efb\u52a1\u4e0a\u90fd\u4f1a\u5f97\u5230\u6781\u5dee\u7684\u7ed3\u679c\uff0c\u4f8b\u5982\uff0c\u5728 CogVideoX \u6587\u751f\u89c6\u9891\u6a21\u578b\u4e2d\uff0c\u4f1a\u5f97\u5230\u5b8c\u5168\u6a21\u7cca\u7684\u89c6\u9891\uff1bLlama2-7B \u8fdb\u884c\u56db\u9009\u4e00\u9009\u62e9\u9898\u4efb\u52a1\u4e0a\u5f97\u5230 25% \u7684\u51c6\u786e\u7387\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s2.51cto.com\/oss\/202412\/26\/0713b3256b90f8569d96031fc03009b009467a.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u7ecf\u8fc7\u4ed4\u7ec6\u5206\u6790\u540e\uff0c\u7814\u7a76\u56e2\u961f\u53d1\u73b0\u4e3b\u8981\u662f\u4e24\u4e2a\u539f\u56e0\u5bfc\u81f4\u4e86\u91cf\u5316\u6ce8\u610f\u529b\u7684\u4e0d\u51c6\u786e\uff1a<\/p>\n<p>\uff081\uff09INT4 \u7684\u6570\u503c\u8303\u56f4\u76f8\u6bd4 INT8 \u975e\u5e38\u5c0f\uff0c\u5bfc\u81f4\u5176\u91cf\u5316\u8bef\u5dee\u5728 Q\uff0cK \u77e9\u9635\u4e2d\u51fa\u73b0\u4e00\u4e9b\u5f02\u5e38\u503c\u65f6\u4f1a\u53d8\u5f97\u5341\u5206\u660e\u663e\uff0c\u6070\u597d\u5927\u591a\u6a21\u578b\u90fd\u5728 Q, K \u4e2d\u8868\u73b0\u51fa\u6765\u4e86\u8f83\u5927\u7684\u901a\u9053\u7ef4\u5ea6\u7684\u5f02\u5e38\u503c\u3002\u8fd9\u6781\u5927\u524a\u51cf\u4e86 QK^\u22a4\u77e9\u9635\u4e58\u6cd5\u7684\u7cbe\u5ea6\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s8.51cto.com\/oss\/202412\/26\/99ef3b6030bbabce1905960f6e366f1f0e6a10.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\uff082\uff09\u7814\u7a76\u56e2\u961f\u53d1\u73b0 Nvidia \u7684\u663e\u5361\u4e0a\uff0cFP8 \u7684\u77e9\u9635\u4e58\u6cd5\u6307\u4ee4 (mma.f32.f8.f8.f32) \u7684\u4e58\u6cd5\u7d2f\u52a0\u5668\u5e76\u4e0d\u662f\u5b98\u65b9\u5ba3\u79f0\u7684 FP32 \u7cbe\u5ea6\uff0c\u800c\u662f\u53ea\u6709 FP22 \u7cbe\u5ea6\uff0c\u8fd9\u5bfc\u81f4\u4e86 PV \u77e9\u9635\u4e58\u6cd5\u51fa\u73b0\u8f83\u5927\u7684\u7d2f\u52a0\u8bef\u5dee\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s8.51cto.com\/oss\/202412\/26\/5904ee9652ac5bd21fe48365330156e1e83543.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<h4>\u6280\u672f\u65b9\u6848<\/h4>\n<p>\u4e3a\u4e86\u89e3\u51b3\u4e0a\u8ff0\u7684\u4e24\u4e2a\u6311\u6218\uff0c\u7814\u7a76\u56e2\u961f\u63d0\u51fa\u4e86\u5bf9\u5e94\u7684\u89e3\u51b3\u529e\u6cd5\u3002<\/p>\n<p>\uff081\uff09\u4fdd\u7559 SageAttention \u4e2d\u5bf9 K \u8fdb\u884c\u5e73\u6ed1\u5904\u7406\u7684\u540c\u65f6\uff0c\u63d0\u51fa\u5bf9 Q \u8fdb\u884c\u5e73\u6ed1\u5904\u7406\uff1aQ \u2013 mean (Q)\u3002\u5176\u4e2d mean (Q) \u662f\u6cbf\u7740\u901a\u9053\u7ef4\u5ea6\u7684\u5e73\u5747\u503c\u5411\u91cf\u3002\u5b8c\u6210\u8be5\u5e73\u6ed1\u64cd\u4f5c\u540e\u9700\u8981\u5728 Attention \u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u5c06 mean (Q) \u548c K^T \u7684\u5411\u91cf\u4e0e\u77e9\u9635\u4e58\u6cd5\u7684\u7ed3\u679c\u8865\u507f\u5230 S \u4e2d\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s6.51cto.com\/oss\/202412\/26\/e1405b563e09cb9e9865030c297d095e78e772.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u8fd9\u4f7f\u5f97\u76f8\u6bd4\u76f4\u63a5\u91cf\u5316 Q, K \u81f3 INT4 \u7684\u51c6\u786e\u5ea6\u6709\u8d28\u7684\u6539\u53d8\uff0c\u5982\u4e0b\u8868\u5c55\u793a\u4e86\u5bf9\u6bd4\u4e86\u8be5\u65b9\u6cd5\u548c\u76f4\u63a5\u91cf\u5316 Q, K \u81f3 INT4 \u5728 Cogvideo \u548c Llama3.1 \u4e0a\u7684\u7aef\u5230\u7aef\u8868\u73b0\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s4.51cto.com\/oss\/202412\/26\/e2f3111769db0139e887148334aaa45268a232.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u77e9\u9635 Q \u5e73\u6ed1\u524d\u540e\u7684\u6570\u636e\u5206\u5e03\u53ef\u89c6\u5316\u7684\u7ed3\u679c\u5982\u4e0b\uff0c\u53ef\u4ee5\u53d1\u73b0\u5e73\u6ed1\u540e\u7684 Q \u5bf9 INT4 \u6570\u636e\u8303\u56f4\u7684\u5229\u7528\u5ea6\u66f4\u9ad8\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s4.51cto.com\/oss\/202412\/26\/011678b4195074176459964c9c7b007f731573.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\uff082\uff09\u5bf9 Q, K \u8fdb\u884c Per-thread \u91cf\u5316\u3002\u5bf9\u4e8e\u77e9\u9635 Q, K\uff0cSageAttention2 \u91c7\u7528\u4e86\u6839\u636e mma \u6307\u4ee4\u5bf9\u77e9\u9635\u5185\u5b58\u6392\u5e03\u7684\u8981\u6c42\uff0c\u5bf9 Q\uff0cK \u4e2d\u7684 Token \u6309\u7167 GPU \u7ebf\u7a0b\u8fdb\u884c\u5206\u7ec4\uff0c\u4f7f\u91cf\u5316\u7c92\u5ea6\u6bd4 SageAttention \u4e2d\u7684 per-block \u7ec6\u5316 16 \u500d\uff0c\u6781\u5927\u63d0\u9ad8\u4e86 4Bit \u7684 QK^\u22a4\u4e58\u6cd5\u51c6\u786e\u5ea6\u7684\u540c\u65f6\u4e0d\u5f15\u5165\u4efb\u4f55\u989d\u5916\u5f00\u9500\u3002<\/p>\n<p>\u5177\u4f53\u6765\u8bf4\uff0c\u5728 SageAttention \u4e2d\uff0c\u6bcf\u4e2a Q \u7684\u5757\u5c06\u88ab\u5212\u5206\u4e3a c_w \u4e2a\u6bb5\uff0c\u7531 GPU \u6d41\u5904\u7406\u5668\uff08SM\uff09\u4e2d\u7684 c_w \u4e2a GPU warp \u5904\u7406\u3002\u7136\u540e\uff0c\u6bcf\u4e2a\u5305\u542b 32 \u4e2a\u7ebf\u7a0b\u7684 warp \u4f1a\u4f7f\u7528 NVIDIA \u7684 mma.m16n8k64 PTX \u6307\u4ee4\u6765\u6267\u884c QK^\u22a4\u8fd0\u7b97\u3002\u6839\u636e\u8fd9\u4e00\u6307\u4ee4\u7684\u5e03\u5c40\u8981\u6c42\uff0c\u7814\u7a76\u56e2\u961f\u53d1\u73b0\u4e00\u4e2a warp \u5185\u7684 Q [8\u00d7(n%8)] \u53ef\u4ee5\u5171\u7528\u4e00\u4e2a\u91cf\u5316\u7f29\u653e\u53c2\u6570\uff0c\u800c\u4e00\u4e2a warp \u5185\u7684 K [8\u00d7(n%8)] \u548c K [8\u00d7(n%8+1)] \u4e5f\u53ef\u4ee5\u5171\u7528\u4e00\u4e2a\u91cf\u5316\u7f29\u653e\u53c2\u6570\uff0c\u5176\u4e2d n \u662f token \u7d22\u5f15\u3002<\/p>\n<p>\u8fd9\u79cd\u91cf\u5316\u65b9\u6cd5\u66f4\u4e3a\u7ec6\u81f4\u4e14\u4e0d\u589e\u52a0\u989d\u5916\u5f00\u9500\u3002\u8fd9\u662f\u56e0\u4e3a\u5b83\u6839\u636e MMA \u6307\u4ee4\u7684\u5e03\u5c40\u5c06\u4e0d\u540c\u7684 GPU \u7ebf\u7a0b\u5206\u914d\u5230\u4e0d\u540c\u7684\u91cf\u5316 Token \u7ec4\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u53ea\u5bf9\u5e94\u4e00\u4e2a\u91cf\u5316\u7f29\u653e\u53c2\u6570\u8fdb\u884c\u53cd\u91cf\u5316\u3002\u800c\u975e Per-token \u91cf\u5316\u90a3\u6837\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u5bf9\u5e94\u591a\u4e2a\u91cf\u5316\u7f29\u653e\u53c2\u6570\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s2.51cto.com\/oss\/202412\/26\/5331d2426c76510a80389258c85053b417ea07.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u5982\u4e0b\u8868\u6240\u793a\uff0c\u53ef\u4ee5\u53d1\u73b0 per-thread \u91cf\u5316\u7684\u51c6\u786e\u5ea6\u6bd4 SageAttention \u4e2d\u91c7\u7528\u7684 per-block \u91cf\u5316\u9ad8\u5f97\u591a\uff0c\u51c6\u786e\u5ea6\u548c per-token \u91cf\u5316\u51e0\u4e4e\u6ca1\u6709\u5dee\u522b\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s2.51cto.com\/oss\/202412\/26\/6163d6976632ac9dea0129be1dcac53e047bf3.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\uff083\uff09\u5bf9 FP8 \u7684 PV \u77e9\u9635\u4e58\u6cd5\u91c7\u7528 FP32 \u7684\u5bc4\u5b58\u5668\u5c06\u6bcf\u6b21 FlashAttention \u5206\u5757\u7c92\u5ea6\u7684 PV \u7684 FP22 \u7684\u4e58\u6cd5\u7ed3\u679c\u7d2f\u52a0\u8d77\u6765\u3002\u8fd9\u79cd\u505a\u6cd5\u53ef\u4ee5\u6709\u6548\u5730\u907f\u514d FP22 \u7684\u4e58\u6cd5\u7d2f\u52a0\u5668\u6cbf\u7740\u5e8f\u5217\u957f\u5ea6\u7d2f\u79ef\u8fc7\u591a\u7684\u8bef\u5dee\uff0c\u5c06 FP22 \u7d2f\u52a0\u5668\u5e26\u6765\u7684\u8bef\u5dee\u63a7\u5236\u5728 FlashAttention \u5206\u5757\u7684\u7c92\u5ea6\u4e2d\uff0c\u63d0\u9ad8\u4e86 FP8 \u7684 PV \u4e58\u6cd5\u7684\u51c6\u786e\u5ea6\u3002<\/p>\n<p>\uff084\uff09\u9488\u5bf9 P \u548c V\uff0c\u7814\u7a76\u56e2\u961f\u5bf9\u6bd4\u4e86\u591a\u79cd\u91cf\u5316\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5bf9\u6bd4\u53d1\u73b0\u4f7f\u7528 E4M3 \u6570\u636e\u683c\u5f0f\u7684 FP8 \u7cbe\u5ea6\u6700\u51c6\u786e\uff0c\u57fa\u672c\u63a5\u8fd1\u4e86 FP16 \u7684\u51c6\u786e\u5ea6\u3002\u56e0\u6b64\u91c7\u7528\u5c06 P \u548c V \u91cf\u5316\u81f3 E4M3\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s4.51cto.com\/oss\/202412\/26\/8643d21424e42f181914730fb7cc40d9d0b377.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u4e0b\u56fe\u5c55\u793a\u4e86 SageAttention2 \u7684\u7b97\u6cd5\u6d41\u7a0b\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s4.51cto.com\/oss\/202412\/26\/d9b68ee94de7df8ec2665229014e0ab3492a3a.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>SageAttention2 \u5171\u5b9e\u73b0\u4e86\u4e24\u79cd Kernel\uff0c\u533a\u522b\u5728\u4e8e\u5bf9 Q, K \u8fdb\u884c INT4 \u91cf\u5316\u8fd8\u662f INT8 \u91cf\u5316\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s4.51cto.com\/oss\/202412\/26\/380705a30cf791dc07267492654fd516d5632d.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u6b64\u5916\uff0cSageAttention2 \u8fd8\u63d0\u51fa\u4e00\u79cd\u53ef\u9009\u7684\u5bf9\u77e9\u9635 V \u8fdb\u884c\u5e73\u6ed1\u5904\u7406\u7684\u6280\u672f\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8 PV \u77e9\u9635\u4e58\u6cd5\u7684\u51c6\u786e\u5ea6\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5f53\u67d0\u4e9b\u6a21\u578b\u4e2d V \u77e9\u9635\u5177\u6709\u901a\u9053\u7ef4\u5ea6\u7684\u504f\u79fb\u65f6\uff0c\u53ef\u4ee5\u5c06 V \u51cf\u53bb\u5176\u901a\u9053\u7ef4\u5ea6\u7684\u5e73\u5747\u503c mean (V) \u6765\u53bb\u9664\u504f\u79fb\uff0c\u4e4b\u540e\u8fdb\u884c\u6b63\u5e38\u7684\u91cf\u5316 Attention \u8fd0\u7b97\u3002\u53ea\u9700\u8981\u5bf9\u6700\u7ec8 Attention \u7684 Output \u52a0\u4e0a mean (V) \u5373\u53ef\u4fdd\u6301\u8ba1\u7b97\u7684\u6b63\u786e\u6027\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s6.51cto.com\/oss\/202412\/26\/c7e9dd484aac8c62b78865b05a89d2bb16ddeb.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s4.51cto.com\/oss\/202412\/26\/8831fcb60b78428eb2b058ee2386b9b20a25c6.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u8fd9\u79cd\u505a\u6cd5\u53ef\u4ee5\u63d0\u5347\u51c6\u786e\u5ea6\u7684\u539f\u56e0\u5982\u4e0b\u56fe\u6240\u793a\u3002\u5728 FP22 \u7684\u8868\u793a\u8303\u56f4\u5185\uff0c\u6570\u503c\u8d8a\u5927\uff0c\u76f8\u6bd4 FP32 \u7684\u8bef\u5dee\u8d8a\u5927\u3002\u800c P \u7684\u8303\u56f4\u662f 0\uff5e1 \u4e4b\u95f4\uff0c\u90a3\u4e48\u5f53 V \u77e9\u9635\u7684\u5217\u6709\u8f83\u5927\u7684\u6570\u503c\u504f\u79fb\u65f6\uff0cPV \u7684 FP22 \u7d2f\u52a0\u5668\u7684\u7cbe\u5ea6\u5c31\u8d8a\u5dee\uff0c\u901a\u8fc7\u5e73\u6ed1 V \u53bb\u9664\u504f\u79fb\u540e\uff0c\u5c31\u53ef\u4ee5\u52a0\u5f3a PV \u77e9\u9635\u4e58\u6cd5\u7684\u51c6\u786e\u5ea6\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s6.51cto.com\/oss\/202412\/26\/578531a1132f79b055827545ae1df37f9a70b7.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<h4>\u5b9e\u9a8c\u6548\u679c<\/h4>\n<p>SageAttention \u5b9e\u73b0\u4e86\u5e95\u5c42\u7684 GPU CUDA Kernel\uff0c\u5728\u7b97\u5b50\u901f\u5ea6\u4ee5\u53ca\u5404\u4e2a\u6a21\u578b\u7aef\u5230\u7aef\u51c6\u786e\u5ea6\u4e0a\u90fd\u6709\u5341\u5206\u4e0d\u9519\u7684\u8868\u73b0\u3002<\/p>\n<p>\u5177\u4f53\u6765\u8bf4\uff0c\u7b97\u5b50\u901f\u5ea6\u76f8\u6bd4\u4e8e FlashAttention2 \u548c xformers \u6709\u5927\u7ea6 3 \u500d\u4ee5\u53ca 4.5 \u500d\u7684\u52a0\u901f\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s9.51cto.com\/oss\/202412\/26\/015810c04022a87edf8844f7630d94ad185e9a.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s8.51cto.com\/oss\/202412\/26\/54929450679bd8cf592946c22bf37e7592814a.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u7b97\u5b50\u7684\u51c6\u786e\u5ea6\u65b9\u9762\u4e5f\u662f\u6bd4\u5bf9 Q, K \u8fdb\u884c SmoothQuant \u548c Hadamard \u53d8\u6362\u8981\u66f4\u52a0\u51c6\u786e\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s8.51cto.com\/oss\/202412\/26\/f86481a1494ec0a0cd3647a3c104fcecbcfc6d.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u5404\u6a21\u578b\u5728\u771f\u5b9e\u573a\u666f\u7684\u7aef\u5230\u7aef\u7cbe\u5ea6\u8868\u73b0\u4e2d\uff0c\u5728\u89c6\u9891\u3001\u56fe\u50cf\u3001\u6587\u672c\u751f\u6210\u7b49\u5927\u6a21\u578b\u4e0a\u5747\u4fdd\u6301\u4e86\u7aef\u5230\u7aef\u7684\u7cbe\u5ea6\u8868\u73b0\uff1a<\/p>\n<p>\u4e0b\u56fe\u662f\u5728 HunyuanVideo \u4e2d\u7684\u53ef\u89c6\u5316\u5b9e\u4f8b\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s7.51cto.com\/oss\/202412\/26\/485cc3020e5dd8ecf83991f9bf7b7b0c9d883f.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u4e0b\u56fe\u662f\u5728 Cogvideo \u4e2d\u7684\u53ef\u89c6\u5316\u5b9e\u4f8b\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s2.51cto.com\/oss\/202412\/26\/a250ef526fde2ec432f88098fe3a01a5759431.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p>\u4e0b\u8868\u5c55\u793a\u4e86\u5404\u4e2a\u8bed\u8a00\u3001\u89c6\u9891\u3001\u56fe\u50cf\u751f\u6210\u6a21\u578b\u4e2d SageAttention2 \u7684\u7aef\u5230\u7aef\u7cbe\u5ea6\u8868\u73b0\uff1a<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s7.51cto.com\/oss\/202412\/26\/543a688599dfb370fe4033dcf50c390064d34e.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s9.51cto.com\/oss\/202412\/26\/68f832c540c19912a55605a43973b363d43652.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<p><strong>\u7aef\u5230\u7aef\u7684\u901f\u5ea6\u8868\u73b0\u4e0a<\/strong>\uff0cSageAttention2 \u4e24\u4e2a Kernel \u7684\u5b9e\u73b0\u5747\u53ef\u4ee5\u6709\u6548\u5730\u5bf9\u957f\u5e8f\u5217\u6a21\u578b\u8fdb\u884c\u52a0\u901f\uff0c\u6bd4\u5982\u53ef\u4ee5\u7aef\u5230\u7aef\u00a0<strong>1.8<\/strong>\u00a0\u500d\u52a0\u901f CogVideoX1.5-5B\uff0c\u5176\u4ed6\u6a21\u578b\u4e0a\u4e5f\u5747\u6709\u00a0<strong>1.6<\/strong>\u00a0\u5230<strong>\u00a01.8<\/strong>\u00a0\u500d\u7684\u63d0\u901f\u3002<\/p>\n<p><img decoding=\"async\" title=\"\u56fe\u7247\" src=\"https:\/\/s3.51cto.com\/oss\/202412\/26\/7871c874645868a524e713f5abcb8a9705b486.webp\" alt=\"\u56fe\u7247\" data-type=\"inline\" \/><\/p>\n<\/div>\n<\/div>\n<div class=\"article-bottom\">\u6587\u7ae0\u6765\u81ea\uff1a51CTO<\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_23720\" class=\"pvc_stats total_only  \" data-element-id=\"23720\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd1\u65e5\uff0c\u9648\u952e\u98de\u56e2\u961f\u8fdb\u4e00\u6b65\u63d0\u51fa\u4e86 4-Bit \u7684\u5373\u63d2\u5373\u7528 Attention\uff08SageAttention2\uff09\uff0c\u76f8\u8f83 [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_23720\" class=\"pvc_stats total_only  \" data-element-id=\"23720\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":56,"featured_media":23722,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,17,20,80],"tags":[124,887,888],"class_list":["post-23720","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-23","category-17","category-20","category-80","tag-ai","tag-887","tag-888"],"_links":{"self":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/23720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/comments?post=23720"}],"version-history":[{"count":1,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/23720\/revisions"}],"predecessor-version":[{"id":23725,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/23720\/revisions\/23725"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media\/23722"}],"wp:attachment":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media?parent=23720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/categories?post=23720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/tags?post=23720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}