|
31 | 31 | <meta property="og:image" content="https://njudeepengine.github.io/2025/07/13/A4-attention-module/window.svg"> |
32 | 32 | <meta property="og:image" content="https://njudeepengine.github.io/2025/07/13/A4-attention-module/bottom-right.svg"> |
33 | 33 | <meta property="article:published_time" content="2025-07-13T03:01:59.000Z"> |
34 | | -<meta property="article:modified_time" content="2025-08-26T09:15:22.376Z"> |
| 34 | +<meta property="article:modified_time" content="2025-11-26T02:09:41.967Z"> |
35 | 35 | <meta property="article:author" content="DeepEngine"> |
36 | 36 | <meta property="article:tag" content="Attention"> |
37 | 37 | <meta property="article:tag" content="Mask"> |
@@ -192,7 +192,7 @@ <h1 class="post-title" itemprop="name headline"> |
192 | 192 | <i class="far fa-calendar-check"></i> |
193 | 193 | </span> |
194 | 194 | <span class="post-meta-item-text">更新于</span> |
195 | | - <time title="修改时间:2025-08-26 17:15:22" itemprop="dateModified" datetime="2025-08-26T17:15:22+08:00">2025-08-26</time> |
| 195 | + <time title="修改时间:2025-11-26 10:09:41" itemprop="dateModified" datetime="2025-11-26T10:09:41+08:00">2025-11-26</time> |
196 | 196 | </span> |
197 | 197 | <span class="post-meta-item"> |
198 | 198 | <span class="post-meta-item-icon"> |
@@ -290,7 +290,7 @@ <h1 id="Task-1-Offline-Sliding-Window-Attention"><a href="#Task-1-Offline-Slidin |
290 | 290 | <li><strong>AttnQKVLayout.SBHD</strong>:更适用于<strong>分布式环境(distributed environment)</strong> 的布局,满足 $\mathbf{Q},\mathbf{K},\mathbf{V} \in \mathbb{R}^{\text{seq_len_kv} \times \text{batch_size} \times \text{num_head} \times \text{head_dim}}$ ,记为 <code>sbhd</code>;</li> |
291 | 291 | <li><strong>AttnQKVLayout.THD</strong>:最通用的布局格式,也称为 <code>varlen layout</code>(变长布局),满足 $\mathbf{Q},\mathbf{K},\mathbf{V} \in \mathbb{R}^{\text{total_seq_len} \times \text{num_head} \times \text{head_dim}}$,在这种布局中,不存在显式的 <code>batch</code> 维度,所有长度不一的序列会沿着 <code>sequence</code> 维度拼接在一起,在这种情况下需要额外提供两个辅助输入,用于标识每条序列在拼接后的张量中的位置:<ul> |
292 | 292 | <li><code>cu_seqlens_q</code>;</li> |
293 | | -<li><code>cu_seqlens_kv</code>;<br>这两个张量都是 <code>int32</code> 类型,形状为 <code>[batch_size + 1]</code>,其中每一段 <code>[[cu_seqlens}[i], cu_seqlens[i+1]]</code> 表示第 i 个样本在 $\mathbf{Q}$ 或 $\mathbf{K}$、$\mathbf{V}$ 中的 起止区间(start-end),在 <code>varlen layout</code> 场景的掩码模式可参考下图。(更多示例请参考 Flash Attention 接口中的相关内容。)</li> |
| 293 | +<li><code>cu_seqlens_kv</code>;<br>这两个张量都是 <code>int32</code> 类型,形状为 <code>[batch_size + 1]</code>,其中每一段 <code>[[cu_seqlens[i], cu_seqlens[i+1])</code> 表示第 i 个样本在 $\mathbf{Q}$ 或 $\mathbf{K}$、$\mathbf{V}$ 中的 起止区间(start-end),在 <code>varlen layout</code> 场景的掩码模式可参考下图。(更多示例请参考 Flash Attention 接口中的相关内容。)</li> |
294 | 294 | </ul> |
295 | 295 | </li> |
296 | 296 | </ul> |
|
0 commit comments