<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>核心算法 on Inference Cookbook</title>
    <link>https://inference.lei6393.com/flashattention/02-core-algorithm/</link>
    <description>Recent content in 核心算法 on Inference Cookbook</description>
    <generator>Hugo</generator>
    <language>zh</language>
    <copyright>Copyright (c) 2024-2025 Inference Cookbook</copyright>
    <atom:link href="https://inference.lei6393.com/flashattention/02-core-algorithm/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Online Softmax 算法详解</title>
      <link>https://inference.lei6393.com/flashattention/02-core-algorithm/01-online-softmax/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://inference.lei6393.com/flashattention/02-core-algorithm/01-online-softmax/</guid>
      <description>&lt;h2 id=&#34;目录&#34;&gt;目录&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#1-%e4%bb%8e%e7%90%86%e8%ae%ba%e5%88%b0%e5%ae%9e%e7%8e%b0---%e5%9b%9e%e9%a1%be%e4%b8%8e%e5%8a%a8%e6%9c%ba&#34;&gt;1. 从理论到实现 - 回顾与动机&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#2-%e4%b8%89%e7%a7%8d-softmax-%e5%ae%9e%e7%8e%b0%e7%ad%96%e7%95%a5%e5%af%b9%e6%af%94&#34;&gt;2. 三种 Softmax 实现策略对比&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#3-flash-attention-%e7%9a%84%e5%8d%95%e9%81%8d-online-softmax&#34;&gt;3. Flash Attention 的单遍 Online Softmax&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#4-%e6%ba%90%e7%a0%81%e8%a7%a3%e6%9e%90---hoppersoftmaxh&#34;&gt;4. 源码解析 - hopper/softmax.h&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#5-exp2f-%e4%bc%98%e5%8c%96---%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e7%94%a8-expf&#34;&gt;5. exp2f 优化 - 为什么不用 expf&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#6-fp8-max_offset-%e6%8a%80%e5%b7%a7&#34;&gt;6. FP8 Max_offset 技巧&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#7-%e6%95%b0%e5%80%bc%e7%a8%b3%e5%ae%9a%e6%80%a7%e5%88%86%e6%9e%90&#34;&gt;7. 数值稳定性分析&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#8-lse-%e7%9a%84%e8%ae%a1%e7%ae%97%e4%b8%8e%e7%94%a8%e9%80%94&#34;&gt;8. LSE 的计算与用途&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;1-从理论到实现---回顾与动机&#34;&gt;&#xA;    &lt;span id=&#34;toc-h-1-从理论到实现---回顾与动机&#34;&gt;1. 从理论到实现 - 回顾与动机&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;p&gt;在 &lt;a href=&#34;https://inference.lei6393.com/flashattention/01-theory/03-flash-attention-theory/&#34;&gt;Flash Attention 核心理论&lt;/a&gt; 中，我们推导了 Online Softmax 的递推公式。处理到第 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;j&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 个 K/V 块后，状态 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo stretchy=&#34;false&#34;&gt;(&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mrow&gt;&lt;mo stretchy=&#34;false&#34;&gt;(&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo stretchy=&#34;false&#34;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;mo separator=&#34;true&#34;&gt;,&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;mrow&gt;&lt;mo stretchy=&#34;false&#34;&gt;(&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo stretchy=&#34;false&#34;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;mo separator=&#34;true&#34;&gt;,&lt;/mo&gt;&lt;msup&gt;&lt;mi&gt;O&lt;/mi&gt;&lt;mrow&gt;&lt;mo stretchy=&#34;false&#34;&gt;(&lt;/mo&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mo stretchy=&#34;false&#34;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/msup&gt;&lt;mo stretchy=&#34;false&#34;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;(m^{(j)}, l^{(j)}, O^{(j)})&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 通过以下递推关系更新：&lt;/p&gt;</description>
    </item>
    <item>
      <title>分块策略与调度</title>
      <link>https://inference.lei6393.com/flashattention/02-core-algorithm/02-tiling-strategy/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://inference.lei6393.com/flashattention/02-core-algorithm/02-tiling-strategy/</guid>
      <description>&lt;h2 id=&#34;目录&#34;&gt;目录&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#1-%e5%88%86%e5%9d%97%e7%ad%96%e7%95%a5%e6%a6%82%e8%bf%b0&#34;&gt;1. 分块策略概述&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#2-%e5%8a%a8%e6%80%81%e5%88%86%e5%9d%97%e5%a4%a7%e5%b0%8f%e9%80%89%e6%8b%a9---tile_sizeh&#34;&gt;2. 动态分块大小选择 - tile_size.h&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#3-%e5%9d%97%e7%ba%a7%e9%81%ae%e8%94%bd%e8%b7%b3%e8%bf%87%e4%bc%98%e5%8c%96---blockh&#34;&gt;3. 块级遮蔽跳过优化 - block.h&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#4-tile-%e8%b0%83%e5%ba%a6%e5%99%a8---tile_schedulerhpp&#34;&gt;4. Tile 调度器 - tile_scheduler.hpp&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#5-split-k-%e7%ad%96%e7%95%a5%e4%b8%8e-num_splits-%e5%90%af%e5%8f%91%e5%bc%8f&#34;&gt;5. Split-K 策略与 num_splits 启发式&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#6-packgqa-%e4%b8%8e%e5%88%86%e5%9d%97%e7%9a%84%e4%ba%a4%e4%ba%92&#34;&gt;6. PackGQA 与分块的交互&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;1-分块策略概述&#34;&gt;&#xA;    &lt;span id=&#34;toc-h-1-分块策略概述&#34;&gt;1. 分块策略概述&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;p&gt;在 &lt;a href=&#34;https://inference.lei6393.com/flashattention/01-theory/03-flash-attention-theory/&#34;&gt;Flash Attention 核心理论&lt;/a&gt; 中，我们推导了分块计算的基本原理：将 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;Q&lt;/mi&gt;&lt;mo separator=&#34;true&#34;&gt;,&lt;/mo&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;mo separator=&#34;true&#34;&gt;,&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;Q, K, V&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 矩阵按行分为大小为 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;B_r \times d&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 和 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;/msub&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;B_c \times d&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 的块，使中间计算 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;Q&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;msubsup&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;mi&gt;j&lt;/mi&gt;&lt;mi&gt;T&lt;/mi&gt;&lt;/msubsup&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;S_{ij} = Q_i K_j^T&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 可以驻留在 GPU 的 SRAM 中。&lt;/p&gt;</description>
    </item>
    <item>
      <title>前向传播算法详解</title>
      <link>https://inference.lei6393.com/flashattention/02-core-algorithm/03-forward-pass/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://inference.lei6393.com/flashattention/02-core-algorithm/03-forward-pass/</guid>
      <description>&lt;h2 id=&#34;目录&#34;&gt;目录&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#1-%e5%89%8d%e5%90%91%e4%bc%a0%e6%92%ad%e7%9a%84%e6%95%b4%e4%bd%93%e6%9e%b6%e6%9e%84&#34;&gt;1. 前向传播的整体架构&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#2-warp-specialization---producer-consumer-%e6%a8%a1%e5%bc%8f&#34;&gt;2. Warp Specialization - Producer-Consumer 模式&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#3-producer-%e6%89%a7%e8%a1%8c%e8%b7%af%e5%be%84---%e6%95%b0%e6%8d%ae%e5%8a%a0%e8%bd%bd&#34;&gt;3. Producer 执行路径 - 数据加载&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#4-consumer-%e6%89%a7%e8%a1%8c%e8%b7%af%e5%be%84---%e8%ae%a1%e7%ae%97%e4%b8%bb%e5%be%aa%e7%8e%af&#34;&gt;4. Consumer 执行路径 - 计算主循环&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#5-pipeline-%e5%a4%9a%e9%98%b6%e6%ae%b5%e6%b5%81%e6%b0%b4%e7%ba%bf&#34;&gt;5. Pipeline 多阶段流水线&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#6-intrawgoverlap---%e7%bb%84%e5%86%85%e9%87%8d%e5%8f%a0%e4%bc%98%e5%8c%96&#34;&gt;6. IntraWGOverlap - 组内重叠优化&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#7-epilogue---%e8%be%93%e5%87%ba%e4%b8%8e-lse-%e5%86%99%e5%9b%9e&#34;&gt;7. Epilogue - 输出与 LSE 写回&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#8-%e5%ae%8c%e6%95%b4%e6%89%a7%e8%a1%8c%e6%97%b6%e5%ba%8f&#34;&gt;8. 完整执行时序&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;1-前向传播的整体架构&#34;&gt;&#xA;    &lt;span id=&#34;toc-h-1-前向传播的整体架构&#34;&gt;1. 前向传播的整体架构&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;h3 id=&#34;11-内核类结构&#34;&gt;&#xA;    &lt;span id=&#34;toc-h-11-内核类结构&#34;&gt;1.1 内核类结构&lt;/span&gt;&lt;/h3&gt;&#xA;&lt;p&gt;Flash Attention 的 SM90 前向内核由三个可替换的组件构成：&lt;/p&gt;&#xA;&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;&lt;div class=&#34;expressive-code&#34;&gt;&#xD;&#xA;  &lt;figure class=&#34;frame not-content&#34;&gt;&#xD;&#xA;  &lt;figcaption class=&#34;header&#34;&gt;&#xD;&#xA;    &lt;span class=&#34;title&#34;&gt;&lt;/span&gt;&#xD;&#xA;  &lt;/figcaption&gt;&#xD;&#xA;  &lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// hopper/flash_fwd_kernel_sm90.h:27-28&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;CollectiveMainloop_&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;CollectiveEpilogue_&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;TileScheduler_&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;FlashAttnFwdSm90&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xD;&#xA;  &lt;/figure&gt;&#xD;&#xA;&lt;/div&gt;&#xD;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;组件&lt;/th&gt;&#xA;          &lt;th&gt;类名&lt;/th&gt;&#xA;          &lt;th&gt;职责&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Mainloop&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;CollectiveMainloopFwdSm90&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Q/K/V 加载、QK GEMM、Softmax、PV GEMM&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Epilogue&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;CollectiveEpilogueFwd&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;输出 O 和 LSE 写回 HBM&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Scheduler&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;TileScheduler&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;分配 tile 到 SM&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;这种模板组合设计允许通过编译期参数选择不同的实现变体（FP8、Paged KV、Varlen 等），而无需运行时分支。&lt;/p&gt;</description>
    </item>
    <item>
      <title>反向传播算法详解</title>
      <link>https://inference.lei6393.com/flashattention/02-core-algorithm/04-backward-pass/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://inference.lei6393.com/flashattention/02-core-algorithm/04-backward-pass/</guid>
      <description>&lt;h2 id=&#34;目录&#34;&gt;目录&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#1-%e5%8f%8d%e5%90%91%e4%bc%a0%e6%92%ad%e7%9a%84%e6%8c%91%e6%88%98%e4%b8%8e%e6%a0%b8%e5%bf%83%e7%ad%96%e7%95%a5&#34;&gt;1. 反向传播的挑战与核心策略&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#2-%e6%a2%af%e5%ba%a6%e6%8e%a8%e5%af%bc---%e4%bb%8e%e6%95%b0%e5%ad%a6%e5%88%b0%e4%bb%a3%e7%a0%81&#34;&gt;2. 梯度推导 - 从数学到代码&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#3-n-outer-q-inner-%e5%be%aa%e7%8e%af%e7%bb%93%e6%9e%84&#34;&gt;3. N-outer Q-inner 循环结构&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#4-flashattnbwdsm90-%e5%86%85%e6%a0%b8%e6%9e%b6%e6%9e%84&#34;&gt;4. FlashAttnBwdSm90 内核架构&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#5-consumer-%e4%b8%bb%e5%be%aa%e7%8e%af---bwd_step-%e9%80%90%e6%ad%a5%e8%a7%a3%e6%9e%90&#34;&gt;5. Consumer 主循环 - bwd_step 逐步解析&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#6-dq-%e7%9a%84%e5%ad%98%e5%82%a8%e7%ad%96%e7%95%a5---%e5%8e%9f%e5%ad%90%e7%b4%af%e5%8a%a0%e4%b8%8e-tma&#34;&gt;6. dQ 的存储策略 - 原子累加与 TMA&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#7-%e4%b8%8e%e5%89%8d%e5%90%91%e4%bc%a0%e6%92%ad%e7%9a%84%e6%9e%b6%e6%9e%84%e5%af%b9%e6%af%94&#34;&gt;7. 与前向传播的架构对比&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;#8-%e9%ab%98%e7%ba%a7%e4%bc%98%e5%8c%96%e6%8a%80%e5%b7%a7&#34;&gt;8. 高级优化技巧&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;1-反向传播的挑战与核心策略&#34;&gt;&#xA;    &lt;span id=&#34;toc-h-1-反向传播的挑战与核心策略&#34;&gt;1. 反向传播的挑战与核心策略&lt;/span&gt;&lt;/h2&gt;&#xA;&lt;h3 id=&#34;11-为什么反向传播比前向更难&#34;&gt;&#xA;    &lt;span id=&#34;toc-h-11-为什么反向传播比前向更难&#34;&gt;1.1 为什么反向传播比前向更难&lt;/span&gt;&lt;/h3&gt;&#xA;&lt;p&gt;在标准 Attention 的反向传播中，我们需要计算损失函数 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;L&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;L&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 对 &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;Q&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;Q&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;, &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;K&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;, &lt;span class=&#34;katex&#34;&gt;&lt;math xmlns=&#34;http://www.w3.org/1998/Math/MathML&#34;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&#34;application/x-tex&#34;&gt;V&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt; 三个输入的梯度。回顾前向公式：&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
