Transformer長文自己注意 — 読者別詳細レポート
- 調べたこと
- 長文の自己注意に必要な計算・メモリを何が制約し、各改善はどの条件で成立するか。
- 調査を区切った理由
- 充足による終了。0周目の地図作成に続く実調査2周で、全6論点に保存本文の行番号と短い引用を付け、参考文献・被引用・著者追跡を実施した。飽和・4周上限・アクセス制限による終了ではない。
- 調査の論点
- 根拠あり知見の集まる用語・人物・媒体はどこか。
- 根拠あり密な自己注意の計算・メモリと、学習・prefill・decode・KVキャッシュはどう違うか。
- 根拠ありexact attentionのIO最適化は何を減らし、何を減らさず、どのハードウェア条件で成立するか。
- 根拠ありsparse/local/global attentionはどの接続・窓幅条件で長文を扱い、何を失うか。
- 根拠ありlinear/低ランク近似は何を仮定し、どの精度・表現力の制約を持つか。
- 根拠あり日本語の実践知と原著の実験を照合すると、実装・KVキャッシュ・長文評価をどう選び、どこまで一般化できるか。
Lv1(前提知識が無い人向け)
要旨
自己注意は文章中の位置どうしを比べるため、全位置を一度に処理する基本形では文章が長くなるほど計算が二乗で増えます。原文 1
O(n2 · d)
訳系列長n、表現幅dに対する自己注意の層あたり計算量。
arxiv-1706.03762-attention.txt:269-269 元のページを開く前後を読む(263〜275行)
263 Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations264 for different layer types. n is the sequence length, d is the representation dimension, k is the kernel265 size of convolutions and r the size of the neighborhood in restricted self-attention.267 Layer Type Complexity per Layer Sequential Maximum Path Length268 Operations269 Self-Attention O(n2 · d) O(1) O(1)270 Recurrent O(n · d2 ) O(n) O(n)271 Convolutional O(k · n · d2 ) O(1) O(logk (n))272 Self-Attention (restricted) O(r · n · d) O(1) O(n/r)FlashAttentionは同じ注意計算を保ちながら、GPUの大きなメモリへの中間行列の書き出しを避けます。原文 2
materialize the matrices S and P to HBM
訳SとPの行列をHBMに実体化する。
arxiv-2205.14135-flashattention.txt:214-214 元のページを開く前後を読む(208〜220行)
208 Given input sequences Q, K, V ∈ R 𝑁 ×𝑑 where 𝑁 is the sequence length and 𝑑 is the head dimension, we want209 to compute the attention output O ∈ R 𝑁 ×𝑑 :211 S = QK> ∈ R 𝑁 ×𝑁 , P = softmax(S) ∈ R 𝑁 ×𝑁 , O = PV ∈ R 𝑁 ×𝑑 ,213 where softmax is applied row-wise.214 Standard attention implementations materialize the matrices S and P to HBM, which takes 𝑂 (𝑁 2 ) memory.215 Often 𝑁 𝑑 (e.g., for GPT2, 𝑁 = 1024 and 𝑑 = 64). We describe the standard attention implementation216 in Algorithm 0. As some or most of the operations are memory-bound (e.g., softmax), the large number of217 memory accesses translates to slow wall-clock time.218 This problem is exacerbated by other elementwise operations applied to the attention matrix, such as219 masking applied to S or dropout applied to P. As a result, there have been many attempts to fuse several220 elementwise operations, such as fusing masking with softmax [77].we split the inputs Q, K, V into blocks
訳Q、K、Vをブロックに分ける。
arxiv-2205.14135-flashattention.txt:247-247 元のページを開く前後を読む(241〜253行)
242 3.1 An Efficient Attention Algorithm With Tiling and Recomputation243 Given the inputs Q, K, V ∈ R 𝑁 ×𝑑 in HBM, we aim to compute the attention output O ∈ R 𝑁 ×𝑑 and write it to244 HBM. Our goal is to reduce the amount of HBM accesses (to sub-quadratic in 𝑁).245 We apply two established techniques (tiling, recomputation) to overcome the technical challenge of246 computing exact attention in sub-quadratic HBM accesses. We describe this in Algorithm 1. The main idea247 is that we split the inputs Q, K, V into blocks, load them from slow HBM to fast SRAM, then compute the248 attention output with respect to those blocks. By scaling the output of each block by the right normalization249 factor before adding them up, we get the correct result at the end.250 Tiling. We compute attention by blocks. Softmax couples columns of K, so we decompose the large251 softmax with scaling [51, 60, 66]. For numerical stability, the softmax of vector 𝑥 ∈ R 𝐵 is computed as:252 ∑︁ 𝑓 (𝑥)253 𝑓 (𝑥) := 𝑒 𝑥1 −𝑚( 𝑥) 𝑒 𝑥𝐵 −𝑚( 𝑥) ,比較相手を窓内に絞る方法や小さな特徴に置き換える方法は計算を減らしますが、窓幅や近似精度を選ぶ必要があります。原文 4
Given a fixed window size w
訳固定された窓幅wの下で。
arxiv-2004.05150-longformer.txt:179-179 元のページを開く前後を読む(173〜185行)
173 attention in Transformers, and pre-training it for rounding each token. Using multiple stacked lay-174 long document natural language tasks. In particu- ers of such windowed attention results in a large175 lar, ETC (Ainslie et al., 2020) uses a similar local receptive field, where top layers have access to all176 + global attention instead of full self-attention to input locations and have the capacity to build repre-177 scale Transformers to long documents. Different sentations that incorporate information across the178 from Longformer, ETC uses relative position em- entire input, similar to CNNs (Wu et al., 2019).179 2 Given a fixed window size w, each token attends180 SQuAD contexts typically fit within the 512 limit, and181 MRQA is constructed by dropping long-document examples. to 12 w tokens on each side (Fig. 2b). The com-182 3183 All were published on arXiv after Longformer. putation complexity of this pattern is O(n × w),185 3complexity of this pattern is O(n × w)
訳このパターンの計算量はO(nw)。
arxiv-2004.05150-longformer.txt:183-183 元のページを開く前後を読む(177〜189行)
177 scale Transformers to long documents. Different sentations that incorporate information across the178 from Longformer, ETC uses relative position em- entire input, similar to CNNs (Wu et al., 2019).179 2 Given a fixed window size w, each token attends180 SQuAD contexts typically fit within the 512 limit, and181 MRQA is constructed by dropping long-document examples. to 12 w tokens on each side (Fig. 2b). The com-182 3183 All were published on arXiv after Longformer. putation complexity of this pattern is O(n × w),185 3186 which scales linearly with input sequence length n. simpler than existing task specific approaches that187 In a transformer with ` layers, the receptive field use complex architecture to combine information188 size at the top layer is ` × w (assuming w is fixed across smaller input chunks.189 for all layers). Depending on the application, itcomplexity O(Lrd)
訳計算時間はO(Lrd)。
arxiv-2009.14794-performer.txt:174-174 元のページを開く前後を読む(168〜180行)
168 b = diag(Q0 ((K0 )> 1L )).169 D (4)171 Here Att172 \ ↔ stands for the approximate attention and brackets indicate the order of computations. It is173 easy to see that such a mechanism is characterized by space complexity O(Lr + Ld + rd) and time174 complexity O(Lrd) as opposed to O(L2 + Ld) and O(L2 d) of the regular attention (see also Fig. 1).179 Figure 1: Approximation of the regular attention mechanism AV (before D−1 -renormalization) via (random)180 feature maps. Dashed-blocks indicate order of computation with corresponding time complexities attached.queries/keys are upper-bounded by R > 0.
訳query/keyのノルムがRで上から抑えられる。
arxiv-2009.14794-performer.txt:394-394 元のページを開く前後を読む(388〜400行)
388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 trig398 lowing holds for the attention approximation mechanism leveraging estimators SM399 d with ORFs:400 kAb − Ak∞ ≤ with any constant probability, where Ab approximates the attention matrix A.長い文章を入力できても必要な情報を使えるとは限らず、Liuらの実験では情報を置く位置によって成績が変わりました。原文 2
the middle of long contexts
訳長い文脈の中央。
liu-2024-lost-middle.txt:35-35 元のページを開く前後を読む(29〜41行)
29 put contexts. In particular, we observe that increases quadratically in sequence length. As30 performance is often highest when relevant in- a result, Transformer language models were of-31 formation occurs at the beginning or end of the ten trained with relatively small context windows32 input context, and significantly degrades when (between 512 and 2048 tokens). Recent improve-33 models must access relevant information in34 ments in hardware (e.g., faster GPUs with more35 the middle of long contexts, even for explicitly36 long-context models. Our analysis provides a memory) and algorithms (Dai et al., 2019; Dao37 better understanding of how language mod- et al., 2022; Poli et al., 2023; Rubin and Berant,38 els use their input context and provides new 2023, inter alia) have resulted in language models39 evaluation protocols for future long-context with larger context windows (e.g., 4096, 32K, and40 language models. even 100K tokens), but it remains unclear how41 these extended-context language models makeswering and key-value retrieval.
訳多文書質問応答とkey-value検索。
liu-2024-lost-middle.txt:23-23 元のページを開く前後を読む(17〜29行)
17 ity to take long contexts as input, relatively18 little is known about how well they use nal information (relevant documents from a search19 longer context. We analyze the performance engine, database query results, etc.; Petroni et al.,20 of language models on two tasks that re- 2020; Ram et al., 2023; Shi et al., 2023; Mallen21 quire identifying relevant information in their et al., 2023; Schick et al., 2023, inter alia).22 input contexts: multi-document question an- Handling these use-cases requires language23 swering and key-value retrieval. We find that models to successfully operate over long se-24 performance can degrade significantly when25 quences. Existing language models are generally26 changing the position of relevant information,27 indicating that current language models do not implemented with Transformers (Vaswani et al.,28 robustly make use of information in long in- 2017), which require memory and compute that29 put contexts. In particular, we observe that increases quadratically in sequence length. As用語
- prefillとdecode
入力をまとめて読む段階に対し、decodeでは次の言葉を1つずつ生成します。原文 1
出力トークンを 1 つずつ自己回帰的に生成します。
nvidia-2023-inference-ja.md:41-41元のページを開く前後を読む(35〜47行)
35 ### プレフィル フェーズまたは入力の処理37 プレフィル フェーズでは、LLM は入力トークンを処理して中間状態 (キーと値) を計算します。これは、「最初の」新しいトークンを生成するために使用されます。新しいトークンはそれぞれ、以前のすべてのトークンに依存しますが、これは、入力の全範囲がわかっていることにより、大まかに言えば高度に並列化された行列対行列の演算となります。これは、GPU 使用率が事実上飽和状態になります。39 ### デコード フェーズまたは出力の生成41 デコード フェーズでは、LLM は停止基準が満たされるまで、出力トークンを 1 つずつ自己回帰的に生成します。各順次出力トークンは、以前のすべてのイテレーションの出力状態 (キーと値) を知っている必要があります。これは、プリフィル フェーズと比較して GPU の計算能力を十分に活用しない行列ベクトル演算のようなものです。データ (重み、キー、値、アクティベーション) がメモリから GPU に転送される速度が、レイテンシを支配します。実際の計算速度ではありません。言い換えれば、これはメモリに依存した操作です。43 この投稿で紹介されている推論の課題と対応するソリューションの多くは、効率的なアテンション モジュール、キーと値の効果的な管理など、このデコード フェーズの最適化に関係しています。45 異なる LLM は異なるトークナイザーを使用する可能性があるため、それらの間で出力トークンを比較することは簡単ではない可能性があります。推論スループットを比較する場合、2 つの LLM の 1 秒あたりのトークン出力が同等であっても、異なるトークナイザーを使用している場合は同等ではない可能性があります。これは、対応するトークンが異なる数の文字を表す可能性があるためです。47 ### バッチ処理
- KVキャッシュ
過去のキーと値を保存する領域で、保存するトークン数に比例して容量が増えます。原文 2
prev_K : t e n s o r with sha pe [ b , h , m, k ]
訳保存済みキーの形状は[b,h,m,k]。
arxiv-1911.02150-mqa.txt:172-172元のページを開く前後を読む(166〜178行)
166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]176 P_v: a t e n s o r with sha pe [ h , d , v ]177 P_o : a t e n s o r with sha pe [ h , d , v ]178 Retur ns :
2 * (num_layers) * (num_heads * dim_head) * precision_in_bytes
nvidia-2023-inference-ja.md:73-73元のページを開く前後を読む(67〜79行)
67 モデルの重み: メモリはモデル パラメーターによって占有されます。例として、70 億個のパラメーター (たとえば、[Llama 2 7B](https://huggingface.co/meta-llama/Llama-2-7b/blob/main/params.json))を、16 ビット精度 (FP16 または BF16) でロードすると、メモリにおよそ 7B * sizeof(FP16) ~= 14 GB が必要になります。69 KV キャッシュ: メモリは、冗長な計算を避けるためにセルフアテンション テンソルのキャッシュによって占有されます。71 バッチ処理では、バッチ内の各リクエストの KV キャッシュを個別に割り当てる必要があり、メモリ フットプリントが大きくなる可能性があります。以下の式は、今日の最も一般的な LLM アーキテクチャに適用できる KV キャッシュのサイズを示しています。73 トークンごとの KV キャッシュのサイズ (バイト単位) = 2 * (num_layers) * (num_heads * dim_head) * precision_in_bytes75 最初の係数 2 は、K 行列と V 行列を表します。通常、(num_heads * dim_head) の値は、Transformer の hidden_size (またはモデルの次元 d_model) と同じです。これらのモデル属性は、通常、モデル カードまたは関連する構成ファイルで見つけることができます。77 このメモリ サイズは、入力のバッチ全体にわたって、入力シーケンス内の各トークンに必要です。半精度を仮定すると、KV キャッシュの合計サイズは次の式で求められます。79 KV キャッシュの合計サイズ (バイト単位) = (batch_size) * (sequence_length) * 2 * (num_layers) * (hidden_size) * sizeof(FP16)
- 疎な注意
全位置を比べず近くの位置などを選ぶ仕組みで、Longformerは固定幅の窓を使います。原文 2
Given a fixed window size w
訳固定された窓幅wの下で。
arxiv-2004.05150-longformer.txt:179-179元のページを開く前後を読む(173〜185行)
173 attention in Transformers, and pre-training it for rounding each token. Using multiple stacked lay-174 long document natural language tasks. In particu- ers of such windowed attention results in a large175 lar, ETC (Ainslie et al., 2020) uses a similar local receptive field, where top layers have access to all176 + global attention instead of full self-attention to input locations and have the capacity to build repre-177 scale Transformers to long documents. Different sentations that incorporate information across the178 from Longformer, ETC uses relative position em- entire input, similar to CNNs (Wu et al., 2019).179 2 Given a fixed window size w, each token attends180 SQuAD contexts typically fit within the 512 limit, and181 MRQA is constructed by dropping long-document examples. to 12 w tokens on each side (Fig. 2b). The com-182 3183 All were published on arXiv after Longformer. putation complexity of this pattern is O(n × w),185 3
complexity of this pattern is O(n × w)
訳このパターンの計算量はO(nw)。
arxiv-2004.05150-longformer.txt:183-183元のページを開く前後を読む(177〜189行)
177 scale Transformers to long documents. Different sentations that incorporate information across the178 from Longformer, ETC uses relative position em- entire input, similar to CNNs (Wu et al., 2019).179 2 Given a fixed window size w, each token attends180 SQuAD contexts typically fit within the 512 limit, and181 MRQA is constructed by dropping long-document examples. to 12 w tokens on each side (Fig. 2b). The com-182 3183 All were published on arXiv after Longformer. putation complexity of this pattern is O(n × w),185 3186 which scales linearly with input sequence length n. simpler than existing task specific approaches that187 In a transformer with ` layers, the receptive field use complex architecture to combine information188 size at the top layer is ` × w (assuming w is fixed across smaller input chunks.189 for all layers). Depending on the application, it
- 近似
Performerは注意の計算を特徴数rを使う計算へ置き換え、Linformerは射影する次元kを使います。原文 2
complexity O(Lrd)
訳計算時間はO(Lrd)。
arxiv-2009.14794-performer.txt:174-174元のページを開く前後を読む(168〜180行)
168 b = diag(Q0 ((K0 )> 1L )).169 D (4)171 Here Att172 \ ↔ stands for the approximate attention and brackets indicate the order of computations. It is173 easy to see that such a mechanism is characterized by space complexity O(Lr + Ld + rd) and time174 complexity O(Lrd) as opposed to O(L2 + Ld) and O(L2 d) of the regular attention (see also Fig. 1).179 Figure 1: Approximation of the regular attention mechanism AV (before D−1 -renormalization) via (random)180 feature maps. Dashed-blocks indicate order of computation with corresponding time complexities attached.
operations only require O(nk) time and space complexity.
訳必要な時間・空間はO(nk)。
arxiv-2006.04768-linformer.txt:313-313元のページを開く前後を読む(307〜319行)
307 = softmax √ · Fi V WiV , (7)308 dk | {z }309 | {z } k×d310 P̄ :n×k312 Finally, we compute context embeddings for each headi using P̄ · (Fi V WiV ). Note the above313 operations only require O(nk) time and space complexity. Thus, if we can choose a very small314 projected dimension k, such that k n, then we can significantly reduce the memory and space315 consumption. The following theorem states that, when k = O(d/2 ) (independent of n), one can316 approximate P · V WiV using linear self-attention (7) with error.317 Theorem 2. (Linear self-attention) For any Qi , Ki , Vi ∈ Rn×d and WiQ , WiK , WiV ∈ Rd×d , if318 k = min{Θ(9d log(d)/2 ), 5Θ(log(n)/2 )}, then√ there exists matrices Ei , Fi ∈ R319 n×k
論点ごとの解説
知見の集まる用語・人物・媒体はどこか。
研究論文に加え、推論を研究開発する釜堀圭祐の日本語記事からPagedAttention原著へのリンクをたどれます。原文 2
専門は機械学習システムで、LLMなどの推論を効率化する技術を研究・開発しています。
kamahori-2025-serving.md:20-20 元のページを開く前後を読む(14〜26行)
14 [llm](https://zenn.dev/topics/llm)16 [推論システム](https://zenn.dev/topics/%E6%8E%A8%E8%AB%96%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0)18 [tech](https://zenn.dev/tech-or-idea)20 ワシントン大学/Kotoba Technologiesの[釜堀](https://kamahori.org/)です。専門は機械学習システムで、LLMなどの推論を効率化する技術を研究・開発しています。22 現代のLLMは莫大な計算・メモリを要するため、LLMを使ったサービスを提供する際には推論の効率性が非常に重要です。この分野はここ数年活発に研究されていて、[vLLM](https://github.com/vllm-project/vllm)や[SGLang](https://github.com/sgl-project/sglang)など非常に高性能なOSSも出てきています。LLMのservingは、コンピュータサイエンスの知見を総動員させて最適化されている奥深い世界ですが、一方で中身を理解するには多くの前提知識が必要です。24 そこでこの記事ではTransformerモデルを中心に、LLMのserving system(多数のクライアントにLLM推論を提供するシステム)でどのようなテクニックが使われているのかについて体系的に解説していきます。26 構成としては、LLM servingで最も重要な概念である「バッチ推論」と「KVキャッシュマネジメント」について、現代のserving systemの基礎となっている技術を紹介します。さらに、「実装の工夫」「アルゴリズムの工夫」「モデルアーキテクチャの工夫」「分散処理」という4つの軸で、より細かく様々な技術について見ていきます。面白そうなところだけでもつまみ食いしていただければと思います。
vLLMの元論文で提案された[PagedAttention]
kamahori-2025-serving.md:130-130 元のページを開く前後を読む(124〜136行)
125 で、最大コンテクスト長は4096のため、本当に必要とするトークン数によらず、1リクエストあたり512KB x 4096 = 2GBものメモリが必要です。これは例えば80GBメモリを持つH100であっても、30リクエストほどしか同時に処理できない計算になります[2][3]。より最近のモデルではコンテクスト長が数十万以上になり、この実装は非現実的です。127 ###128 3.1. PagedAttention130 この問題を改善したのが、vLLMの元論文で提案された[PagedAttention](https://arxiv.org/abs/2309.06180)です。これは古典的なOSにおける[ページング](https://ja.wikipedia.org/wiki/%E3%83%9A%E3%83%BC%E3%82%B8%E3%83%B3%E3%82%B0%E6%96%B9%E5%BC%8F)に着想を得て、KVキャッシュを仮想アドレス空間と物理アドレス空間に分ける手法です。132 [https://arxiv.org/pdf/2309.06180](https://arxiv.org/pdf/2309.06180)134 上図中央にある物理 KV ブロックはあらかじめ固定サイズに分割されたバッファです。この例では、リクエストAが3個の、リクエストBが2個のブロックを必要としています。各リクエストには論理ブロックとして連続しているように見えていますが、実際にはバラバラの領域に保存されています。たとえばリクエストAは物理ブロックの1、7、3を、Bは5、2を使っています。実際にメモリアクセスが発生した際は、仮想アドレスから物理アドレスへ変換されます。136 リクエストが終了した際は、そのリクエストが保有していた物理ブロックが解放され、他のリクエストが使うことができるようになります。そのためメモリの[フラグメンテーション](https://ja.wikipedia.org/wiki/%E3%83%95%E3%83%A9%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3)が発生せず、バッチサイズを最大まで増やして推論効率を上げることができます。
密な自己注意の計算・メモリと、学習・prefill・decode・KVキャッシュはどう違うか。
文章を一度に扱う注意行列の二乗の大きさと、過去を保存するKVキャッシュの線形の大きさは別です。原文 2
materialize the matrices S and P to HBM
訳SとPの行列をHBMに実体化する。
arxiv-2205.14135-flashattention.txt:214-214 元のページを開く前後を読む(208〜220行)
208 Given input sequences Q, K, V ∈ R 𝑁 ×𝑑 where 𝑁 is the sequence length and 𝑑 is the head dimension, we want209 to compute the attention output O ∈ R 𝑁 ×𝑑 :211 S = QK> ∈ R 𝑁 ×𝑁 , P = softmax(S) ∈ R 𝑁 ×𝑁 , O = PV ∈ R 𝑁 ×𝑑 ,213 where softmax is applied row-wise.214 Standard attention implementations materialize the matrices S and P to HBM, which takes 𝑂 (𝑁 2 ) memory.215 Often 𝑁 𝑑 (e.g., for GPT2, 𝑁 = 1024 and 𝑑 = 64). We describe the standard attention implementation216 in Algorithm 0. As some or most of the operations are memory-bound (e.g., softmax), the large number of217 memory accesses translates to slow wall-clock time.218 This problem is exacerbated by other elementwise operations applied to the attention matrix, such as219 masking applied to S or dropout applied to P. As a result, there have been many attempts to fuse several220 elementwise operations, such as fusing masking with softmax [77].prev_K : t e n s o r with sha pe [ b , h , m, k ]
訳保存済みキーの形状は[b,h,m,k]。
arxiv-1911.02150-mqa.txt:172-172 元のページを開く前後を読む(166〜178行)
166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]176 P_v: a t e n s o r with sha pe [ h , d , v ]177 P_o : a t e n s o r with sha pe [ h , d , v ]178 Retur ns :exact attentionのIO最適化は何を減らし、何を減らさず、どのハードウェア条件で成立するか。
FlashAttentionはメモリの読み書きを節約しますが、全ての位置を比べる演算量の二乗の増え方は残ります。原文 2
requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.
訳HBMアクセス数はΘ(N²d²/M)。
arxiv-2205.14135-flashattention.txt:364-364 元のページを開く前後を読む(358〜370行)
358 A100 GPU. Fewer HBM accesses result in faster runtime, up to a point. Right: The runtime (for seq. length 4K) of359 block-sparse FlashAttention is faster than FlashAttention by a factor proportional to the sparsity.361 asymptotically improve on HBM accesses over all SRAM sizes. Proofs are in Appendix C.362 Theorem 2. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.363 Standard attention (Algorithm 0) requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses, while FlashAttention (Algorithm 1)364 requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.365 For typical values of 𝑑 (64-128) and 𝑀 (around 100KB), 𝑑 2 is many times smaller than 𝑀, and thus366 FlashAttention requires many times fewer HBM accesses than standard implementation. This leads to367 both faster execution and lower memory footprint, which we validate in Section 4.3.368 The main idea of the proof is that given the SRAM size of 𝑀, we can load blocks of K, V of size Θ(𝑀) each369 (Algorithm 1 line 6). For each block of K and V, we iterate over all blocks of Q (Algorithm 1 line 8) to compute370 the intermediate values, resulting in Θ(𝑁 𝑑𝑀 −1 ) passes over Q. Each pass loads Θ(𝑁 𝑑) elements, which𝑂 (𝑁 2 𝑑) FLOPs
訳演算量はO(N²d)。
arxiv-2205.14135-flashattention.txt:319-319 元のページを開く前後を読む(313〜325行)
313 13: Write ℓ𝑖 ← ℓ𝑖new , 𝑚 𝑖 ← 𝑚 𝑖new to HBM.314 14: end for315 15: end for316 16: Return O.318 We show FlashAttention’s correctness, runtime, and memory requirement (proof in Appendix C).319 Theorem 1. Algorithm 1 returns O = softmax(QK> )V with 𝑂 (𝑁 2 𝑑) FLOPs and requires 𝑂 (𝑁) additional320 memory beyond inputs and output.322 3.2 Analysis: IO Complexity of FlashAttention323 We analyze the IO complexity of FlashAttention, showing significant reduction in HBM accesses compared324 to standard attention. We also provide a lower bound, proving that no exact attention algorithm can325 2 This style of aggregation is called algebraic aggregation [33].sparse/local/global attentionはどの接続・窓幅条件で長文を扱い、何を失うか。
窓内だけに絞ると計算は軽くなりますが、離れた位置の情報を伝える経路が長くなります。原文 2
O(r · n · d)
訳近傍幅rに制限した場合の層あたり計算量。
arxiv-1706.03762-attention.txt:272-272 元のページを開く前後を読む(266〜278行)
267 Layer Type Complexity per Layer Sequential Maximum Path Length268 Operations269 Self-Attention O(n2 · d) O(1) O(1)270 Recurrent O(n · d2 ) O(n) O(n)271 Convolutional O(k · n · d2 ) O(1) O(logk (n))272 Self-Attention (restricted) O(r · n · d) O(1) O(n/r)276 3.5 Positional Encoding278 Since our model contains no recurrence and no convolution, in order for the model to make use of theThis would increase the maximum…path length to O(n/r).
訳その場合、最大経路長はO(n/r)に増える。
arxiv-1706.03762-attention.txt:325-326 元のページを開く前後を読む(319〜332行)
320 6321 length n is smaller than the representation dimensionality d, which is most often the case with322 sentence representations used by state-of-the-art models in machine translations, such as word-piece323 [38] and byte-pair [31] representations. To improve computational performance for tasks involving324 very long sequences, self-attention could be restricted to considering only a neighborhood of size r in325 the input sequence centered around the respective output position. This would increase the maximum326 path length to O(n/r). We plan to investigate this approach further in future work.327 A single convolutional layer with kernel width k < n does not connect all pairs of input and output328 positions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,329 or O(logk (n)) in the case of dilated convolutions [18], increasing the length of the longest paths330 between any two positions in the network. Convolutional layers are generally more expensive than331 recurrent layers, by a factor of k. Separable convolutions [6], however, decrease the complexity332 considerably, to O(k · n · d + n · d2 ). Even with k = n, however, the complexity of a separablelinear/低ランク近似は何を仮定し、どの精度・表現力の制約を持つか。
近似法の軽さは無条件ではなく、Performerでは特徴数と誤差の条件、Linformerでは圧縮する次元を確認します。原文 3
queries/keys are upper-bounded by R > 0.
訳query/keyのノルムがRで上から抑えられる。
arxiv-2009.14794-performer.txt:394-394 元のページを開く前後を読む(388〜400行)
388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 trig398 lowing holds for the attention approximation mechanism leveraging estimators SM399 d with ORFs:400 kAb − Ak∞ ≤ with any constant probability, where Ab approximates the attention matrix A.but does not depend on input sequence length L.
訳入力系列長Lには依存しない。
arxiv-2009.14794-performer.txt:391-391 元のページを開く前後を読む(385〜397行)
386 We see that ORFs provide exponentially small and sharper bounds for critical regions where the387 softmax-kernel is small. Below we show that even for the SMtrig mechanism with ORFs, it suffices to388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 trigbetter as projected dimension k increases.
訳射影次元kを増やすと性能が良くなる。
arxiv-2006.04768-linformer.txt:391-391 元のページを開く前後を読む(385〜397行)
385 pretrained with the masked-language-modeling (MLM) objective, and the training for all experiments386 are parallelized across 64 Tesla V100 GPUs with 250k updates.387 Effect of projected dimension: We experiment with various values for the projected dimension k.388 (We use the same k across all layers and heads of Linformer.) In the Figure 3(a) and (b), we plot the389 validation perplexity curves for both the standard Transformer and the Linformer across different390 k, for maximum sequence lengths n = 512 and n = 1024. As expected, the Linformer performs391 better as projected dimension k increases. However, even at k = 128 for n = 512 and k = 256 for392 n = 1024, Linformer’s performance is already nearly on par with the original Transformer. Effect of393 sharing projections: In Figure 3(c), we plot the validation perplexity curves for the three parameter394 sharing strategies (headwise, key-value, and layerwise) with n = 512. Note that when we use just395 a single projection matrix (i.e. for layerwise sharing), the resulting Linformer model’s validation396 perplexity almost matches that of the the non-shared model. This suggests that we can decrease the397 number of additional parameters in our model, and consequently, it’s memory consumption, without日本語の実践知と原著の実験を照合すると、実装・KVキャッシュ・長文評価をどう選び、どこまで一般化できるか。
日本語の谷口らの研究は生成速度をまだ測っていないため、そこで計算量が減ったことからGPUの速度向上を断定できません。原文 1
計測を行っていない。
taniguchi-2025-share-attention.txt:193-193 元のページを開く前後を読む(187〜199行)
187 見受けられた。これは最終レイヤは回答精度につい を併用した場合については、p=0.95(伝搬するトーク188 てはそこまで重要ではないが、回答フォーマットに ンは1割程度), ヘッドを 3 割程度削っても基準モデ189 ついては重要な決定権を持っているためと考えら ルと比較して 8 割程度のスコアを維持できているこ190 れる。 とが確認できた。191 上記考察を踏まえ、Longbench を実行する際は前 生成速度については、CUDA に最適化されている192 半と後半レイヤについては th を小さく・中盤レイヤ 手法である Flash_Attention[6] に Share-Attention 機能193 では大きく設定を行い共有ヘッド数を変化させて検 を追加できていないため計測を行っていない。本手194 証を行った。このときの各レイヤにおけるヘッド維 法により計算量は削減されているため CPU 上での195 持率 (retention rate, 100× 計算を行うヘッド数/本来の 動作では高速化が可能であり、また GPU 上での動196 ヘッド数) を付録 B の図 7 に、検証結果を表 1 に表 作においては Flash_Attention を Share-Attention に対197 した。 応させることで高速化が可能であると思われる。198 表より、QA タスクである Qasper,2wikiqa,Hotpotqa また本実験では Longbench 内の平均長が 10k 程199 ではヘッド維持率が低下するにつれてスコアが下 度 の タ ス ク を 利 用 し て 検 証 を 行 っ た。こ の 理 由
日本語の実践知と原著の実験を照合すると、実装・KVキャッシュ・長文評価をどう選び、どこまで一般化できるか。
初回応答までの時間TTFTと、後続の1トークンごとの時間TPOTを分けて考えることが、日本語のServing解説でも示されています。原文 2
Time To First Token (TTFT)
kamahori-2025-serving.md:270-270 元のページを開く前後を読む(264〜276行)
264 4.3. スケジューリング266 これまでシステム全体の性能を上げる方法を見てきましたが、実用上はスループット(単位時間あたりに生成できる合計トークン数)だけではなくレイテンシ(あるユーザが体験する遅延時間)も重要です。また、全体として効率が良くても、それが特定のユーザの体験を犠牲にした結果であったとしたら望ましくありません。268 LLM servingの[SLO](https://en.wikipedia.org/wiki/Service-level_objective)としては、よく以下の二つが使われます。270 Time To First Token (TTFT): ユーザがリクエストを送ってから、最初のトークンが返ってくるまでの時間。Prefill フェーズに相当。272 Time Per Output Token (TPOT): 最初のトークン生成後に、追加で各出力トークンを生成するのに要する平均時間。Decode フェーズに相当。274 アプリケーションによって細かい要件は異なりますが、一般にTTFTとTPOTの両方が大きくなりすぎないようにすることが求められます。しかし、スケジューリングのロジックを工夫しないと、両方の要件を満たせなくなる場合があります。276 例えば、あるユーザが入力長の非常に長いリクエストを送った場合、単純に「リクエストを来た順に処理する」といったスケジューリングをしていると、そのユーザのprefillのために時間がかかりすぎて、他のユーザのTPOTが大きくなってしまう、といったケースが考えられます。
Time Per Output Token (TPOT)
kamahori-2025-serving.md:272-272 元のページを開く前後を読む(266〜278行)
266 これまでシステム全体の性能を上げる方法を見てきましたが、実用上はスループット(単位時間あたりに生成できる合計トークン数)だけではなくレイテンシ(あるユーザが体験する遅延時間)も重要です。また、全体として効率が良くても、それが特定のユーザの体験を犠牲にした結果であったとしたら望ましくありません。268 LLM servingの[SLO](https://en.wikipedia.org/wiki/Service-level_objective)としては、よく以下の二つが使われます。270 Time To First Token (TTFT): ユーザがリクエストを送ってから、最初のトークンが返ってくるまでの時間。Prefill フェーズに相当。272 Time Per Output Token (TPOT): 最初のトークン生成後に、追加で各出力トークンを生成するのに要する平均時間。Decode フェーズに相当。274 アプリケーションによって細かい要件は異なりますが、一般にTTFTとTPOTの両方が大きくなりすぎないようにすることが求められます。しかし、スケジューリングのロジックを工夫しないと、両方の要件を満たせなくなる場合があります。276 例えば、あるユーザが入力長の非常に長いリクエストを送った場合、単純に「リクエストを来た順に処理する」といったスケジューリングをしていると、そのユーザのprefillのために時間がかかりすぎて、他のユーザのTPOTが大きくなってしまう、といったケースが考えられます。278 これを解決するために、以下のような手法が提案されています。
理解の確認
FlashAttentionは長文の演算回数を線形にしますか。
答えを見る
密な注意を正確に計算するFlashAttentionの演算量はO(N²d)のままです。原文 1
𝑂 (𝑁 2 𝑑) FLOPs
訳演算量はO(N²d)。
arxiv-2205.14135-flashattention.txt:319-319 元のページを開く前後を読む(313〜325行)
313 13: Write ℓ𝑖 ← ℓ𝑖new , 𝑚 𝑖 ← 𝑚 𝑖new to HBM.314 14: end for315 15: end for316 16: Return O.318 We show FlashAttention’s correctness, runtime, and memory requirement (proof in Appendix C).319 Theorem 1. Algorithm 1 returns O = softmax(QK> )V with 𝑂 (𝑁 2 𝑑) FLOPs and requires 𝑂 (𝑁) additional320 memory beyond inputs and output.322 3.2 Analysis: IO Complexity of FlashAttention323 We analyze the IO complexity of FlashAttention, showing significant reduction in HBM accesses compared324 to standard attention. We also provide a lower bound, proving that no exact attention algorithm can325 2 This style of aggregation is called algebraic aggregation [33].長文を扱えるモデルなら中央の情報も必ず使えますか。
答えを見る
Liuらが調べた質問応答と検索では、中央の情報を使うときの性能低下が観察されました。原文 2
swering and key-value retrieval.
訳多文書質問応答とkey-value検索。
liu-2024-lost-middle.txt:23-23 元のページを開く前後を読む(17〜29行)
17 ity to take long contexts as input, relatively18 little is known about how well they use nal information (relevant documents from a search19 longer context. We analyze the performance engine, database query results, etc.; Petroni et al.,20 of language models on two tasks that re- 2020; Ram et al., 2023; Shi et al., 2023; Mallen21 quire identifying relevant information in their et al., 2023; Schick et al., 2023, inter alia).22 input contexts: multi-document question an- Handling these use-cases requires language23 swering and key-value retrieval. We find that models to successfully operate over long se-24 performance can degrade significantly when25 quences. Existing language models are generally26 changing the position of relevant information,27 indicating that current language models do not implemented with Transformers (Vaswani et al.,28 robustly make use of information in long in- 2017), which require memory and compute that29 put contexts. In particular, we observe that increases quadratically in sequence length. Asthe middle of long contexts
訳長い文脈の中央。
liu-2024-lost-middle.txt:35-35 元のページを開く前後を読む(29〜41行)
29 put contexts. In particular, we observe that increases quadratically in sequence length. As30 performance is often highest when relevant in- a result, Transformer language models were of-31 formation occurs at the beginning or end of the ten trained with relatively small context windows32 input context, and significantly degrades when (between 512 and 2048 tokens). Recent improve-33 models must access relevant information in34 ments in hardware (e.g., faster GPUs with more35 the middle of long contexts, even for explicitly36 long-context models. Our analysis provides a memory) and algorithms (Dai et al., 2019; Dao37 better understanding of how language mod- et al., 2022; Poli et al., 2023; Rubin and Berant,38 els use their input context and provides new 2023, inter alia) have resulted in language models39 evaluation protocols for future long-context with larger context windows (e.g., 4096, 32K, and40 language models. even 100K tokens), but it remains unclear how41 these extended-context language models makeLv2(近い分野を知っている人向け)
要旨
Vaswaniらの層あたり密な注意はO(n²d)であり、FlashAttentionはこの演算量を保ったまま中間状態の格納方法を変えます。原文 3
O(n2 · d)
訳系列長n、表現幅dに対する自己注意の層あたり計算量。
arxiv-1706.03762-attention.txt:269-269 元のページを開く前後を読む(263〜275行)
263 Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations264 for different layer types. n is the sequence length, d is the representation dimension, k is the kernel265 size of convolutions and r the size of the neighborhood in restricted self-attention.267 Layer Type Complexity per Layer Sequential Maximum Path Length268 Operations269 Self-Attention O(n2 · d) O(1) O(1)270 Recurrent O(n · d2 ) O(n) O(n)271 Convolutional O(k · n · d2 ) O(1) O(logk (n))272 Self-Attention (restricted) O(r · n · d) O(1) O(n/r)𝑂 (𝑁 2 𝑑) FLOPs
訳演算量はO(N²d)。
arxiv-2205.14135-flashattention.txt:319-319 元のページを開く前後を読む(313〜325行)
313 13: Write ℓ𝑖 ← ℓ𝑖new , 𝑚 𝑖 ← 𝑚 𝑖new to HBM.314 14: end for315 15: end for316 16: Return O.318 We show FlashAttention’s correctness, runtime, and memory requirement (proof in Appendix C).319 Theorem 1. Algorithm 1 returns O = softmax(QK> )V with 𝑂 (𝑁 2 𝑑) FLOPs and requires 𝑂 (𝑁) additional320 memory beyond inputs and output.322 3.2 Analysis: IO Complexity of FlashAttention323 We analyze the IO complexity of FlashAttention, showing significant reduction in HBM accesses compared324 to standard attention. We also provide a lower bound, proving that no exact attention algorithm can325 2 This style of aggregation is called algebraic aggregation [33].materialize the matrices S and P to HBM
訳SとPの行列をHBMに実体化する。
arxiv-2205.14135-flashattention.txt:214-214 元のページを開く前後を読む(208〜220行)
208 Given input sequences Q, K, V ∈ R 𝑁 ×𝑑 where 𝑁 is the sequence length and 𝑑 is the head dimension, we want209 to compute the attention output O ∈ R 𝑁 ×𝑑 :211 S = QK> ∈ R 𝑁 ×𝑁 , P = softmax(S) ∈ R 𝑁 ×𝑁 , O = PV ∈ R 𝑁 ×𝑑 ,213 where softmax is applied row-wise.214 Standard attention implementations materialize the matrices S and P to HBM, which takes 𝑂 (𝑁 2 ) memory.215 Often 𝑁 𝑑 (e.g., for GPT2, 𝑁 = 1024 and 𝑑 = 64). We describe the standard attention implementation216 in Algorithm 0. As some or most of the operations are memory-bound (e.g., softmax), the large number of217 memory accesses translates to slow wall-clock time.218 This problem is exacerbated by other elementwise operations applied to the attention matrix, such as219 masking applied to S or dropout applied to P. As a result, there have been many attempts to fuse several220 elementwise operations, such as fusing masking with softmax [77].PerformerのO(Lrd)とLinformerのO(nk)は、特徴数rや射影次元kを系列長から独立に保つときに系列長に線形と読めます。原文 3
complexity O(Lrd)
訳計算時間はO(Lrd)。
arxiv-2009.14794-performer.txt:174-174 元のページを開く前後を読む(168〜180行)
168 b = diag(Q0 ((K0 )> 1L )).169 D (4)171 Here Att172 \ ↔ stands for the approximate attention and brackets indicate the order of computations. It is173 easy to see that such a mechanism is characterized by space complexity O(Lr + Ld + rd) and time174 complexity O(Lrd) as opposed to O(L2 + Ld) and O(L2 d) of the regular attention (see also Fig. 1).179 Figure 1: Approximation of the regular attention mechanism AV (before D−1 -renormalization) via (random)180 feature maps. Dashed-blocks indicate order of computation with corresponding time complexities attached.operations only require O(nk) time and space complexity.
訳必要な時間・空間はO(nk)。
arxiv-2006.04768-linformer.txt:313-313 元のページを開く前後を読む(307〜319行)
307 = softmax √ · Fi V WiV , (7)308 dk | {z }309 | {z } k×d310 P̄ :n×k312 Finally, we compute context embeddings for each headi using P̄ · (Fi V WiV ). Note the above313 operations only require O(nk) time and space complexity. Thus, if we can choose a very small314 projected dimension k, such that k n, then we can significantly reduce the memory and space315 consumption. The following theorem states that, when k = O(d/2 ) (independent of n), one can316 approximate P · V WiV using linear self-attention (7) with error.317 Theorem 2. (Linear self-attention) For any Qi , Ki , Vi ∈ Rn×d and WiQ , WiK , WiV ∈ Rd×d , if318 k = min{Θ(9d log(d)/2 ), 5Θ(log(n)/2 )}, then√ there exists matrices Ei , Fi ∈ R319 n×kbut does not depend on input sequence length L.
訳入力系列長Lには依存しない。
arxiv-2009.14794-performer.txt:391-391 元のページを開く前後を読む(385〜397行)
386 We see that ORFs provide exponentially small and sharper bounds for critical regions where the387 softmax-kernel is small. Below we show that even for the SMtrig mechanism with ORFs, it suffices to388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 trig生成の1ステップではqueryが1位置なので、過去長mに対するスコアはm個であり、全位置を一度に扱うn×n行列と区別します。原文 2
Multi−head S e l f −A t t e n t i o n ( one s t e p ) .
訳多頭自己注意の1ステップ。
arxiv-1911.02150-mqa.txt:169-169 元のページを開く前後を読む(163〜175行)
163 efficient parallel implementation similar to that in section 2.3. However, when generating from the trained164 model, the output of the self-attention layer at a particular position affects the token that is generated at165 the next position, which in turn affects the input to that layer at the next position. This prevents parallel166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]" bhk , bhmk−>bhm"
訳1ステップのqueryと過去キーから長さmのスコアを作る縮約。
arxiv-1911.02150-mqa.txt:190-190 元のページを開く前後を読む(184〜196行)
184 new_K = t f . c o n c a t (185 [ prev_K , t f . expand_dims ( t f . einsum ( " bd , hdk−>bhk " , M, P_k) , a x i s = 2 ) ] ,186 a x i s =2)187 new_V = t f . c o n c a t (188 [ prev_V , t f . expand_dims ( t f . einsum ( " bd , hdv−>bhv " , M, P_v) , a x i s = 2 ) ] ,189 a x i s =2)190 l o g i t s = t f . einsum ( " bhk , bhmk−>bhm" , q , new_K)191 w e i g h t s = t f . so ftma x ( l o g i t s )192 o = t f . einsum ( "bhm, bhmv−>bhv " , weig hts , new_V)193 y = t f . einsum ( " bhv , hdv−>bd " , O, P_o)194 r e t u r n y , new_K, new_VGQAはquery headの群ごとにkey/valueを共有し、PagedAttentionはKV領域の断片化による浪費を減らす別の層の改善です。原文 2
heads per subgroup of query heads.
訳query headの部分群ごとにkey/value headを持つ。
arxiv-2305.13245-gqa.txt:26-26 元のページを開く前後を読む(20〜32行)
20 be desirable to train a separate model just for well as high-quality MHA checkpoints.21 faster inference. We (1) propose a recipe for Second, we propose grouped-query attention22 uptraining existing multi-head language model (GQA), an interpolation between multi-head and23 checkpoints into models with MQA using 5%24 multi-query attention with single key and value25 of original pre-training compute, and (2) intro-26 duce grouped-query attention (GQA), a gener- heads per subgroup of query heads. We show that27 alization of multi-query attention which uses uptrained GQA achieves quality close to multi-28 an intermediate (more than one, less than num- head attention while being almost as fast as multi-29 ber of query heads) number of key-value heads. query attention.30 We show that uptrained GQA achieves quality31 close to multi-head attention with comparable 2 Method32 speed to MQA.memory can be significantly wasted by fragmentation
訳断片化によってメモリが大きく浪費されうる。
arxiv-2309.06180-pagedattention.txt:36-36 元のページを開く前後を読む(30〜42行)
32 Throughput (token/s)33 and shrinks dynamically. When managed inefficiently, this 1.2k36 memory can be significantly wasted by fragmentation and 0.8k37 Others38 redundant duplication, limiting the batch size. To address 0.4k39 this problem, we propose PagedAttention, an attention al- NVIDIA A100 40GB40 041 gorithm inspired by the classical virtual memory and pag- 0 10 20 30 4042 Batch size (# requests)用語
- HBMとSRAM
FlashAttentionはQ/K/Vをブロックに分けて扱い、原著のMをSRAM容量としたHBMアクセス数はΘ(N²d²/M)です。原文 3
we split the inputs Q, K, V into blocks
訳Q、K、Vをブロックに分ける。
arxiv-2205.14135-flashattention.txt:247-247元のページを開く前後を読む(241〜253行)
242 3.1 An Efficient Attention Algorithm With Tiling and Recomputation243 Given the inputs Q, K, V ∈ R 𝑁 ×𝑑 in HBM, we aim to compute the attention output O ∈ R 𝑁 ×𝑑 and write it to244 HBM. Our goal is to reduce the amount of HBM accesses (to sub-quadratic in 𝑁).245 We apply two established techniques (tiling, recomputation) to overcome the technical challenge of246 computing exact attention in sub-quadratic HBM accesses. We describe this in Algorithm 1. The main idea247 is that we split the inputs Q, K, V into blocks, load them from slow HBM to fast SRAM, then compute the248 attention output with respect to those blocks. By scaling the output of each block by the right normalization249 factor before adding them up, we get the correct result at the end.250 Tiling. We compute attention by blocks. Softmax couples columns of K, so we decompose the large251 softmax with scaling [51, 60, 66]. For numerical stability, the softmax of vector 𝑥 ∈ R 𝐵 is computed as:252 ∑︁ 𝑓 (𝑥)253 𝑓 (𝑥) := 𝑒 𝑥1 −𝑚( 𝑥) 𝑒 𝑥𝐵 −𝑚( 𝑥) ,
𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.
訳SRAM容量Mの範囲。
arxiv-2205.14135-flashattention.txt:362-362元のページを開く前後を読む(356〜368行)
356 (seq. length 1024, head dim. 64, 16 heads, batch size 64) on A100 GPU. HBM access is the primary factor affecting357 runtime. Middle: Forward runtime of FlashAttention (seq. length 1024, head dim. 64, 16 heads, batch size 64) on358 A100 GPU. Fewer HBM accesses result in faster runtime, up to a point. Right: The runtime (for seq. length 4K) of359 block-sparse FlashAttention is faster than FlashAttention by a factor proportional to the sparsity.361 asymptotically improve on HBM accesses over all SRAM sizes. Proofs are in Appendix C.362 Theorem 2. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.363 Standard attention (Algorithm 0) requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses, while FlashAttention (Algorithm 1)364 requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.365 For typical values of 𝑑 (64-128) and 𝑀 (around 100KB), 𝑑 2 is many times smaller than 𝑀, and thus366 FlashAttention requires many times fewer HBM accesses than standard implementation. This leads to367 both faster execution and lower memory footprint, which we validate in Section 4.3.368 The main idea of the proof is that given the SRAM size of 𝑀, we can load blocks of K, V of size Θ(𝑀) each
requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.
訳HBMアクセス数はΘ(N²d²/M)。
arxiv-2205.14135-flashattention.txt:364-364元のページを開く前後を読む(358〜370行)
358 A100 GPU. Fewer HBM accesses result in faster runtime, up to a point. Right: The runtime (for seq. length 4K) of359 block-sparse FlashAttention is faster than FlashAttention by a factor proportional to the sparsity.361 asymptotically improve on HBM accesses over all SRAM sizes. Proofs are in Appendix C.362 Theorem 2. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.363 Standard attention (Algorithm 0) requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses, while FlashAttention (Algorithm 1)364 requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.365 For typical values of 𝑑 (64-128) and 𝑀 (around 100KB), 𝑑 2 is many times smaller than 𝑀, and thus366 FlashAttention requires many times fewer HBM accesses than standard implementation. This leads to367 both faster execution and lower memory footprint, which we validate in Section 4.3.368 The main idea of the proof is that given the SRAM size of 𝑀, we can load blocks of K, V of size Θ(𝑀) each369 (Algorithm 1 line 6). For each block of K and V, we iterate over all blocks of Q (Algorithm 1 line 8) to compute370 the intermediate values, resulting in Θ(𝑁 𝑑𝑀 −1 ) passes over Q. Each pass loads Θ(𝑁 𝑑) elements, which
- KV容量
MHAでhead数h、head幅d_h、層数ℓ、byte数s、batch B、文脈長Nを固定形状とすると、保存するKとVの容量は2BℓNhd_hs byteです(保存形状と公式の式からの導出)。原文 2
prev_K : t e n s o r with sha pe [ b , h , m, k ]
訳保存済みキーの形状は[b,h,m,k]。
arxiv-1911.02150-mqa.txt:172-172元のページを開く前後を読む(166〜178行)
166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]176 P_v: a t e n s o r with sha pe [ h , d , v ]177 P_o : a t e n s o r with sha pe [ h , d , v ]178 Retur ns :
2 * (num_layers) * (num_heads * dim_head) * precision_in_bytes
nvidia-2023-inference-ja.md:73-73元のページを開く前後を読む(67〜79行)
67 モデルの重み: メモリはモデル パラメーターによって占有されます。例として、70 億個のパラメーター (たとえば、[Llama 2 7B](https://huggingface.co/meta-llama/Llama-2-7b/blob/main/params.json))を、16 ビット精度 (FP16 または BF16) でロードすると、メモリにおよそ 7B * sizeof(FP16) ~= 14 GB が必要になります。69 KV キャッシュ: メモリは、冗長な計算を避けるためにセルフアテンション テンソルのキャッシュによって占有されます。71 バッチ処理では、バッチ内の各リクエストの KV キャッシュを個別に割り当てる必要があり、メモリ フットプリントが大きくなる可能性があります。以下の式は、今日の最も一般的な LLM アーキテクチャに適用できる KV キャッシュのサイズを示しています。73 トークンごとの KV キャッシュのサイズ (バイト単位) = 2 * (num_layers) * (num_heads * dim_head) * precision_in_bytes75 最初の係数 2 は、K 行列と V 行列を表します。通常、(num_heads * dim_head) の値は、Transformer の hidden_size (またはモデルの次元 d_model) と同じです。これらのモデル属性は、通常、モデル カードまたは関連する構成ファイルで見つけることができます。77 このメモリ サイズは、入力のバッチ全体にわたって、入力シーケンス内の各トークンに必要です。半精度を仮定すると、KV キャッシュの合計サイズは次の式で求められます。79 KV キャッシュの合計サイズ (バイト単位) = (batch_size) * (sequence_length) * 2 * (num_layers) * (hidden_size) * sizeof(FP16)
- GQA
GQAでKV head数をh_kvにすると同じ容量式のhがh_kvになるため、MHAに対するKV容量比はh_kv/hです(共有構造からの導出)。原文 2
heads per subgroup of query heads.
訳query headの部分群ごとにkey/value headを持つ。
arxiv-2305.13245-gqa.txt:26-26元のページを開く前後を読む(20〜32行)
20 be desirable to train a separate model just for well as high-quality MHA checkpoints.21 faster inference. We (1) propose a recipe for Second, we propose grouped-query attention22 uptraining existing multi-head language model (GQA), an interpolation between multi-head and23 checkpoints into models with MQA using 5%24 multi-query attention with single key and value25 of original pre-training compute, and (2) intro-26 duce grouped-query attention (GQA), a gener- heads per subgroup of query heads. We show that27 alization of multi-query attention which uses uptrained GQA achieves quality close to multi-28 an intermediate (more than one, less than num- head attention while being almost as fast as multi-29 ber of query heads) number of key-value heads. query attention.30 We show that uptrained GQA achieves quality31 close to multi-head attention with comparable 2 Method32 speed to MQA.
prev_K : t e n s o r with sha pe [ b , h , m, k ]
訳保存済みキーの形状は[b,h,m,k]。
arxiv-1911.02150-mqa.txt:172-172元のページを開く前後を読む(166〜178行)
166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]176 P_v: a t e n s o r with sha pe [ h , d , v ]177 P_o : a t e n s o r with sha pe [ h , d , v ]178 Retur ns :
- FAVOR+
Performerはランダム特徴で注意を近似し、計算時間O(Lrd)、空間O(Lr+Ld+rd)を示しています。原文 2
complexity O(Lrd)
訳計算時間はO(Lrd)。
arxiv-2009.14794-performer.txt:174-174元のページを開く前後を読む(168〜180行)
168 b = diag(Q0 ((K0 )> 1L )).169 D (4)171 Here Att172 \ ↔ stands for the approximate attention and brackets indicate the order of computations. It is173 easy to see that such a mechanism is characterized by space complexity O(Lr + Ld + rd) and time174 complexity O(Lrd) as opposed to O(L2 + Ld) and O(L2 d) of the regular attention (see also Fig. 1).179 Figure 1: Approximation of the regular attention mechanism AV (before D−1 -renormalization) via (random)180 feature maps. Dashed-blocks indicate order of computation with corresponding time complexities attached.
space complexity O(Lr + Ld + rd)
訳空間計算量はO(Lr+Ld+rd)。
arxiv-2009.14794-performer.txt:173-173元のページを開く前後を読む(167〜179行)
167 ↔ (Q, K, V) = D168 b = diag(Q0 ((K0 )> 1L )).169 D (4)171 Here Att172 \ ↔ stands for the approximate attention and brackets indicate the order of computations. It is173 easy to see that such a mechanism is characterized by space complexity O(Lr + Ld + rd) and time174 complexity O(Lrd) as opposed to O(L2 + Ld) and O(L2 d) of the regular attention (see also Fig. 1).179 Figure 1: Approximation of the regular attention mechanism AV (before D−1 -renormalization) via (random)
論点ごとの解説
知見の集まる用語・人物・媒体はどこか。
Tri Dao本人のページでPrincetonの助教とTogether AIの共同創業者・Chief Scientistを確認でき、FlashAttention-2の原著でも著者・所属を確認できます。原文 3
Assistant Professor of Computer Science
訳計算機科学の助教。
dao-2026-home.md:3-3 元のページを開く前後を読む(1〜9行)
1 tri [at] tridao (dot) me3 Assistant Professor of Computer Science at [Princeton University](https://www.cs.princeton.edu/), leading the [Dao AI Lab](https://dao-lab.ai/).4 Co-founder & Chief Scientist of [Together AI](https://together.ai/).6 [CV](https://tridao.me/assets/pdf/cv.pdf) (updated 01/2026)8 Previously: PhD, [Department of Computer Science](https://www-cs.stanford.edu/), [Stanford University](https://www.stanford.edu)Co-founder & Chief Scientist
訳共同創業者・Chief Scientist。
dao-2026-home.md:4-4 元のページを開く前後を読む(1〜10行)
1 tri [at] tridao (dot) me3 Assistant Professor of Computer Science at [Princeton University](https://www.cs.princeton.edu/), leading the [Dao AI Lab](https://dao-lab.ai/).4 Co-founder & Chief Scientist of [Together AI](https://together.ai/).6 [CV](https://tridao.me/assets/pdf/cv.pdf) (updated 01/2026)8 Previously: PhD, [Department of Computer Science](https://www-cs.stanford.edu/), [Stanford University](https://www.stanford.edu)10 ## Research InterestsTri Dao1,2
訳著者: Tri Dao。
arxiv-2307.08691-flashattention2.txt:3-3 元のページを開く前後を読む(1〜9行)
1 FlashAttention-2:2 Faster Attention with Better Parallelism and Work Partitioning3 Tri Dao1,24 1 Department of Computer Science, Princeton University5 2 Department of Computer Science, Stanford University6 arXiv:2307.08691v1 [cs.LG] 17 Jul 2023密な自己注意の計算・メモリと、学習・prefill・decode・KVキャッシュはどう違うか。
通常の密なprefillや学習の注意部分はO(N²d)、KVを使うdecodeの1ステップの注意部分はO(Nd)です(原著表と縮約形状からの導出、head数・幅は固定)。原文 3
O(n2 · d)
訳系列長n、表現幅dに対する自己注意の層あたり計算量。
arxiv-1706.03762-attention.txt:269-269 元のページを開く前後を読む(263〜275行)
263 Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations264 for different layer types. n is the sequence length, d is the representation dimension, k is the kernel265 size of convolutions and r the size of the neighborhood in restricted self-attention.267 Layer Type Complexity per Layer Sequential Maximum Path Length268 Operations269 Self-Attention O(n2 · d) O(1) O(1)270 Recurrent O(n · d2 ) O(n) O(n)271 Convolutional O(k · n · d2 ) O(1) O(logk (n))272 Self-Attention (restricted) O(r · n · d) O(1) O(n/r)Multi−head S e l f −A t t e n t i o n ( one s t e p ) .
訳多頭自己注意の1ステップ。
arxiv-1911.02150-mqa.txt:169-169 元のページを開く前後を読む(163〜175行)
163 efficient parallel implementation similar to that in section 2.3. However, when generating from the trained164 model, the output of the self-attention layer at a particular position affects the token that is generated at165 the next position, which in turn affects the input to that layer at the next position. This prevents parallel166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]" bhk , bhmk−>bhm"
訳1ステップのqueryと過去キーから長さmのスコアを作る縮約。
arxiv-1911.02150-mqa.txt:190-190 元のページを開く前後を読む(184〜196行)
184 new_K = t f . c o n c a t (185 [ prev_K , t f . expand_dims ( t f . einsum ( " bd , hdk−>bhk " , M, P_k) , a x i s = 2 ) ] ,186 a x i s =2)187 new_V = t f . c o n c a t (188 [ prev_V , t f . expand_dims ( t f . einsum ( " bd , hdv−>bhv " , M, P_v) , a x i s = 2 ) ] ,189 a x i s =2)190 l o g i t s = t f . einsum ( " bhk , bhmk−>bhm" , q , new_K)191 w e i g h t s = t f . so ftma x ( l o g i t s )192 o = t f . einsum ( "bhm, bhmv−>bhv " , weig hts , new_V)193 y = t f . einsum ( " bhv , hdv−>bd " , O, P_o)194 r e t u r n y , new_K, new_V密な自己注意の計算・メモリと、学習・prefill・decode・KVキャッシュはどう違うか。
KVキャッシュを維持するメモリO(N)と、各ステップで過去のKVを読む帯域コストは残るので、キャッシュだけで長文推論の全制約は消えません。原文 3
prev_K : t e n s o r with sha pe [ b , h , m, k ]
訳保存済みキーの形状は[b,h,m,k]。
arxiv-1911.02150-mqa.txt:172-172 元のページを開く前後を読む(166〜178行)
166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]176 P_v: a t e n s o r with sha pe [ h , d , v ]177 P_o : a t e n s o r with sha pe [ h , d , v ]178 Retur ns :takes one token
訳1トークンを受け取る。
arxiv-2309.06180-pagedattention.txt:179-179 元のページを開く前後を読む(173〜185行)
173 probabilities (a.k.a. autoregressive decomposition [3]):174 matrix multiplication operations. Therefore, this phase can175 efficiently use the parallelism inherent in GPUs.176 𝑃 (𝑥) = 𝑃 (𝑥 1 ) · 𝑃 (𝑥 2 | 𝑥 1 ) · · · 𝑃 (𝑥𝑛 | 𝑥 1, . . . , 𝑥𝑛−1 ). (1)177 The autoregressive generation phase generates the re-178 Transformers [53] have become the de facto standard ar- maining new tokens sequentially. At iteration 𝑡, the model179 chitecture for modeling the probability above at a large scale. takes one token 𝑥𝑛+𝑡 as input and computes the probability180 The most important component of a Transformer-based lan- 𝑃 (𝑥𝑛+𝑡 +1 | 𝑥 1, . . . , 𝑥𝑛+𝑡 ) with the key vectors 𝑘 1, . . . , 𝑘𝑛+𝑡 and181 guage model is its self-attention layers. For an input hidden value vectors 𝑣 1, . . . , 𝑣𝑛+𝑡 . Note that the key and value vectors182 state sequence (𝑥 1, . . . , 𝑥𝑛 ) ∈ R𝑛×𝑑 , a self-attention layer at positions 1 to 𝑛 + 𝑡 − 1 are cached at previous iterations,183 first applies linear transformations on each position 𝑖 to get only the new key and value vector 𝑘𝑛+𝑡 and 𝑣𝑛+𝑡 are com-184 the query, key, and value vectors: puted at this iteration. This phase completes either when the185 sequence reaches a maximum length (specified by users ormemory can be significantly wasted by fragmentation
訳断片化によってメモリが大きく浪費されうる。
arxiv-2309.06180-pagedattention.txt:36-36 元のページを開く前後を読む(30〜42行)
32 Throughput (token/s)33 and shrinks dynamically. When managed inefficiently, this 1.2k36 memory can be significantly wasted by fragmentation and 0.8k37 Others38 redundant duplication, limiting the batch size. To address 0.4k39 this problem, we propose PagedAttention, an attention al- NVIDIA A100 40GB40 041 gorithm inspired by the classical virtual memory and pag- 0 10 20 30 4042 Batch size (# requests)exact attentionのIO最適化は何を減らし、何を減らさず、どのハードウェア条件で成立するか。
FlashAttentionはsoftmaxの統計量と出力を保存して逆伝播時の行列を再計算し、入力・出力とは別の追加メモリをO(N)に抑えます。原文 2
we can recompute the
訳再計算できる。
arxiv-2205.14135-flashattention.txt:281-281 元のページを開く前後を読む(275〜287行)
275 ℓ(𝑥)276 Therefore if we keep track of some extra statistics (𝑚(𝑥), ℓ(𝑥)), we can compute softmax one block at a time.2277 We thus split the inputs Q, K, V into blocks (Algorithm 1 line 3), compute the softmax values along with278 extra statistics (Algorithm 1 line 10), and combine the results (Algorithm 1 line 12).279 Recomputation. One of our goals is to not store 𝑂 (𝑁 2 ) intermediate values for the backward pass. The280 backward pass typically requires the matrices S, P ∈ R 𝑁 ×𝑁 to compute the gradients with respect to Q, K, V.281 However, by storing the output O and the softmax normalization statistics (𝑚, ℓ), we can recompute the282 attention matrix S and P easily in the backward pass from blocks of Q, K, V in SRAM. This can be seen as a283 form of selective gradient checkpointing [10, 34]. While gradient checkpointing has been suggested to reduce284 the maximum amount of memory required [66], all implementations (that we know off) have to trade speed285 for memory. In contrast, even with more FLOPs, our recomputation speeds up the backward pass due to286 reduced HBM accesses (Fig. 2). The full backward pass description is in Appendix B.287 Implementation details: Kernel fusion. Tiling enables us to implement our algorithm in onememory beyond inputs and output.
訳入力と出力に加えて必要なメモリ。
arxiv-2205.14135-flashattention.txt:320-320 元のページを開く前後を読む(314〜326行)
314 14: end for315 15: end for316 16: Return O.318 We show FlashAttention’s correctness, runtime, and memory requirement (proof in Appendix C).319 Theorem 1. Algorithm 1 returns O = softmax(QK> )V with 𝑂 (𝑁 2 𝑑) FLOPs and requires 𝑂 (𝑁) additional320 memory beyond inputs and output.322 3.2 Analysis: IO Complexity of FlashAttention323 We analyze the IO complexity of FlashAttention, showing significant reduction in HBM accesses compared324 to standard attention. We also provide a lower bound, proving that no exact attention algorithm can325 2 This style of aggregation is called algebraic aggregation [33].exact attentionのIO最適化は何を減らし、何を減らさず、どのハードウェア条件で成立するか。
公式実装のFlashAttention-2ではdtypeやhead dimensionの制約があり、FlashAttention-3にはH100/H800とCUDA12.3以上という要件があります。原文 3
Datatype fp16 and bf16
訳対応データ型fp16・bf16。
dao-2026-flashattention-readme.md:146-146 元のページを開く前後を読む(140〜152行)
140 We recommend the141 [Pytorch](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch)142 container from Nvidia, which has all the required tools to install FlashAttention.144 FlashAttention-2 with CUDA currently supports:145 1. Ampere, Ada, or Hopper GPUs (e.g., A100, RTX 3090, RTX 4090, H100). For Turing GPUs (T4, RTX 2080), see the separate [flash-attention-turing](https://github.com/ssiu/flash-attention-turing) repo, which supports a core subset of FlashAttention features on Turing.146 2. Datatype fp16 and bf16 (bf16 requires Ampere, Ada, or Hopper GPUs).147 3. All head dimensions up to 256. ~~Head dim > 192 backward requires A100/A800 or H100/H800~~. Head dim 256 backward now works on consumer GPUs (if there's no dropout) as of flash-attn 2.5.5.149 ### AMD ROCm Support150 ROCm version has two backends. There is [composable_kernel](https://github.com/ROCm/composable_kernel) (ck) which is the default backend and a [Triton](https://github.com/triton-lang/triton) backend. They provide an implementation of FlashAttention-2.152 **Requirements:**All head dimensions up to 256.
訳head dimension 256まで対応。
dao-2026-flashattention-readme.md:147-147 元のページを開く前後を読む(141〜153行)
141 [Pytorch](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch)142 container from Nvidia, which has all the required tools to install FlashAttention.144 FlashAttention-2 with CUDA currently supports:145 1. Ampere, Ada, or Hopper GPUs (e.g., A100, RTX 3090, RTX 4090, H100). For Turing GPUs (T4, RTX 2080), see the separate [flash-attention-turing](https://github.com/ssiu/flash-attention-turing) repo, which supports a core subset of FlashAttention features on Turing.146 2. Datatype fp16 and bf16 (bf16 requires Ampere, Ada, or Hopper GPUs).147 3. All head dimensions up to 256. ~~Head dim > 192 backward requires A100/A800 or H100/H800~~. Head dim 256 backward now works on consumer GPUs (if there's no dropout) as of flash-attn 2.5.5.149 ### AMD ROCm Support150 ROCm version has two backends. There is [composable_kernel](https://github.com/ROCm/composable_kernel) (ck) which is the default backend and a [Triton](https://github.com/triton-lang/triton) backend. They provide an implementation of FlashAttention-2.152 **Requirements:**153 - ROCm 6.0 and above.Requirements: H100 / H800 GPU, CUDA >= 12.3.
訳FlashAttention-3の要件はH100/H800、CUDA12.3以上。
dao-2026-flashattention-readme.md:45-45 元のページを開く前後を読む(39〜51行)
39 This is a beta release for testing / benchmarking before we integrate that with40 the rest of the repo.42 Currently released:43 - FP16 / BF16 forward and backward, FP8 forward45 Requirements: H100 / H800 GPU, CUDA >= 12.3.47 We highly recommend CUDA 12.8 for best performance.49 To install:50 ```sh51 cd hoppersparse/local/global attentionはどの接続・窓幅条件で長文を扱い、何を失うか。
Longformerの局所部分は固定窓wならO(nw)で、層数をℓとした局所経路の受容野はℓwです。原文 3
Given a fixed window size w
訳固定された窓幅wの下で。
arxiv-2004.05150-longformer.txt:179-179 元のページを開く前後を読む(173〜185行)
173 attention in Transformers, and pre-training it for rounding each token. Using multiple stacked lay-174 long document natural language tasks. In particu- ers of such windowed attention results in a large175 lar, ETC (Ainslie et al., 2020) uses a similar local receptive field, where top layers have access to all176 + global attention instead of full self-attention to input locations and have the capacity to build repre-177 scale Transformers to long documents. Different sentations that incorporate information across the178 from Longformer, ETC uses relative position em- entire input, similar to CNNs (Wu et al., 2019).179 2 Given a fixed window size w, each token attends180 SQuAD contexts typically fit within the 512 limit, and181 MRQA is constructed by dropping long-document examples. to 12 w tokens on each side (Fig. 2b). The com-182 3183 All were published on arXiv after Longformer. putation complexity of this pattern is O(n × w),185 3complexity of this pattern is O(n × w)
訳このパターンの計算量はO(nw)。
arxiv-2004.05150-longformer.txt:183-183 元のページを開く前後を読む(177〜189行)
177 scale Transformers to long documents. Different sentations that incorporate information across the178 from Longformer, ETC uses relative position em- entire input, similar to CNNs (Wu et al., 2019).179 2 Given a fixed window size w, each token attends180 SQuAD contexts typically fit within the 512 limit, and181 MRQA is constructed by dropping long-document examples. to 12 w tokens on each side (Fig. 2b). The com-182 3183 All were published on arXiv after Longformer. putation complexity of this pattern is O(n × w),185 3186 which scales linearly with input sequence length n. simpler than existing task specific approaches that187 In a transformer with ` layers, the receptive field use complex architecture to combine information188 size at the top layer is ` × w (assuming w is fixed across smaller input chunks.189 for all layers). Depending on the application, itsize at the top layer is ` × w
訳最上層の受容野の大きさは層数×窓幅。
arxiv-2004.05150-longformer.txt:188-188 元のページを開く前後を読む(182〜194行)
182 3183 All were published on arXiv after Longformer. putation complexity of this pattern is O(n × w),185 3186 which scales linearly with input sequence length n. simpler than existing task specific approaches that187 In a transformer with ` layers, the receptive field use complex architecture to combine information188 size at the top layer is ` × w (assuming w is fixed across smaller input chunks.189 for all layers). Depending on the application, it190 Linear Projections for Global Attention Re-191 might be helpful to use different values of w for192 call that given the linear projections Q, K, V , the193 each layer to balance between efficiency and model194 Transformer model (Vaswani et al., 2017) computessparse/local/global attentionはどの接続・窓幅条件で長文を扱い、何を失うか。
BigBirdは局所窓、random token、global tokenを組み合わせるため、幅と個数を固定した場合に全接続数を系列長に線形にできます(接続定義からの導出)。原文 3
A set of g global tokens attending on all parts of the sequence.
訳系列全体に注意を向けるg個のglobal token。
arxiv-2007.14062-bigbird.txt:79-79 元のページを開く前後を読む(73〜85行)
73 B IG B IRD, an attention mechanism whose complexity is linear in the number of tokens (Sec. 2). We74 take inspiration from graph sparsification methods and understand where the proof for expressiveness75 of Transformers breaks down when full-attention is relaxed to form the proposed attention pattern.76 This understanding helped us develop B IG B IRD, which is theoretically as expressive and also77 empirically useful. In particular, our B IG B IRD consists of three main part:79 • A set of g global tokens attending on all parts of the sequence.80 • All tokens attending to a set of w local neighboring tokens.81 • All tokens attending to a set of r random tokens.83 This leads to a high performing attention mechanism scaling to much longer sequence lengths (8x).84 To summarize, our main contributions are:All tokens attending to a set of r random tokens.
訳全トークンがr個のランダムなトークンに注意を向ける。
arxiv-2007.14062-bigbird.txt:81-81 元のページを開く前後を読む(75〜87行)
75 of Transformers breaks down when full-attention is relaxed to form the proposed attention pattern.76 This understanding helped us develop B IG B IRD, which is theoretically as expressive and also77 empirically useful. In particular, our B IG B IRD consists of three main part:79 • A set of g global tokens attending on all parts of the sequence.80 • All tokens attending to a set of w local neighboring tokens.81 • All tokens attending to a set of r random tokens.83 This leads to a high performing attention mechanism scaling to much longer sequence lengths (8x).84 To summarize, our main contributions are:86 1. B IG B IRD satisfies all the known theoretical properties of full transformer (Sec. 3). In particular,87 we show that adding extra tokens allows one to express all continuous sequence to sequenceAll tokens attending to a set of w local neighboring tokens.
訳全トークンが近傍のwトークンに注意を向ける。
arxiv-2007.14062-bigbird.txt:80-80 元のページを開く前後を読む(74〜86行)
74 take inspiration from graph sparsification methods and understand where the proof for expressiveness75 of Transformers breaks down when full-attention is relaxed to form the proposed attention pattern.76 This understanding helped us develop B IG B IRD, which is theoretically as expressive and also77 empirically useful. In particular, our B IG B IRD consists of three main part:79 • A set of g global tokens attending on all parts of the sequence.80 • All tokens attending to a set of w local neighboring tokens.81 • All tokens attending to a set of r random tokens.83 This leads to a high performing attention mechanism scaling to much longer sequence lengths (8x).84 To summarize, our main contributions are:86 1. B IG B IRD satisfies all the known theoretical properties of full transformer (Sec. 3). In particular,linear/低ランク近似は何を仮定し、どの精度・表現力の制約を持つか。
Performerの一様近似保証はquery/keyのノルム上界Rや要求精度に依存し、単にLだけを増やしたときの線形性を無条件の一定精度保証と混同しないようにします。原文 2
queries/keys are upper-bounded by R > 0.
訳query/keyのノルムがRで上から抑えられる。
arxiv-2009.14794-performer.txt:394-394 元のページを開く前後を読む(388〜400行)
388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 trig398 lowing holds for the attention approximation mechanism leveraging estimators SM399 d with ORFs:400 kAb − Ak∞ ≤ with any constant probability, where Ab approximates the attention matrix A.but does not depend on input sequence length L.
訳入力系列長Lには依存しない。
arxiv-2009.14794-performer.txt:391-391 元のページを開く前後を読む(385〜397行)
386 We see that ORFs provide exponentially small and sharper bounds for critical regions where the387 softmax-kernel is small. Below we show that even for the SMtrig mechanism with ORFs, it suffices to388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 triglinear/低ランク近似は何を仮定し、どの精度・表現力の制約を持つか。
Linformer原著は射影次元kを増やすほど精度が良くなると報告しており、kを小さく保つことと精度との兼ね合いを調べる必要があります。原文 3
operations only require O(nk) time and space complexity.
訳必要な時間・空間はO(nk)。
arxiv-2006.04768-linformer.txt:313-313 元のページを開く前後を読む(307〜319行)
307 = softmax √ · Fi V WiV , (7)308 dk | {z }309 | {z } k×d310 P̄ :n×k312 Finally, we compute context embeddings for each headi using P̄ · (Fi V WiV ). Note the above313 operations only require O(nk) time and space complexity. Thus, if we can choose a very small314 projected dimension k, such that k n, then we can significantly reduce the memory and space315 consumption. The following theorem states that, when k = O(d/2 ) (independent of n), one can316 approximate P · V WiV using linear self-attention (7) with error.317 Theorem 2. (Linear self-attention) For any Qi , Ki , Vi ∈ Rn×d and WiQ , WiK , WiV ∈ Rd×d , if318 k = min{Θ(9d log(d)/2 ), 5Θ(log(n)/2 )}, then√ there exists matrices Ei , Fi ∈ R319 n×kbetter as projected dimension k increases.
訳射影次元kを増やすと性能が良くなる。
arxiv-2006.04768-linformer.txt:391-391 元のページを開く前後を読む(385〜397行)
385 pretrained with the masked-language-modeling (MLM) objective, and the training for all experiments386 are parallelized across 64 Tesla V100 GPUs with 250k updates.387 Effect of projected dimension: We experiment with various values for the projected dimension k.388 (We use the same k across all layers and heads of Linformer.) In the Figure 3(a) and (b), we plot the389 validation perplexity curves for both the standard Transformer and the Linformer across different390 k, for maximum sequence lengths n = 512 and n = 1024. As expected, the Linformer performs391 better as projected dimension k increases. However, even at k = 128 for n = 512 and k = 256 for392 n = 1024, Linformer’s performance is already nearly on par with the original Transformer. Effect of393 sharing projections: In Figure 3(c), we plot the validation perplexity curves for the three parameter394 sharing strategies (headwise, key-value, and layerwise) with n = 512. Note that when we use just395 a single projection matrix (i.e. for layerwise sharing), the resulting Linformer model’s validation396 perplexity almost matches that of the the non-shared model. This suggests that we can decrease the397 number of additional parameters in our model, and consequently, it’s memory consumption, withoutk = 128 for n = 512 and k = 256 for
訳n=512ではk=128、n=1024ではk=256を比較した。
arxiv-2006.04768-linformer.txt:391-391 元のページを開く前後を読む(385〜397行)
385 pretrained with the masked-language-modeling (MLM) objective, and the training for all experiments386 are parallelized across 64 Tesla V100 GPUs with 250k updates.387 Effect of projected dimension: We experiment with various values for the projected dimension k.388 (We use the same k across all layers and heads of Linformer.) In the Figure 3(a) and (b), we plot the389 validation perplexity curves for both the standard Transformer and the Linformer across different390 k, for maximum sequence lengths n = 512 and n = 1024. As expected, the Linformer performs391 better as projected dimension k increases. However, even at k = 128 for n = 512 and k = 256 for392 n = 1024, Linformer’s performance is already nearly on par with the original Transformer. Effect of393 sharing projections: In Figure 3(c), we plot the validation perplexity curves for the three parameter394 sharing strategies (headwise, key-value, and layerwise) with n = 512. Note that when we use just395 a single projection matrix (i.e. for layerwise sharing), the resulting Linformer model’s validation396 perplexity almost matches that of the the non-shared model. This suggests that we can decrease the397 number of additional parameters in our model, and consequently, it’s memory consumption, without日本語の実践知と原著の実験を照合すると、実装・KVキャッシュ・長文評価をどう選び、どこまで一般化できるか。
GQA原著の速度測定はTPUv4で、モデルごとにbatchを調整した条件なので、A100上のFlashAttention-2の倍率とそのまま順位比較できません。原文 2
Timing We report time per sample per TPUv4
訳時間計測はTPUv4のサンプルあたり時間。
arxiv-2305.13245-gqa.txt:156-156 元のページを開く前後を読む(150〜162行)
150 Figure 3: Uptrained MQA yields a favorable tradeoff151 train until convergence and select the checkpoint152 compared to MHA with higher quality and faster153 with the highest dev performance. We use greedy speed than MHA-Large, and GQA achieves even154 decoding for inference. better performance with similar speed gains and155 comparable quality to MHA-XXL. Average perfor-156 Timing We report time per sample per TPUv4157 mance on all tasks as a function of average inference158 chip, as measured by xprof (Google, 2020). For time per sample for T5-Large and T5-XXL with multi-159 timing experiments we use 8 TPUs with the largest head attention, and 5% uptrained T5-XXL with MQA160 batch size that fits up to 32 per TPU, and paral- and GQA-8 attention.161 lelization optimized separately for each model.A100 and getting close to the efficiency of GEMM operations.
訳A100でGEMMの効率に近づく。
arxiv-2307.08691-flashattention2.txt:31-31 元のページを開く前後を読む(25〜37行)
25 warps on the GPU, causing either low-occupancy or unnecessary shared memory reads/writes. We propose26 FlashAttention-2, with better work partitioning to address these issues. In particular, we (1) tweak27 the algorithm to reduce the number of non-matmul FLOPs (2) parallelize the attention computation, even28 for a single head, across different thread blocks to increase occupancy, and (3) within each thread block,29 distribute the work between warps to reduce communication through shared memory. These yield around30 2× speedup compared to FlashAttention, reaching 50-73% of the theoretical maximum FLOPs/s on31 A100 and getting close to the efficiency of GEMM operations. We empirically validate that when used32 end-to-end to train GPT-style models, FlashAttention-2 reaches training speed of up to 225 TFLOPs/s33 per A100 GPU (72% model FLOPs utilization).136 1 Introduction37 Scaling up the context length of Transformers [18] is a challenge, since the attention layer at their heart日本語の実践知と原著の実験を照合すると、実装・KVキャッシュ・長文評価をどう選び、どこまで一般化できるか。
Flashbackの日本語実験は共通の学習系列長2048、A100、手法ごとにスループットを最大化するbatchであり、固定batchの1リクエスト遅延とは測定対象が異なります。原文 3
の 2048 に設定した.
sekii-2025-flashback.txt:412-412 元のページを開く前後を読む(406〜418行)
406 ン分のテキストを同じ順序で学習した.これらのテ 本実験では,従来研究における主要なベースライ407 キストは,GPT-2 BPE トークナイザーを用いてトー ン手法 [5, 25] を選択し,その性能を提案手法と比較408 クン化された.Attention 機構を用いる手法では,学 した.Transformer++ [5] は Rotary Encoding による位409 習と評価に FlashAttention-2 [34] を用いた.学習時の 置埋め込みと Gated Linear Unit を Transformers に追410 バッチサイズは各手法でメモリ使用量が最大になる 加したものである.Mamba [25] は,重要な情報を入411 よう調整した.学習時の入力の系列長は各手法共通 力に依存して選択的に隠れ状態に保存できる SSM412 の 2048 に設定した. の最新の手法である.417 ― 3394 ― This work is licensed by the author(s) under CC BY 4.0418 (https://creativecommons.org/licenses/by/4.0/).
同一の NVIDIA A100 GPU
sekii-2025-flashback.txt:392-392 元のページを開く前後を読む(386〜398行)
386 層系列処理モデルの従来研究において近年広く利用 一致するよう調整した.387 されている.具体的には,22 のサブセットから構成388 されており,総容量は 800 [GB] に及ぶ.これらのサ A.2.1 評価方法389 ブセットには,論文,書籍,プログラム,技術文書 各データセットで用いられる評価指標について390 などが含まれ,多岐にわたる種類のテキストデータ は,Arora ら [26] と同一のものを用いているため,詳391 を用いて言語モデルの汎化性を評価することがで 細は文献を参照されたい.各手法の性能を公平に比392 きる. 較するため,学習と評価に同一の NVIDIA A100 GPU393 を用いた.各手法の処理速度の比較には,単位時間394 A.1.2 評価データ あたりのトークン生成のスループット(Tok./ms)を395 LM-Eval Harness [33] は,EleutherAI によって提供 用いる.処理速度の計測時には,各手法のバッチサ396 されている標準化されたベンチマークである.本実 イズを,実行可能な範囲でスループットが最大にな397 験では,表 1 に示す複数のデータセットを評価に用 るよう調整した.これは,手法間の計算特性やハー398 いた.なお,図 3 に示した常識推論精度は,これら ドウェア利用効率の違いを考慮し,各手法の性能を
スループットが最大にな
sekii-2025-flashback.txt:396-396 元のページを開く前後を読む(390〜402行)
390 などが含まれ,多岐にわたる種類のテキストデータ は,Arora ら [26] と同一のものを用いているため,詳391 を用いて言語モデルの汎化性を評価することがで 細は文献を参照されたい.各手法の性能を公平に比392 きる. 較するため,学習と評価に同一の NVIDIA A100 GPU393 を用いた.各手法の処理速度の比較には,単位時間394 A.1.2 評価データ あたりのトークン生成のスループット(Tok./ms)を395 LM-Eval Harness [33] は,EleutherAI によって提供 用いる.処理速度の計測時には,各手法のバッチサ396 されている標準化されたベンチマークである.本実 イズを,実行可能な範囲でスループットが最大にな397 験では,表 1 に示す複数のデータセットを評価に用 るよう調整した.これは,手法間の計算特性やハー398 いた.なお,図 3 に示した常識推論精度は,これら ドウェア利用効率の違いを考慮し,各手法の性能を399 のデータセットに対する精度の平均である. 最大限に引き出すことで公平な比較を実現するため400 である.また,各手法のメモリ効率の比較には,処401 A.2 実験の設定402 理速度計測時の GPU メモリの総使用量をバッチサ
理解の確認
Nを2倍にしたとき何が増えますか。
答えを見る
head幅等を固定した密な注意部分の演算は約4倍、KV保存量と1ステップdecodeの注意部分は約2倍になります(計算量・形状からの導出)。原文 3
O(n2 · d)
訳系列長n、表現幅dに対する自己注意の層あたり計算量。
arxiv-1706.03762-attention.txt:269-269 元のページを開く前後を読む(263〜275行)
263 Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations264 for different layer types. n is the sequence length, d is the representation dimension, k is the kernel265 size of convolutions and r the size of the neighborhood in restricted self-attention.267 Layer Type Complexity per Layer Sequential Maximum Path Length268 Operations269 Self-Attention O(n2 · d) O(1) O(1)270 Recurrent O(n · d2 ) O(n) O(n)271 Convolutional O(k · n · d2 ) O(1) O(logk (n))272 Self-Attention (restricted) O(r · n · d) O(1) O(n/r)prev_K : t e n s o r with sha pe [ b , h , m, k ]
訳保存済みキーの形状は[b,h,m,k]。
arxiv-1911.02150-mqa.txt:172-172 元のページを開く前後を読む(166〜178行)
166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]176 P_v: a t e n s o r with sha pe [ h , d , v ]177 P_o : a t e n s o r with sha pe [ h , d , v ]178 Retur ns :" bhk , bhmk−>bhm"
訳1ステップのqueryと過去キーから長さmのスコアを作る縮約。
arxiv-1911.02150-mqa.txt:190-190 元のページを開く前後を読む(184〜196行)
184 new_K = t f . c o n c a t (185 [ prev_K , t f . expand_dims ( t f . einsum ( " bd , hdk−>bhk " , M, P_k) , a x i s = 2 ) ] ,186 a x i s =2)187 new_V = t f . c o n c a t (188 [ prev_V , t f . expand_dims ( t f . einsum ( " bd , hdv−>bhv " , M, P_v) , a x i s = 2 ) ] ,189 a x i s =2)190 l o g i t s = t f . einsum ( " bhk , bhmk−>bhm" , q , new_K)191 w e i g h t s = t f . so ftma x ( l o g i t s )192 o = t f . einsum ( "bhm, bhmv−>bhv " , weig hts , new_V)193 y = t f . einsum ( " bhv , hdv−>bd " , O, P_o)194 r e t u r n y , new_K, new_VGQAとPagedAttentionは同じ節約ですか。
答えを見る
GQAはKVのhead共有を変え、PagedAttentionはキャッシュの断片化や重複による浪費を減らします。原文 2
heads per subgroup of query heads.
訳query headの部分群ごとにkey/value headを持つ。
arxiv-2305.13245-gqa.txt:26-26 元のページを開く前後を読む(20〜32行)
20 be desirable to train a separate model just for well as high-quality MHA checkpoints.21 faster inference. We (1) propose a recipe for Second, we propose grouped-query attention22 uptraining existing multi-head language model (GQA), an interpolation between multi-head and23 checkpoints into models with MQA using 5%24 multi-query attention with single key and value25 of original pre-training compute, and (2) intro-26 duce grouped-query attention (GQA), a gener- heads per subgroup of query heads. We show that27 alization of multi-query attention which uses uptrained GQA achieves quality close to multi-28 an intermediate (more than one, less than num- head attention while being almost as fast as multi-29 ber of query heads) number of key-value heads. query attention.30 We show that uptrained GQA achieves quality31 close to multi-head attention with comparable 2 Method32 speed to MQA.memory can be significantly wasted by fragmentation
訳断片化によってメモリが大きく浪費されうる。
arxiv-2309.06180-pagedattention.txt:36-36 元のページを開く前後を読む(30〜42行)
32 Throughput (token/s)33 and shrinks dynamically. When managed inefficiently, this 1.2k36 memory can be significantly wasted by fragmentation and 0.8k37 Others38 redundant duplication, limiting the batch size. To address 0.4k39 this problem, we propose PagedAttention, an attention al- NVIDIA A100 40GB40 041 gorithm inspired by the classical virtual memory and pag- 0 10 20 30 4042 Batch size (# requests)Lv3(この分野を専門にする人向け)
要旨
FlashAttentionの線形メモリはdense softmaxの真に劣二乗な演算時間の証明ではなく、O(N²d) FLOPsと追加メモリの主張を分けて読む必要があります。原文 2
𝑂 (𝑁 2 𝑑) FLOPs
訳演算量はO(N²d)。
arxiv-2205.14135-flashattention.txt:319-319 元のページを開く前後を読む(313〜325行)
313 13: Write ℓ𝑖 ← ℓ𝑖new , 𝑚 𝑖 ← 𝑚 𝑖new to HBM.314 14: end for315 15: end for316 16: Return O.318 We show FlashAttention’s correctness, runtime, and memory requirement (proof in Appendix C).319 Theorem 1. Algorithm 1 returns O = softmax(QK> )V with 𝑂 (𝑁 2 𝑑) FLOPs and requires 𝑂 (𝑁) additional320 memory beyond inputs and output.322 3.2 Analysis: IO Complexity of FlashAttention323 We analyze the IO complexity of FlashAttention, showing significant reduction in HBM accesses compared324 to standard attention. We also provide a lower bound, proving that no exact attention algorithm can325 2 This style of aggregation is called algebraic aggregation [33].memory beyond inputs and output.
訳入力と出力に加えて必要なメモリ。
arxiv-2205.14135-flashattention.txt:320-320 元のページを開く前後を読む(314〜326行)
314 14: end for315 15: end for316 16: Return O.318 We show FlashAttention’s correctness, runtime, and memory requirement (proof in Appendix C).319 Theorem 1. Algorithm 1 returns O = softmax(QK> )V with 𝑂 (𝑁 2 𝑑) FLOPs and requires 𝑂 (𝑁) additional320 memory beyond inputs and output.322 3.2 Analysis: IO Complexity of FlashAttention323 We analyze the IO complexity of FlashAttention, showing significant reduction in HBM accesses compared324 to standard attention. We also provide a lower bound, proving that no exact attention algorithm can325 2 This style of aggregation is called algebraic aggregation [33].BigBirdの表現力の定理は同じ層数で全てのdense計算を置き換えられるという主張ではなく、疎な辺数で深さを要する課題が原著の限界節にあります。原文 2
under standard complexity theoretic assumptions
訳標準的な計算量理論の仮定の下で。
arxiv-2007.14062-bigbird.txt:321-321 元のページを開く前後を読む(315〜327行)
315 symbol. Most of the construction of Pérez et al. [72] goes through for sparse attentions, except for316 their addressing scheme to point back in history (Lemma B.4 in [72]). We show how to simulate this317 using a sparse attention mechanism and defer the details to App. B.319 3.4 Limitations320 We demonstrate a natural task which can be solved by the full attention mechanism in O(1)-layers.321 However, under standard complexity theoretic assumptions, this problem requires Ω̃(n)-layers for322 any sparse attention layers with Õ(n) edges (not just B IG B IRD). (Here Õ hides poly-logarthmic323 factors). Consider the simple problem of finding the corresponding furthest vector for each vector in324 the given sequence of length n. Formally,325 Task 1. Given n unit vectors {u1 , . . . , un }, find f (u1 , . . . , un ) → (u1∗ , . . . , un∗ ) where for a fixed326 j ∈ [n], we define j ∗ = arg maxk kuk − uj k22 .327 Finding vectors that are furthest apart boils down to minimize inner product search in case of unitany sparse attention layers with Õ(n) edges
訳辺数がほぼ線形のあらゆる疎な注意層。
arxiv-2007.14062-bigbird.txt:322-322 元のページを開く前後を読む(316〜328行)
316 their addressing scheme to point back in history (Lemma B.4 in [72]). We show how to simulate this317 using a sparse attention mechanism and defer the details to App. B.319 3.4 Limitations320 We demonstrate a natural task which can be solved by the full attention mechanism in O(1)-layers.321 However, under standard complexity theoretic assumptions, this problem requires Ω̃(n)-layers for322 any sparse attention layers with Õ(n) edges (not just B IG B IRD). (Here Õ hides poly-logarthmic323 factors). Consider the simple problem of finding the corresponding furthest vector for each vector in324 the given sequence of length n. Formally,325 Task 1. Given n unit vectors {u1 , . . . , un }, find f (u1 , . . . , un ) → (u1∗ , . . . , un∗ ) where for a fixed326 j ∈ [n], we define j ∗ = arg maxk kuk − uj k22 .327 Finding vectors that are furthest apart boils down to minimize inner product search in case of unit328 vectors. For a full-attention mechanism with appropriate query and keys, this task is very easy as wePerformerとLinformerの近似の議論では、系列長への次数と、特徴数・射影次元・誤差を分けて検討する必要があります。原文 4
complexity O(Lrd)
訳計算時間はO(Lrd)。
arxiv-2009.14794-performer.txt:174-174 元のページを開く前後を読む(168〜180行)
168 b = diag(Q0 ((K0 )> 1L )).169 D (4)171 Here Att172 \ ↔ stands for the approximate attention and brackets indicate the order of computations. It is173 easy to see that such a mechanism is characterized by space complexity O(Lr + Ld + rd) and time174 complexity O(Lrd) as opposed to O(L2 + Ld) and O(L2 d) of the regular attention (see also Fig. 1).179 Figure 1: Approximation of the regular attention mechanism AV (before D−1 -renormalization) via (random)180 feature maps. Dashed-blocks indicate order of computation with corresponding time complexities attached.queries/keys are upper-bounded by R > 0.
訳query/keyのノルムがRで上から抑えられる。
arxiv-2009.14794-performer.txt:394-394 元のページを開く前後を読む(388〜400行)
388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 trig398 lowing holds for the attention approximation mechanism leveraging estimators SM399 d with ORFs:400 kAb − Ak∞ ≤ with any constant probability, where Ab approximates the attention matrix A.operations only require O(nk) time and space complexity.
訳必要な時間・空間はO(nk)。
arxiv-2006.04768-linformer.txt:313-313 元のページを開く前後を読む(307〜319行)
307 = softmax √ · Fi V WiV , (7)308 dk | {z }309 | {z } k×d310 P̄ :n×k312 Finally, we compute context embeddings for each headi using P̄ · (Fi V WiV ). Note the above313 operations only require O(nk) time and space complexity. Thus, if we can choose a very small314 projected dimension k, such that k n, then we can significantly reduce the memory and space315 consumption. The following theorem states that, when k = O(d/2 ) (independent of n), one can316 approximate P · V WiV using linear self-attention (7) with error.317 Theorem 2. (Linear self-attention) For any Qi , Ki , Vi ∈ Rn×d and WiQ , WiK , WiV ∈ Rd×d , if318 k = min{Θ(9d log(d)/2 ), 5Θ(log(n)/2 )}, then√ there exists matrices Ei , Fi ∈ R319 n×kbetter as projected dimension k increases.
訳射影次元kを増やすと性能が良くなる。
arxiv-2006.04768-linformer.txt:391-391 元のページを開く前後を読む(385〜397行)
385 pretrained with the masked-language-modeling (MLM) objective, and the training for all experiments386 are parallelized across 64 Tesla V100 GPUs with 250k updates.387 Effect of projected dimension: We experiment with various values for the projected dimension k.388 (We use the same k across all layers and heads of Linformer.) In the Figure 3(a) and (b), we plot the389 validation perplexity curves for both the standard Transformer and the Linformer across different390 k, for maximum sequence lengths n = 512 and n = 1024. As expected, the Linformer performs391 better as projected dimension k increases. However, even at k = 128 for n = 512 and k = 256 for392 n = 1024, Linformer’s performance is already nearly on par with the original Transformer. Effect of393 sharing projections: In Figure 3(c), we plot the validation perplexity curves for the three parameter394 sharing strategies (headwise, key-value, and layerwise) with n = 512. Note that when we use just395 a single projection matrix (i.e. for layerwise sharing), the resulting Linformer model’s validation396 perplexity almost matches that of the the non-shared model. This suggests that we can decrease the397 number of additional parameters in our model, and consequently, it’s memory consumption, without日本語の本人研究を原著条件までたどると、未計測の速度と最適batchのスループットが混在しているため、削減率だけの横比較では判断できません。原文 2
計測を行っていない。
taniguchi-2025-share-attention.txt:193-193 元のページを開く前後を読む(187〜199行)
187 見受けられた。これは最終レイヤは回答精度につい を併用した場合については、p=0.95(伝搬するトーク188 てはそこまで重要ではないが、回答フォーマットに ンは1割程度), ヘッドを 3 割程度削っても基準モデ189 ついては重要な決定権を持っているためと考えら ルと比較して 8 割程度のスコアを維持できているこ190 れる。 とが確認できた。191 上記考察を踏まえ、Longbench を実行する際は前 生成速度については、CUDA に最適化されている192 半と後半レイヤについては th を小さく・中盤レイヤ 手法である Flash_Attention[6] に Share-Attention 機能193 では大きく設定を行い共有ヘッド数を変化させて検 を追加できていないため計測を行っていない。本手194 証を行った。このときの各レイヤにおけるヘッド維 法により計算量は削減されているため CPU 上での195 持率 (retention rate, 100× 計算を行うヘッド数/本来の 動作では高速化が可能であり、また GPU 上での動196 ヘッド数) を付録 B の図 7 に、検証結果を表 1 に表 作においては Flash_Attention を Share-Attention に対197 した。 応させることで高速化が可能であると思われる。198 表より、QA タスクである Qasper,2wikiqa,Hotpotqa また本実験では Longbench 内の平均長が 10k 程199 ではヘッド維持率が低下するにつれてスコアが下 度 の タ ス ク を 利 用 し て 検 証 を 行 っ た。こ の 理 由
スループットが最大にな
sekii-2025-flashback.txt:396-396 元のページを開く前後を読む(390〜402行)
390 などが含まれ,多岐にわたる種類のテキストデータ は,Arora ら [26] と同一のものを用いているため,詳391 を用いて言語モデルの汎化性を評価することがで 細は文献を参照されたい.各手法の性能を公平に比392 きる. 較するため,学習と評価に同一の NVIDIA A100 GPU393 を用いた.各手法の処理速度の比較には,単位時間394 A.1.2 評価データ あたりのトークン生成のスループット(Tok./ms)を395 LM-Eval Harness [33] は,EleutherAI によって提供 用いる.処理速度の計測時には,各手法のバッチサ396 されている標準化されたベンチマークである.本実 イズを,実行可能な範囲でスループットが最大にな397 験では,表 1 に示す複数のデータセットを評価に用 るよう調整した.これは,手法間の計算特性やハー398 いた.なお,図 3 に示した常識推論精度は,これら ドウェア利用効率の違いを考慮し,各手法の性能を399 のデータセットに対する精度の平均である. 最大限に引き出すことで公平な比較を実現するため400 である.また,各手法のメモリ効率の比較には,処401 A.2 実験の設定402 理速度計測時の GPU メモリの総使用量をバッチサ
用語
- IOの下界の量化
FlashAttentionのProposition 3はM∈[d,Nd]の全範囲にわたり一様により小さいIOを達成する算法の不存在を述べ、各固定Mでの最適性をそのまま示す文ではありません。原文 2
for all 𝑀 in the range [𝑑, 𝑁 𝑑].
訳この範囲のM全てに対して。
arxiv-2205.14135-flashattention.txt:378-378元のページを開く前後を読む(372〜384行)
372 requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses while the backward pass of FlashAttention requires Θ(𝑁 2 𝑑 2 𝑀 −1 )373 HBM accesses (Appendix B).374 We prove a lower-bound: one cannot asymptotically improve on the number of HBM accesses for all375 values of 𝑀 (the SRAM size) when computing exact attention.376 Proposition 3. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with377 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑. There does not exist an algorithm to compute exact attention with 𝑜(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses378 for all 𝑀 in the range [𝑑, 𝑁 𝑑].379 The proof relies on the fact that for 𝑀 = Θ(𝑁 𝑑) any algorithm must perform Ω(𝑁 2 𝑑 2 𝑀 −1 ) = Ω(𝑁 𝑑)380 HBM accesses. This type of lower bound over a subrange of 𝑀 is common in the streaming algorithms381 literature [88]. We leave proving parameterized complexity [27] lower bounds in terms of 𝑀 as exciting future382 work.383 We validate that the number of HBM accesses is the main determining factor of attention run-time.384 In Fig. 2 (left), we see that even though FlashAttention has higher FLOP count compared to standard
𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.
訳SRAM容量Mの範囲。
arxiv-2205.14135-flashattention.txt:362-362元のページを開く前後を読む(356〜368行)
356 (seq. length 1024, head dim. 64, 16 heads, batch size 64) on A100 GPU. HBM access is the primary factor affecting357 runtime. Middle: Forward runtime of FlashAttention (seq. length 1024, head dim. 64, 16 heads, batch size 64) on358 A100 GPU. Fewer HBM accesses result in faster runtime, up to a point. Right: The runtime (for seq. length 4K) of359 block-sparse FlashAttention is faster than FlashAttention by a factor proportional to the sparsity.361 asymptotically improve on HBM accesses over all SRAM sizes. Proofs are in Appendix C.362 Theorem 2. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.363 Standard attention (Algorithm 0) requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses, while FlashAttention (Algorithm 1)364 requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.365 For typical values of 𝑑 (64-128) and 𝑀 (around 100KB), 𝑑 2 is many times smaller than 𝑀, and thus366 FlashAttention requires many times fewer HBM accesses than standard implementation. This leads to367 both faster execution and lower memory footprint, which we validate in Section 4.3.368 The main idea of the proof is that given the SRAM size of 𝑀, we can load blocks of K, V of size Θ(𝑀) each
- 算術とmemory traffic
FlashAttentionの再計算は演算を追加してもHBMアクセスを節約するため、FLOPsだけでwall-clockを予測する設計とは評価軸が違います。原文 3
we can recompute the
訳再計算できる。
arxiv-2205.14135-flashattention.txt:281-281元のページを開く前後を読む(275〜287行)
275 ℓ(𝑥)276 Therefore if we keep track of some extra statistics (𝑚(𝑥), ℓ(𝑥)), we can compute softmax one block at a time.2277 We thus split the inputs Q, K, V into blocks (Algorithm 1 line 3), compute the softmax values along with278 extra statistics (Algorithm 1 line 10), and combine the results (Algorithm 1 line 12).279 Recomputation. One of our goals is to not store 𝑂 (𝑁 2 ) intermediate values for the backward pass. The280 backward pass typically requires the matrices S, P ∈ R 𝑁 ×𝑁 to compute the gradients with respect to Q, K, V.281 However, by storing the output O and the softmax normalization statistics (𝑚, ℓ), we can recompute the282 attention matrix S and P easily in the backward pass from blocks of Q, K, V in SRAM. This can be seen as a283 form of selective gradient checkpointing [10, 34]. While gradient checkpointing has been suggested to reduce284 the maximum amount of memory required [66], all implementations (that we know off) have to trade speed285 for memory. In contrast, even with more FLOPs, our recomputation speeds up the backward pass due to286 reduced HBM accesses (Fig. 2). The full backward pass description is in Appendix B.287 Implementation details: Kernel fusion. Tiling enables us to implement our algorithm in one
requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.
訳HBMアクセス数はΘ(N²d²/M)。
arxiv-2205.14135-flashattention.txt:364-364元のページを開く前後を読む(358〜370行)
358 A100 GPU. Fewer HBM accesses result in faster runtime, up to a point. Right: The runtime (for seq. length 4K) of359 block-sparse FlashAttention is faster than FlashAttention by a factor proportional to the sparsity.361 asymptotically improve on HBM accesses over all SRAM sizes. Proofs are in Appendix C.362 Theorem 2. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.363 Standard attention (Algorithm 0) requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses, while FlashAttention (Algorithm 1)364 requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.365 For typical values of 𝑑 (64-128) and 𝑀 (around 100KB), 𝑑 2 is many times smaller than 𝑀, and thus366 FlashAttention requires many times fewer HBM accesses than standard implementation. This leads to367 both faster execution and lower memory footprint, which we validate in Section 4.3.368 The main idea of the proof is that given the SRAM size of 𝑀, we can load blocks of K, V of size Θ(𝑀) each369 (Algorithm 1 line 6). For each block of K and V, we iterate over all blocks of Q (Algorithm 1 line 8) to compute370 the intermediate values, resulting in Θ(𝑁 𝑑𝑀 −1 ) passes over Q. Each pass loads Θ(𝑁 𝑑) elements, which
𝑂 (𝑁 2 𝑑) FLOPs
訳演算量はO(N²d)。
arxiv-2205.14135-flashattention.txt:319-319元のページを開く前後を読む(313〜325行)
313 13: Write ℓ𝑖 ← ℓ𝑖new , 𝑚 𝑖 ← 𝑚 𝑖new to HBM.314 14: end for315 15: end for316 16: Return O.318 We show FlashAttention’s correctness, runtime, and memory requirement (proof in Appendix C).319 Theorem 1. Algorithm 1 returns O = softmax(QK> )V with 𝑂 (𝑁 2 𝑑) FLOPs and requires 𝑂 (𝑁) additional320 memory beyond inputs and output.322 3.2 Analysis: IO Complexity of FlashAttention323 We analyze the IO complexity of FlashAttention, showing significant reduction in HBM accesses compared324 to standard attention. We also provide a lower bound, proving that no exact attention algorithm can325 2 This style of aggregation is called algebraic aggregation [33].
- incremental decode
Shazeerの原著の1ステップコードではbhkとbhmkからbhmを作るため、谷口らの式3までN×Nとして説明する箇所を1ステップdecodeの計算量の根拠には採用しません。原文 3
Multi−head S e l f −A t t e n t i o n ( one s t e p ) .
訳多頭自己注意の1ステップ。
arxiv-1911.02150-mqa.txt:169-169元のページを開く前後を読む(163〜175行)
163 efficient parallel implementation similar to that in section 2.3. However, when generating from the trained164 model, the output of the self-attention layer at a particular position affects the token that is generated at165 the next position, which in turn affects the input to that layer at the next position. This prevents parallel166 computation. Code for incrementally computing this self-attention layer is shown below.167 def MultiheadSelfAttentionIncremental (168 x , prev_K , prev_V , P_q , P_k , P_v , P_o ) :169 " " " Multi−head S e l f −A t t e n t i o n ( one s t e p ) .170 Args :171 x : a t e n s o r with sha pe [ b , d ]172 prev_K : t e n s o r with sha pe [ b , h , m, k ]173 prev_V : t e n s o r with sha pe [ b , h , m, v ]174 P_q: a t e n s o r with sha pe [ h , d , k ]175 P_k: a t e n s o r with sha pe [ h , d , k ]
" bhk , bhmk−>bhm"
訳1ステップのqueryと過去キーから長さmのスコアを作る縮約。
arxiv-1911.02150-mqa.txt:190-190元のページを開く前後を読む(184〜196行)
184 new_K = t f . c o n c a t (185 [ prev_K , t f . expand_dims ( t f . einsum ( " bd , hdk−>bhk " , M, P_k) , a x i s = 2 ) ] ,186 a x i s =2)187 new_V = t f . c o n c a t (188 [ prev_V , t f . expand_dims ( t f . einsum ( " bd , hdv−>bhv " , M, P_v) , a x i s = 2 ) ] ,189 a x i s =2)190 l o g i t s = t f . einsum ( " bhk , bhmk−>bhm" , q , new_K)191 w e i g h t s = t f . so ftma x ( l o g i t s )192 o = t f . einsum ( "bhm, bhmv−>bhv " , weig hts , new_V)193 y = t f . einsum ( " bhv , hdv−>bd " , O, P_o)194 r e t u r n y , new_K, new_V
式 1,3 の 計 算 量 は
taniguchi-2025-share-attention.txt:28-28元のページを開く前後を読む(22〜34行)
22 計算量が入力長の 2 乗に比例すること、KV キャッ 算すればよいため生成速度の向上が期待できる。反23 シュのサイズが入力長に比例するという理由によ 面、式 2 のキャッシュサイズは入力長に応じて線形24 り、入力長に対して制限が存在する。本研究では に増加するため、プロンプトが長大な場合はメモリ25 Transformer 内の各レイヤ・各ヘッドについて注意ス (GPU を利用する場合は VRAM) を圧迫する課題が26 コアの分布を調査し、同一レイヤにおいてスコアを 存在している。27 共有できるヘッドが存在すること、また各レイヤに また Q,K,V の作成や FeedForward 処理の計算量28 ついてスコアが大きなトークンが共通していること は O(n) で あ る の に 対 し て、式 1,3 の 計 算 量 は29 を明らかにした。これを元に自己注意処理の効率化 𝑄𝐾 𝑇 ∈ ℝ 𝑁 × 𝑁 のため O(n2 ) となる。そのため既存の30 と KV キャッシュの削減を行い、削減前と比較して Transformer モデルでは、入力長に応じてメモリ使用31 ベンチマークにおける精度低下が限定的であること 量が線形に増加し、また計算量が入力長の二乗に比32 を確認した。 例して大きくなる課題が存在している。33 近年では LLM の活用方法として、本や映画の脚34 1 はじめに 本の要約・複数書類を参照対象とした質問タスクな
- 長文利用能力
Lost in the Middleは入力を受理できる文脈長と情報検索に成功する位置別の能力を実験で分けたもので、対象は質問応答とkey-value検索です。原文 2
swering and key-value retrieval.
訳多文書質問応答とkey-value検索。
liu-2024-lost-middle.txt:23-23元のページを開く前後を読む(17〜29行)
17 ity to take long contexts as input, relatively18 little is known about how well they use nal information (relevant documents from a search19 longer context. We analyze the performance engine, database query results, etc.; Petroni et al.,20 of language models on two tasks that re- 2020; Ram et al., 2023; Shi et al., 2023; Mallen21 quire identifying relevant information in their et al., 2023; Schick et al., 2023, inter alia).22 input contexts: multi-document question an- Handling these use-cases requires language23 swering and key-value retrieval. We find that models to successfully operate over long se-24 performance can degrade significantly when25 quences. Existing language models are generally26 changing the position of relevant information,27 indicating that current language models do not implemented with Transformers (Vaswani et al.,28 robustly make use of information in long in- 2017), which require memory and compute that29 put contexts. In particular, we observe that increases quadratically in sequence length. As
the middle of long contexts
訳長い文脈の中央。
liu-2024-lost-middle.txt:35-35元のページを開く前後を読む(29〜41行)
29 put contexts. In particular, we observe that increases quadratically in sequence length. As30 performance is often highest when relevant in- a result, Transformer language models were of-31 formation occurs at the beginning or end of the ten trained with relatively small context windows32 input context, and significantly degrades when (between 512 and 2048 tokens). Recent improve-33 models must access relevant information in34 ments in hardware (e.g., faster GPUs with more35 the middle of long contexts, even for explicitly36 long-context models. Our analysis provides a memory) and algorithms (Dai et al., 2019; Dao37 better understanding of how language mod- et al., 2022; Poli et al., 2023; Rubin and Berant,38 els use their input context and provides new 2023, inter alia) have resulted in language models39 evaluation protocols for future long-context with larger context windows (e.g., 4096, 32K, and40 language models. even 100K tokens), but it remains unclear how41 these extended-context language models make
論点ごとの解説
知見の集まる用語・人物・媒体はどこか。
所属の確認には本人のPrinceton/Together記載を採用し、著者DBの所属配列の全要素を現在の所属として扱う必要はありません。原文 2
Assistant Professor of Computer Science
訳計算機科学の助教。
dao-2026-home.md:3-3 元のページを開く前後を読む(1〜9行)
1 tri [at] tridao (dot) me3 Assistant Professor of Computer Science at [Princeton University](https://www.cs.princeton.edu/), leading the [Dao AI Lab](https://dao-lab.ai/).4 Co-founder & Chief Scientist of [Together AI](https://together.ai/).6 [CV](https://tridao.me/assets/pdf/cv.pdf) (updated 01/2026)8 Previously: PhD, [Department of Computer Science](https://www-cs.stanford.edu/), [Stanford University](https://www.stanford.edu)Co-founder & Chief Scientist
訳共同創業者・Chief Scientist。
dao-2026-home.md:4-4 元のページを開く前後を読む(1〜10行)
1 tri [at] tridao (dot) me3 Assistant Professor of Computer Science at [Princeton University](https://www.cs.princeton.edu/), leading the [Dao AI Lab](https://dao-lab.ai/).4 Co-founder & Chief Scientist of [Together AI](https://together.ai/).6 [CV](https://tridao.me/assets/pdf/cv.pdf) (updated 01/2026)8 Previously: PhD, [Department of Computer Science](https://www-cs.stanford.edu/), [Stanford University](https://www.stanford.edu)10 ## Research Interests密な自己注意の計算・メモリと、学習・prefill・decode・KVキャッシュはどう違うか。
谷口らの本文は式1と式3を一括で二乗と記述しますが、式3の単一queryとShazeerの縮約形状から、1ステップと生成系列全体を分ける必要があると判断しました。原文 2
式 1,3 の 計 算 量 は
taniguchi-2025-share-attention.txt:28-28 元のページを開く前後を読む(22〜34行)
22 計算量が入力長の 2 乗に比例すること、KV キャッ 算すればよいため生成速度の向上が期待できる。反23 シュのサイズが入力長に比例するという理由によ 面、式 2 のキャッシュサイズは入力長に応じて線形24 り、入力長に対して制限が存在する。本研究では に増加するため、プロンプトが長大な場合はメモリ25 Transformer 内の各レイヤ・各ヘッドについて注意ス (GPU を利用する場合は VRAM) を圧迫する課題が26 コアの分布を調査し、同一レイヤにおいてスコアを 存在している。27 共有できるヘッドが存在すること、また各レイヤに また Q,K,V の作成や FeedForward 処理の計算量28 ついてスコアが大きなトークンが共通していること は O(n) で あ る の に 対 し て、式 1,3 の 計 算 量 は29 を明らかにした。これを元に自己注意処理の効率化 𝑄𝐾 𝑇 ∈ ℝ 𝑁 × 𝑁 のため O(n2 ) となる。そのため既存の30 と KV キャッシュの削減を行い、削減前と比較して Transformer モデルでは、入力長に応じてメモリ使用31 ベンチマークにおける精度低下が限定的であること 量が線形に増加し、また計算量が入力長の二乗に比32 を確認した。 例して大きくなる課題が存在している。33 近年では LLM の活用方法として、本や映画の脚34 1 はじめに 本の要約・複数書類を参照対象とした質問タスクな
" bhk , bhmk−>bhm"
訳1ステップのqueryと過去キーから長さmのスコアを作る縮約。
arxiv-1911.02150-mqa.txt:190-190 元のページを開く前後を読む(184〜196行)
184 new_K = t f . c o n c a t (185 [ prev_K , t f . expand_dims ( t f . einsum ( " bd , hdk−>bhk " , M, P_k) , a x i s = 2 ) ] ,186 a x i s =2)187 new_V = t f . c o n c a t (188 [ prev_V , t f . expand_dims ( t f . einsum ( " bd , hdv−>bhv " , M, P_v) , a x i s = 2 ) ] ,189 a x i s =2)190 l o g i t s = t f . einsum ( " bhk , bhmk−>bhm" , q , new_K)191 w e i g h t s = t f . so ftma x ( l o g i t s )192 o = t f . einsum ( "bhm, bhmv−>bhv " , weig hts , new_V)193 y = t f . einsum ( " bhv , hdv−>bd " , O, P_o)194 r e t u r n y , new_K, new_Vexact attentionのIO最適化は何を減らし、何を減らさず、どのハードウェア条件で成立するか。
FlashAttention-2の約2倍という報告はA100とそのwork partitioningの実験条件の結果であり、全GPUや全decode batchへの倍率保証ではありません。原文 2
2× speedup compared to FlashAttention
訳FlashAttentionに対して約2倍の高速化。
arxiv-2307.08691-flashattention2.txt:30-30 元のページを開く前後を読む(24〜36行)
24 observe that the inefficiency is due to suboptimal work partitioning between different thread blocks and25 warps on the GPU, causing either low-occupancy or unnecessary shared memory reads/writes. We propose26 FlashAttention-2, with better work partitioning to address these issues. In particular, we (1) tweak27 the algorithm to reduce the number of non-matmul FLOPs (2) parallelize the attention computation, even28 for a single head, across different thread blocks to increase occupancy, and (3) within each thread block,29 distribute the work between warps to reduce communication through shared memory. These yield around30 2× speedup compared to FlashAttention, reaching 50-73% of the theoretical maximum FLOPs/s on31 A100 and getting close to the efficiency of GEMM operations. We empirically validate that when used32 end-to-end to train GPT-style models, FlashAttention-2 reaches training speed of up to 225 TFLOPs/s33 per A100 GPU (72% model FLOPs utilization).136 1 IntroductionA100 and getting close to the efficiency of GEMM operations.
訳A100でGEMMの効率に近づく。
arxiv-2307.08691-flashattention2.txt:31-31 元のページを開く前後を読む(25〜37行)
25 warps on the GPU, causing either low-occupancy or unnecessary shared memory reads/writes. We propose26 FlashAttention-2, with better work partitioning to address these issues. In particular, we (1) tweak27 the algorithm to reduce the number of non-matmul FLOPs (2) parallelize the attention computation, even28 for a single head, across different thread blocks to increase occupancy, and (3) within each thread block,29 distribute the work between warps to reduce communication through shared memory. These yield around30 2× speedup compared to FlashAttention, reaching 50-73% of the theoretical maximum FLOPs/s on31 A100 and getting close to the efficiency of GEMM operations. We empirically validate that when used32 end-to-end to train GPT-style models, FlashAttention-2 reaches training speed of up to 225 TFLOPs/s33 per A100 GPU (72% model FLOPs utilization).136 1 Introduction37 Scaling up the context length of Transformers [18] is a challenge, since the attention layer at their heartexact attentionのIO最適化は何を減らし、何を減らさず、どのハードウェア条件で成立するか。
FlashAttention原著のLRA比較ではPerformerを混合精度から除外しており、手法だけでなくdtypeと実装安定性も速度比較の交絡要因として残ります。原文 1
except for Performer (not stable with mixed precision)
訳Performerは混合精度で安定しないため例外とした。
arxiv-2205.14135-flashattention.txt:1593-1593 元のページを開く前後を読む(1587〜1599行)
1587 //github.com/google-research/long-range-arena), and the Nyströmformer reproduction [90]. To be1588 generous to the baseline methods, if we are unable to reproduce the performance of any baseline for any of1589 the five tasks, we report the better performance from Tay et al. [80] or Xiong et al. [90] for that baseline on1590 that task.1591 After hyperparameter tuning, almost all of the attention methods achieve similar accuracy on all of the1592 five LRA tasks.1593 We run all methods with mixed-precision training, except for Performer (not stable with mixed precision)1594 and Local Attention (implementation does not support FP16).1595 To calculate the overall wallclock-time speedup, we take the geometric mean of the wallclock-time speedup1596 of each of the five tasks.1598 Path-X For Path-X and Path-256, we follow the hyperparameters from the PathFinder-32 experiments1599 from the long-range arena paper[80]. For both, we first pretrain a model on Path-64. We take the checkpointsparse/local/global attentionはどの接続・窓幅条件で長文を扱い、何を失うか。
BigBirdのTuring completenessの説明には任意精度という仮定があり、有限精度・有限深さの実用モデルの精度がdenseと同じになるという保証へは拡張できません。原文 2
model works on arbitrary precision model.
訳モデルが任意精度を扱うという仮定。
arxiv-2007.14062-bigbird.txt:305-305 元のページを開く前後を読む(299〜311行)
299 3.3 Turing Completeness300 Transformers are a very general class. In the original paper of Vaswani et al. [91], they were used in301 both an encoder and a decoder. While the previous section outlined how powerful just the encoders302 were, another natural question is to ask what the additional power of both a decoder along with303 an encoder is? Pérez et al. [72] showed that the full transformer based on a quadratic attention304 mechanism is Turing Complete. This result makes one unrealistic assumption, which is that the305 model works on arbitrary precision model. Of course, this is necessary as otherwise, Transformers306 are bounded finite state machines and cannot be Turing Complete.307 It is natural to ask if the full attention mechanism is necessary. Or can a sparse attention mechanism308 also be used to simulate any Turing Machine? We show that this is indeed the case: we can use a309 sparse encoder and sparse decoder to simulate any Turing Machine.310 To use the sparse attention mechanism in the transformer architecture, we need to define a suitable311 modification where each token only reacts to previous tokens. Unlike the case for BERT, where theany sparse attention layers with Õ(n) edges
訳辺数がほぼ線形のあらゆる疎な注意層。
arxiv-2007.14062-bigbird.txt:322-322 元のページを開く前後を読む(316〜328行)
316 their addressing scheme to point back in history (Lemma B.4 in [72]). We show how to simulate this317 using a sparse attention mechanism and defer the details to App. B.319 3.4 Limitations320 We demonstrate a natural task which can be solved by the full attention mechanism in O(1)-layers.321 However, under standard complexity theoretic assumptions, this problem requires Ω̃(n)-layers for322 any sparse attention layers with Õ(n) edges (not just B IG B IRD). (Here Õ hides poly-logarthmic323 factors). Consider the simple problem of finding the corresponding furthest vector for each vector in324 the given sequence of length n. Formally,325 Task 1. Given n unit vectors {u1 , . . . , un }, find f (u1 , . . . , un ) → (u1∗ , . . . , un∗ ) where for a fixed326 j ∈ [n], we define j ∗ = arg maxk kuk − uj k22 .327 Finding vectors that are furthest apart boils down to minimize inner product search in case of unit328 vectors. For a full-attention mechanism with appropriate query and keys, this task is very easy as welinear/低ランク近似は何を仮定し、どの精度・表現力の制約を持つか。
Performerは系列長Lに依存しない特徴数の議論でも次元・ノルム半径・精度を条件にしており、固定特徴数で分布を変えた際の精度維持は別に検証すべきです(保証の適用範囲からの判断)。原文 2
queries/keys are upper-bounded by R > 0.
訳query/keyのノルムがRで上から抑えられる。
arxiv-2009.14794-performer.txt:394-394 元のページを開く前後を読む(388〜400行)
388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 trig398 lowing holds for the attention approximation mechanism leveraging estimators SM399 d with ORFs:400 kAb − Ak∞ ≤ with any constant probability, where Ab approximates the attention matrix A.but does not depend on input sequence length L.
訳入力系列長Lには依存しない。
arxiv-2009.14794-performer.txt:391-391 元のページを開く前後を読む(385〜397行)
386 We see that ORFs provide exponentially small and sharper bounds for critical regions where the387 softmax-kernel is small. Below we show that even for the SMtrig mechanism with ORFs, it suffices to388 take m = Θ(d log(d)) random projections to accurately approximate the attention matrix (thus if not389 attention renormalization, PRFs would not be needed). In general, m depends on the dimensionality390 d of the embeddings, radius R of the ball where all queries/keys live and precision parameter (see:391 Appendix F.6 for additional discussion), but does not depend on input sequence length L.392 Theorem 4 (uniform convergence for attention approximation). Assume that L2 -norms of393 1 2394 queries/keys are upper-bounded by R > 0. Define l = Rd− 4 and take h∗ = exp( l2 ). Then395 3396 for any > 0, δ = (h∗ )2 and the number of random projections m = Θ( δd2 log( 4dδ4 R )) the fol-397 triglinear/低ランク近似は何を仮定し、どの精度・表現力の制約を持つか。
LinformerのO(nk)という形から、kもnとともに増やす設定では系列長だけについての線形性をそのまま称せないと分かります。原文 1
operations only require O(nk) time and space complexity.
訳必要な時間・空間はO(nk)。
arxiv-2006.04768-linformer.txt:313-313 元のページを開く前後を読む(307〜319行)
307 = softmax √ · Fi V WiV , (7)308 dk | {z }309 | {z } k×d310 P̄ :n×k312 Finally, we compute context embeddings for each headi using P̄ · (Fi V WiV ). Note the above313 operations only require O(nk) time and space complexity. Thus, if we can choose a very small314 projected dimension k, such that k n, then we can significantly reduce the memory and space315 consumption. The following theorem states that, when k = O(d/2 ) (independent of n), one can316 approximate P · V WiV using linear self-attention (7) with error.317 Theorem 2. (Linear self-attention) For any Qi , Ki , Vi ∈ Rn×d and WiQ , WiK , WiV ∈ Rd×d , if318 k = min{Θ(9d log(d)/2 ), 5Θ(log(n)/2 )}, then√ there exists matrices Ei , Fi ∈ R319 n×k日本語の実践知と原著の実験を照合すると、実装・KVキャッシュ・長文評価をどう選び、どこまで一般化できるか。
Flashbackの4倍以上・77%削減は、日本語版で示されたA100、共通学習長2048、batch最適化の条件付きの結果として読むべきです。原文 4
4 倍以上の高速化と 77 [%]
sekii-2025-flashback.txt:268-268 元のページを開く前後を読む(262〜274行)
262 Forward Networks(FFN)を表す関数である. 価する.その他の実験の設定の詳細については,付263 2.4 Flashback 特性に基づく DNN アーキ 録 A を参照されたい.264 テクチャ 従 来 手 法 に Flashback 機 構 を 導 入 し た 際 の 性 能265 本 稿 で は,Transformers と Mamba そ れ ぞ れ に の変化を評価した結果を図 3 に示す.同図より,266 Flashback 機構を統合した DNN アーキテクチャを提 Transformer++(1.3B)に Flashback 機 構 を 導 入 し,267 案する.Transformers アーキテクチャのベースとし SWA により計算量を抑制することで,常識推論精度268 て,Transformer++ [5](LLaMa アーキテクチャ)を の向上とともに,4 倍以上の高速化と 77 [%] のメモ269 用いる.Transformers アーキテクチャでは,FFN を リ使用量の削減の効果が現れている.また,Mamba270 含む Attention 機構を一組のブロックとして扱う. (1.3B)に Flashback 機構を導入することで,16 [%]271 また Mamba では,SSM アーキテクチャを一組の の高速化と 38 [%] のメモリ使用量の削減を同時に実272 ブ ロ ッ ク と す る.図 2 に Flashback 機 構 を 統 合 し 現している.以上を踏まえると,1 章の MCNN の課273 た Transformer++と Mamba の ア ー キ テ ク チ ャ を 示 題 1〜3 に対し,提案手法が次トークン予測のため274 す.Transformer++・Mamba の偶数番目のブロック の記憶機構として効率的に動作することがわかる.
同一の NVIDIA A100 GPU
sekii-2025-flashback.txt:392-392 元のページを開く前後を読む(386〜398行)
386 層系列処理モデルの従来研究において近年広く利用 一致するよう調整した.387 されている.具体的には,22 のサブセットから構成388 されており,総容量は 800 [GB] に及ぶ.これらのサ A.2.1 評価方法389 ブセットには,論文,書籍,プログラム,技術文書 各データセットで用いられる評価指標について390 などが含まれ,多岐にわたる種類のテキストデータ は,Arora ら [26] と同一のものを用いているため,詳391 を用いて言語モデルの汎化性を評価することがで 細は文献を参照されたい.各手法の性能を公平に比392 きる. 較するため,学習と評価に同一の NVIDIA A100 GPU393 を用いた.各手法の処理速度の比較には,単位時間394 A.1.2 評価データ あたりのトークン生成のスループット(Tok./ms)を395 LM-Eval Harness [33] は,EleutherAI によって提供 用いる.処理速度の計測時には,各手法のバッチサ396 されている標準化されたベンチマークである.本実 イズを,実行可能な範囲でスループットが最大にな397 験では,表 1 に示す複数のデータセットを評価に用 るよう調整した.これは,手法間の計算特性やハー398 いた.なお,図 3 に示した常識推論精度は,これら ドウェア利用効率の違いを考慮し,各手法の性能を
の 2048 に設定した.
sekii-2025-flashback.txt:412-412 元のページを開く前後を読む(406〜418行)
406 ン分のテキストを同じ順序で学習した.これらのテ 本実験では,従来研究における主要なベースライ407 キストは,GPT-2 BPE トークナイザーを用いてトー ン手法 [5, 25] を選択し,その性能を提案手法と比較408 クン化された.Attention 機構を用いる手法では,学 した.Transformer++ [5] は Rotary Encoding による位409 習と評価に FlashAttention-2 [34] を用いた.学習時の 置埋め込みと Gated Linear Unit を Transformers に追410 バッチサイズは各手法でメモリ使用量が最大になる 加したものである.Mamba [25] は,重要な情報を入411 よう調整した.学習時の入力の系列長は各手法共通 力に依存して選択的に隠れ状態に保存できる SSM412 の 2048 に設定した. の最新の手法である.417 ― 3394 ― This work is licensed by the author(s) under CC BY 4.0418 (https://creativecommons.org/licenses/by/4.0/).
スループットが最大にな
sekii-2025-flashback.txt:396-396 元のページを開く前後を読む(390〜402行)
390 などが含まれ,多岐にわたる種類のテキストデータ は,Arora ら [26] と同一のものを用いているため,詳391 を用いて言語モデルの汎化性を評価することがで 細は文献を参照されたい.各手法の性能を公平に比392 きる. 較するため,学習と評価に同一の NVIDIA A100 GPU393 を用いた.各手法の処理速度の比較には,単位時間394 A.1.2 評価データ あたりのトークン生成のスループット(Tok./ms)を395 LM-Eval Harness [33] は,EleutherAI によって提供 用いる.処理速度の計測時には,各手法のバッチサ396 されている標準化されたベンチマークである.本実 イズを,実行可能な範囲でスループットが最大にな397 験では,表 1 に示す複数のデータセットを評価に用 るよう調整した.これは,手法間の計算特性やハー398 いた.なお,図 3 に示した常識推論精度は,これら ドウェア利用効率の違いを考慮し,各手法の性能を399 のデータセットに対する精度の平均である. 最大限に引き出すことで公平な比較を実現するため400 である.また,各手法のメモリ効率の比較には,処401 A.2 実験の設定402 理速度計測時の GPU メモリの総使用量をバッチサ
日本語の実践知と原著の実験を照合すると、実装・KVキャッシュ・長文評価をどう選び、どこまで一般化できるか。
Liuらの位置効果はMPT・LongChat等を含む当時のモデル群の実験であり、最新モデルでの未検証部分を残して、位置を動かす評価設計を取り入れるのが妥当です(適用範囲からの提案)。原文 2
MPT-30B-Instruct, LongChat-13B
訳評価対象の公開モデル例。
liu-2024-lost-middle.txt:47-47 元のページを開く前後を読む(41〜53行)
41 these extended-context language models make42 use of their input contexts when performing43 downstream tasks.44 1 Introduction45 We empirically investigate this question via46 Language models have become an important and controlled experiments with a variety of state-of-47 flexible building block in a variety of user-facing the-art open (MPT-30B-Instruct, LongChat-13B48 language technologies, including conversational (16K)) and closed (OpenAI’s GPT-3.5-Turbo and49 interfaces, search and summarization, and collab- Anthropic’s Claude-1.3) language models in set-50 orative writing (Shuster et al., 2022; Thoppilan tings that require accessing and using information51 et al., 2022; Lee et al., 2022, inter alia). These within an input context. In particular, our ex-52 models perform downstream tasks primarily via periments make controlled changes to the input53 prompting: all relevant task specification and data context size and the position of the relevantthe middle of long contexts
訳長い文脈の中央。
liu-2024-lost-middle.txt:35-35 元のページを開く前後を読む(29〜41行)
29 put contexts. In particular, we observe that increases quadratically in sequence length. As30 performance is often highest when relevant in- a result, Transformer language models were of-31 formation occurs at the beginning or end of the ten trained with relatively small context windows32 input context, and significantly degrades when (between 512 and 2048 tokens). Recent improve-33 models must access relevant information in34 ments in hardware (e.g., faster GPUs with more35 the middle of long contexts, even for explicitly36 long-context models. Our analysis provides a memory) and algorithms (Dai et al., 2019; Dao37 better understanding of how language mod- et al., 2022; Poli et al., 2023; Rubin and Berant,38 els use their input context and provides new 2023, inter alia) have resulted in language models39 evaluation protocols for future long-context with larger context windows (e.g., 4096, 32K, and40 language models. even 100K tokens), but it remains unclear how41 these extended-context language models make理解の確認
FlashAttentionのIO下界から、どの固定SRAM容量でも最適と結論できますか。
答えを見る
原著の否定命題は範囲内の全Mで一様に漸近改善するアルゴリズムに対するものであり、量化を各Mに入れ替えることはできません。原文 2
for all 𝑀 in the range [𝑑, 𝑁 𝑑].
訳この範囲のM全てに対して。
arxiv-2205.14135-flashattention.txt:378-378 元のページを開く前後を読む(372〜384行)
372 requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses while the backward pass of FlashAttention requires Θ(𝑁 2 𝑑 2 𝑀 −1 )373 HBM accesses (Appendix B).374 We prove a lower-bound: one cannot asymptotically improve on the number of HBM accesses for all375 values of 𝑀 (the SRAM size) when computing exact attention.376 Proposition 3. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with377 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑. There does not exist an algorithm to compute exact attention with 𝑜(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses378 for all 𝑀 in the range [𝑑, 𝑁 𝑑].379 The proof relies on the fact that for 𝑀 = Θ(𝑁 𝑑) any algorithm must perform Ω(𝑁 2 𝑑 2 𝑀 −1 ) = Ω(𝑁 𝑑)380 HBM accesses. This type of lower bound over a subrange of 𝑀 is common in the streaming algorithms381 literature [88]. We leave proving parameterized complexity [27] lower bounds in terms of 𝑀 as exciting future382 work.383 We validate that the number of HBM accesses is the main determining factor of attention run-time.384 In Fig. 2 (left), we see that even though FlashAttention has higher FLOP count compared to standard𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.
訳SRAM容量Mの範囲。
arxiv-2205.14135-flashattention.txt:362-362 元のページを開く前後を読む(356〜368行)
356 (seq. length 1024, head dim. 64, 16 heads, batch size 64) on A100 GPU. HBM access is the primary factor affecting357 runtime. Middle: Forward runtime of FlashAttention (seq. length 1024, head dim. 64, 16 heads, batch size 64) on358 A100 GPU. Fewer HBM accesses result in faster runtime, up to a point. Right: The runtime (for seq. length 4K) of359 block-sparse FlashAttention is faster than FlashAttention by a factor proportional to the sparsity.361 asymptotically improve on HBM accesses over all SRAM sizes. Proofs are in Appendix C.362 Theorem 2. Let 𝑁 be the sequence length, 𝑑 be the head dimension, and 𝑀 be size of SRAM with 𝑑 ≤ 𝑀 ≤ 𝑁 𝑑.363 Standard attention (Algorithm 0) requires Θ(𝑁 𝑑 + 𝑁 2 ) HBM accesses, while FlashAttention (Algorithm 1)364 requires Θ(𝑁 2 𝑑 2 𝑀 −1 ) HBM accesses.365 For typical values of 𝑑 (64-128) and 𝑀 (around 100KB), 𝑑 2 is many times smaller than 𝑀, and thus366 FlashAttention requires many times fewer HBM accesses than standard implementation. This leads to367 both faster execution and lower memory footprint, which we validate in Section 4.3.368 The main idea of the proof is that given the SRAM size of 𝑀, we can load blocks of K, V of size Θ(𝑀) each日本語の計算量説明と速度の結論をどのように監査しましたか。
答えを見る
谷口らの1ステップdecodeの行列形状をMQA原著と照合し、さらに同論文が生成速度未計測と明記している点を区別しました。原文 3
式 1,3 の 計 算 量 は
taniguchi-2025-share-attention.txt:28-28 元のページを開く前後を読む(22〜34行)
22 計算量が入力長の 2 乗に比例すること、KV キャッ 算すればよいため生成速度の向上が期待できる。反23 シュのサイズが入力長に比例するという理由によ 面、式 2 のキャッシュサイズは入力長に応じて線形24 り、入力長に対して制限が存在する。本研究では に増加するため、プロンプトが長大な場合はメモリ25 Transformer 内の各レイヤ・各ヘッドについて注意ス (GPU を利用する場合は VRAM) を圧迫する課題が26 コアの分布を調査し、同一レイヤにおいてスコアを 存在している。27 共有できるヘッドが存在すること、また各レイヤに また Q,K,V の作成や FeedForward 処理の計算量28 ついてスコアが大きなトークンが共通していること は O(n) で あ る の に 対 し て、式 1,3 の 計 算 量 は29 を明らかにした。これを元に自己注意処理の効率化 𝑄𝐾 𝑇 ∈ ℝ 𝑁 × 𝑁 のため O(n2 ) となる。そのため既存の30 と KV キャッシュの削減を行い、削減前と比較して Transformer モデルでは、入力長に応じてメモリ使用31 ベンチマークにおける精度低下が限定的であること 量が線形に増加し、また計算量が入力長の二乗に比32 を確認した。 例して大きくなる課題が存在している。33 近年では LLM の活用方法として、本や映画の脚34 1 はじめに 本の要約・複数書類を参照対象とした質問タスクな
" bhk , bhmk−>bhm"
訳1ステップのqueryと過去キーから長さmのスコアを作る縮約。
arxiv-1911.02150-mqa.txt:190-190 元のページを開く前後を読む(184〜196行)
184 new_K = t f . c o n c a t (185 [ prev_K , t f . expand_dims ( t f . einsum ( " bd , hdk−>bhk " , M, P_k) , a x i s = 2 ) ] ,186 a x i s =2)187 new_V = t f . c o n c a t (188 [ prev_V , t f . expand_dims ( t f . einsum ( " bd , hdv−>bhv " , M, P_v) , a x i s = 2 ) ] ,189 a x i s =2)190 l o g i t s = t f . einsum ( " bhk , bhmk−>bhm" , q , new_K)191 w e i g h t s = t f . so ftma x ( l o g i t s )192 o = t f . einsum ( "bhm, bhmv−>bhv " , weig hts , new_V)193 y = t f . einsum ( " bhv , hdv−>bd " , O, P_o)194 r e t u r n y , new_K, new_V計測を行っていない。
taniguchi-2025-share-attention.txt:193-193 元のページを開く前後を読む(187〜199行)
187 見受けられた。これは最終レイヤは回答精度につい を併用した場合については、p=0.95(伝搬するトーク188 てはそこまで重要ではないが、回答フォーマットに ンは1割程度), ヘッドを 3 割程度削っても基準モデ189 ついては重要な決定権を持っているためと考えら ルと比較して 8 割程度のスコアを維持できているこ190 れる。 とが確認できた。191 上記考察を踏まえ、Longbench を実行する際は前 生成速度については、CUDA に最適化されている192 半と後半レイヤについては th を小さく・中盤レイヤ 手法である Flash_Attention[6] に Share-Attention 機能193 では大きく設定を行い共有ヘッド数を変化させて検 を追加できていないため計測を行っていない。本手194 証を行った。このときの各レイヤにおけるヘッド維 法により計算量は削減されているため CPU 上での195 持率 (retention rate, 100× 計算を行うヘッド数/本来の 動作では高速化が可能であり、また GPU 上での動196 ヘッド数) を付録 B の図 7 に、検証結果を表 1 に表 作においては Flash_Attention を Share-Attention に対197 した。 応させることで高速化が可能であると思われる。198 表より、QA タスクである Qasper,2wikiqa,Hotpotqa また本実験では Longbench 内の平均長が 10k 程199 ではヘッド維持率が低下するにつれてスコアが下 度 の タ ス ク を 利 用 し て 検 証 を 行 っ た。こ の 理 由
主な人物と媒体
Tri Daoは本人サイトでPrincetonの助教とTogether AIの共同創業者・Chief Scientistを名乗っています。原文 2
Assistant Professor of Computer Science
訳計算機科学の助教。
dao-2026-home.md:3-3 元のページを開く前後を読む(1〜9行)
1 tri [at] tridao (dot) me3 Assistant Professor of Computer Science at [Princeton University](https://www.cs.princeton.edu/), leading the [Dao AI Lab](https://dao-lab.ai/).4 Co-founder & Chief Scientist of [Together AI](https://together.ai/).6 [CV](https://tridao.me/assets/pdf/cv.pdf) (updated 01/2026)8 Previously: PhD, [Department of Computer Science](https://www-cs.stanford.edu/), [Stanford University](https://www.stanford.edu)Co-founder & Chief Scientist
訳共同創業者・Chief Scientist。
dao-2026-home.md:4-4 元のページを開く前後を読む(1〜10行)
1 tri [at] tridao (dot) me3 Assistant Professor of Computer Science at [Princeton University](https://www.cs.princeton.edu/), leading the [Dao AI Lab](https://dao-lab.ai/).4 Co-founder & Chief Scientist of [Together AI](https://together.ai/).6 [CV](https://tridao.me/assets/pdf/cv.pdf) (updated 01/2026)8 Previously: PhD, [Department of Computer Science](https://www-cs.stanford.edu/), [Stanford University](https://www.stanford.edu)10 ## Research Interests釜堀圭祐はワシントン大学/Kotoba Technologiesの機械学習システム研究開発者としてServing技術を日本語で解説し、PagedAttention原著へリンクしています。原文 2
専門は機械学習システムで、LLMなどの推論を効率化する技術を研究・開発しています。
kamahori-2025-serving.md:20-20 元のページを開く前後を読む(14〜26行)
14 [llm](https://zenn.dev/topics/llm)16 [推論システム](https://zenn.dev/topics/%E6%8E%A8%E8%AB%96%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0)18 [tech](https://zenn.dev/tech-or-idea)20 ワシントン大学/Kotoba Technologiesの[釜堀](https://kamahori.org/)です。専門は機械学習システムで、LLMなどの推論を効率化する技術を研究・開発しています。22 現代のLLMは莫大な計算・メモリを要するため、LLMを使ったサービスを提供する際には推論の効率性が非常に重要です。この分野はここ数年活発に研究されていて、[vLLM](https://github.com/vllm-project/vllm)や[SGLang](https://github.com/sgl-project/sglang)など非常に高性能なOSSも出てきています。LLMのservingは、コンピュータサイエンスの知見を総動員させて最適化されている奥深い世界ですが、一方で中身を理解するには多くの前提知識が必要です。24 そこでこの記事ではTransformerモデルを中心に、LLMのserving system(多数のクライアントにLLM推論を提供するシステム)でどのようなテクニックが使われているのかについて体系的に解説していきます。26 構成としては、LLM servingで最も重要な概念である「バッチ推論」と「KVキャッシュマネジメント」について、現代のserving systemの基礎となっている技術を紹介します。さらに、「実装の工夫」「アルゴリズムの工夫」「モデルアーキテクチャの工夫」「分散処理」という4つの軸で、より細かく様々な技術について見ていきます。面白そうなところだけでもつまみ食いしていただければと思います。
vLLMの元論文で提案された[PagedAttention]
kamahori-2025-serving.md:130-130 元のページを開く前後を読む(124〜136行)
125 で、最大コンテクスト長は4096のため、本当に必要とするトークン数によらず、1リクエストあたり512KB x 4096 = 2GBものメモリが必要です。これは例えば80GBメモリを持つH100であっても、30リクエストほどしか同時に処理できない計算になります[2][3]。より最近のモデルではコンテクスト長が数十万以上になり、この実装は非現実的です。127 ###128 3.1. PagedAttention130 この問題を改善したのが、vLLMの元論文で提案された[PagedAttention](https://arxiv.org/abs/2309.06180)です。これは古典的なOSにおける[ページング](https://ja.wikipedia.org/wiki/%E3%83%9A%E3%83%BC%E3%82%B8%E3%83%B3%E3%82%B0%E6%96%B9%E5%BC%8F)に着想を得て、KVキャッシュを仮想アドレス空間と物理アドレス空間に分ける手法です。132 [https://arxiv.org/pdf/2309.06180](https://arxiv.org/pdf/2309.06180)134 上図中央にある物理 KV ブロックはあらかじめ固定サイズに分割されたバッファです。この例では、リクエストAが3個の、リクエストBが2個のブロックを必要としています。各リクエストには論理ブロックとして連続しているように見えていますが、実際にはバラバラの領域に保存されています。たとえばリクエストAは物理ブロックの1、7、3を、Bは5、2を使っています。実際にメモリアクセスが発生した際は、仮想アドレスから物理アドレスへ変換されます。136 リクエストが終了した際は、そのリクエストが保有していた物理ブロックが解放され、他のリクエストが使うことができるようになります。そのためメモリの[フラグメンテーション](https://ja.wikipedia.org/wiki/%E3%83%95%E3%83%A9%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3)が発生せず、バッチサイズを最大まで増やして推論効率を上げることができます。
関井大気のFlashbackは日本語の言語処理学会版に加えてCOLING原著があり、The Pileによる学習実験を記載しています。原文 2
Taiki Sekii
訳著者: 関井大気。
sekii-2025-flashback-coling.txt:4-4 元のページを開く前後を読む(1〜10行)
1 F LASHBACK: Memory Mechanism for Enhancing Memory Efficiency and2 Speed in Deep Sequential Models4 Taiki Sekii5 CyberAgent6 taiki.sekii@gmail.com10 Abstract OpenAI et al., 2024). Such models are highly scal-tasks. In experiments, we trained on The Pile
訳実験ではThe Pileで学習した。
sekii-2025-flashback-coling.txt:29-29 元のページを開く前後を読む(23〜35行)
23 a Flashback mechanism that satisfies this prop- struggle to retain this external memory beyond a24 erty in a fully differentiable, end-to-end man- certain capacity due to their architectural character-25 ner. Further, to tackle (3), we propose archi- istics stemming from the computational and mem-26 tectures that incorporate the Flashback mecha- ory costs that increase with the length of input27 nism into Transformers and Mamba, enabling sequences in attention mechanisms (Vaswani et al.,28 next-token prediction for language modeling 2017; Dai et al., 2019). Two general approaches29 tasks. In experiments, we trained on The Pile30 have been explored to address this issue: (1) imple-31 dataset, which includes diverse texts, to evalu-32 ate tradeoffs between commonsense reasoning menting memory mechanisms on the application33 accuracy, processing speed, and memory usage side or (2) integrating memory capabilities within34 after introducing the Flashback mechanism into the DNN architecture.35 existing methods. The evaluations confirmed The first approach involves enhancing appli-未解決の点
- 19資料の範囲で論点を充足した。全効率化手法を網羅した系統的レビューではない。
- 今回GPUで独自のベンチマーク再現はしていない。ハードウェア、batch、入力長、出力長、dtypeを揃えた速度順位は未確定。
- FlashAttention-3/4、最新のhybrid/linear法、位置外挿・RoPE拡張の全原著は未読。公式READMEの対応状況と、論文の性能主張を区別した。
- Lost in the Middleの知見を2026年の全モデル・全タスクに一般化できない。最新モデルでの位置別検索、複数根拠統合、要約の再評価は残る。
- 日本語YouTube、PFNの本人実測記事、関井本人の個人サイト・公開コードは今回特定していない。
- OpenAlexには題名・年・DOIの不整合があった。全引用網の完全性、著者記録の所属配列、引用数の精度は未解決。本文で確認したリンクだけを採用した。
- 有料・ログイン必須で未取得の中核原典は今回ない。保存資料の日本語OCRは不要であり、スキャン資料のOCR品質は未検証。
調査記録自動生成
検索 15本・ヒット 318件・空振り 1本
参照したサイト
| サイト | ヒット | 保存 | 失敗 | |
|---|---|---|---|---|
| doi.org | 47 | 2 | ||
| reddit.com | 42 | |||
| arxiv.org | 29 | |||
| en.wikipedia.org | 13 | |||
| huggingface.co | 13 | |||
| github.com | 12 | |||
| openreview.net | 8 | |||
| research.google | 8 | |||
| aclanthology.org | 6 | 1 | ||
| zenn.dev | 6 | 1 |
ほか 93 サイト
| サイト | ヒット | 保存 | 失敗 | |
|---|---|---|---|---|
| alphaxiv.org | 5 | |||
| hatohato.jp | 4 | |||
| researchgate.net | 4 | |||
| thetrail.jp | 4 | |||
| anlp.jp | 3 | 3 | ||
| asabook.cc | 3 | |||
| mext.go.jp | 3 | |||
| papers.neurips.cc | 3 | |||
| tridao.me | 3 | |||
| zh.wikipedia.org | 3 | |||
| arxiv.deeppaper.ai | 2 | |||
| d2l.smola.org | 2 | |||
| gwern.net | 2 | |||
| jedworkshop.github.io | 2 | |||
| mlanthology.org | 2 | |||
| mlsanity.com | 2 | |||
| patents.google.com | 2 | |||
| pith.science | 2 | |||
| pmc.ncbi.nlm.nih.gov | 2 | |||
| proceedings.iclr.cc | 2 | |||
| proceedings.mlr.press | 2 | |||
| proceedings.neurips.cc | 2 | |||
| sampooni.github.io | 2 | |||
| scixa.com | 2 | |||
| sebastianraschka.com | 2 | |||
| theatlantic.com | 2 | |||
| 3dvar.com | 1 | |||
| accelresearching.com | 1 | |||
| actionbridge.io | 1 | |||
| ai-research-site.jp | 1 | |||
| ai.lab.uec.ac.jp | 1 | |||
| aman.ai | 1 | |||
| arxivlens.com | 1 | |||
| ashwanijha.dev | 1 | |||
| bowdbeg.github.io | 1 | |||
| brainailab.com | 1 | |||
| center.nitech.ac.jp | 1 | |||
| conftrace.com | 1 | |||
| cs.stanford.edu | 1 | |||
| cse.iitd.ac.in | 1 | |||
| csie.ntu.edu.tw | 1 | |||
| dao-lab.ai | 1 | |||
| dblp.org | 1 | |||
| dbsj.org | 1 | |||
| de.wikipedia.org | 1 | |||
| deepsense.ai | 1 | |||
| direct.mit.edu | 1 | |||
| discuss.google.dev | 1 | |||
| dspace.jaist.ac.jp | 1 | |||
| eiler2005.github.io | 1 | |||
| es.wikipedia.org | 1 | |||
| explore.openaire.eu | 1 | |||
| fc-datascience.com | 1 | |||
| hazyresearch.stanford.edu | 1 | |||
| ibm.com | 1 | |||
| iclr-blogposts.github.io | 1 | |||
| issoh.co.jp | 1 | |||
| it.wikipedia.org | 1 | |||
| ithub.global.ssl.fastly.net | 1 | |||
| jstage.jst.go.jp | 1 | |||
| kvcache.cobanov.dev | 1 | |||
| labhub.hopto.org | 1 | |||
| lacuna.tiptreesystems.com | 1 | |||
| lassic.co.jp | 1 | |||
| livescience.com | 1 | |||
| lizeman.github.io | 1 | |||
| localmodelwatch.tsuchitsuchi.com | 1 | |||
| media.tcdigital.jp | 1 | |||
| microsoft.com | 1 | |||
| mouseionagentica.org | 1 | |||
| ndlsearch.ndl.go.jp | 1 | |||
| neurips2023-enlsp.github.io | 1 | |||
| newyorker.com | 1 | |||
| papers.cool | 1 | |||
| papers.nips.cc | 1 | |||
| people.iiis.tsinghua.edu.cn | 1 | |||
| podcast.do-not-panic.com | 1 | |||
| pt.wikipedia.org | 1 | |||
| pypi.org | 1 | |||
| qiita.com | 1 | |||
| rajeshrmahapatra.com | 1 | |||
| raw.githubusercontent.com | 1 | |||
| scribd.com | 1 | |||
| shop.zimaspace.com | 1 | |||
| t.co | 1 | |||
| theguardian.com | 1 | |||
| themoonlight.io | 1 | |||
| theverge.com | 1 | |||
| together.ai | 1 | |||
| transacl.org | 1 | |||
| troy-technical.jp | 1 | |||
| wired.com | 1 | |||
| www-cs.stanford.edu | 1 |
検索語別の全結果
0周目(検索 5本・ヒット 157件)
「Transformer long sequence self attention quadratic complexity FlashAttention」
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FLASHATTENTION: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 Fast Attention Over Long Sequences With Dynamic Sparse Flash Attention
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention
- 未取得 FLASHATTENTION: Fast and
- 未取得 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness | ML Anthology
- 未取得 I/O Complexity of Attention, or How Optimal is FlashAttention?
- 未取得 An Introduction to FlashAttention
- 未取得 Paper page - FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 The Evolution of FlashAttention | ICLR Blogposts 2026
- 未取得 Inside Google’s Gemini 3.8 Flash and FlashAttention-3: The Hardware Physics of 2M Tokens - Community Articles - Google Developer forums
- 未取得 Optimizing LLMs for Speed and Memory · Hugging Face
- 未取得 The Cost of Attention
- 未取得 The Cost of Attention
- 未取得 Faster Causal Attention Over Large Sequences Through Sparse Flash Attention
- 未取得 FlashAttention: Fast Transformer Training with Long Sequences · Hazy Research
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness | alphaXiv
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness | alphaXiv
- 未取得 Fast Attention Over Long Sequences With Dynamic
- 未取得 ELFATT: Efficient Linear Fast Attention for Vision Transformers
- 未取得 Transformer (deep learning)
- 未取得 [Paper] Continuum Attention
- 未取得 [R] FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 [R] Luna: Linear Unified Nested Attention
- 未取得 [R] Long-Short Transformer: Efficient Transformers for Language and Vision
- 未取得 FlashAttention-2 released - 2x faster than FlashAttention v1
- 未取得 [R] Efficient Long-Range Transformers: You Need to Attend More, but Not Necessarily at Every Layer
- 未取得 GitHub - NVIDIA/Star-Attention: Efficient LLM Inference over Long Sequences
- 未取得 FlashAttention: the library running inside almost every LLM you use, 2-8x faster attention on GPU (25k stars)
- 未取得 Why input length affect time complexity of transformers?
- 未取得 [R] Nyströmformer: A Nyström-Based Algorithm for Approximating Self-Attention
- 未取得 TransformerFAM: Feedback attention is working memory
- 未取得 Attention (machine learning)
「FlashAttention 日本語 実装 ベンチマーク メモリ 測定」
- 未取得 FlashAttention原論文を読む 注意計算のメモリ移動を減らす | TRAIL
- 未取得 FlashAttention | papers | ASa Book
- 未取得 FlashAttention-2 | papers | ASa Book
- 未取得 FlashAttention-3 | papers | ASa Book
- 未取得 FlashAttention: GPUメモリ階層を活用したアテンション最適化の分析 — LabHub ブログ
- 未取得 Local Model Watch | 手元で動くオープンウェイトモデルの新着・早見表・実測データ
- 保存
sekii-2025-flashback.txtFlashback: 深層系列処理モデルのメモリ効率化・高速化のための記憶機構 - 未取得 flash-attention/README.md at main · fw-ai/flash-attention · GitHub
- 保存
taniguchi-2025-share-attention.txtAttention スコアの分布類似性を用いた大規模言語モデルの動作効率化および省メモリ化 - 未取得 Flash Attention:ローカル推論のメモリトラフィックを削減する仕組み
- 未取得 計算量より帯域幅?Flash Attention 2で挑むAI推論のIOボトルネック解消術〖PyTorch実装付〗
- 未取得 theonlyengine/Flash-attention1 · Hugging Face
- 未取得 FlashAttention | Transformer 入門 | はとはとプロジェクト
- 未取得 GitHub - royc6/flashattn: FlashAttention forward pass from scratch: PyTorch, Triton and CUDA behind one SDPA-style interface, with a KV-cache decode kernel, tests and H100 benchmarks · GitHub
- 未取得 JLR2025_発表資料
- 未取得 【システム研究調査(理化学研究所)チーム 】令和6年度成果報告書(2)
- 未取得 一般論文 日本データベース学会和文論文誌 Vol. 24-J, Article No. 7
- 未取得 20230827_SNLP_h3_hippo_s4
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 I built FlashAttention from scratch in CUDA to understand LLM performance. Here’s what I learned about the GPU Memory Wall.
- 未取得 FlashMask: Efficient and Rich Mask Extension of FlashAttention
- 未取得 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- 未取得 LampAttention: Look-Ahead Mixed-Precision FlashAttention for Dedicated Accelerators
- 未取得 llama.cpp FlashAttention: P100 owners wanted for testing
- 未取得 FlashAttention: the library running inside almost every LLM you use, 2-8x faster attention on GPU (25k stars)
- 未取得 Samsungがテレビに「ベンチマーク測定値を不正に高性能にする機能」を仕込んでいたことが判明 - GIGAZINE
- 未取得 FlashAttention-4: 1613 TFLOPs/s, 2.7x faster than Triton, written in Python. What it means for inference.
「同一呼出しの統合結果(検索別帰属は返されず): ["site.zenn.dev FlashAttention 実装 検証 メモリ", "site.tech.preferred.jp Transformer 長文 Attention 計算量"]」
- 未取得 Transformerの仕組み、Attentionの考え方と弱点 | 株式会社LASSIC(ラシック)
- 未取得 FlashAttentionのIO-aware設計と実装上の確認点
- 未取得 論文メモ:FlashAttentionのIO-awareなAttention高速化
- 未取得 電気通信大学情報理工学域
- 未取得 FlashAttention原論文を読む 注意計算のメモリ移動を減らす | TRAIL
- 未取得 LLM・生成モデルの推論高速化技術の全体像(多分)
- 未取得 FlashAttention: Making Attention I/O-Aware
- 未取得 スパースアテンションとは?疎なAttentionの仕組みとNSA・DSAの実装判断を解説
- 未取得 JAIST Repository
- 未取得 Transformerと大規模言語モデル 技術解説 | 技術情報発信(素材技術を未来へ)
- 未取得 なぜ Attention だけで足りるのか | Transformer 入門 | はとはとプロジェクト
- 未取得 2B4-GS-6-01
- 未取得 第7章 — 効率と Transformer の派生 / LLM Primer II — 数学で読み解く言語モデル - AB
- 未取得 JLR2025_発表資料
- 未取得 第1回:Transformerとは何か? Attention Is All You Needについて調べてみた。
- 未取得 [Investigation] FlashAttention-4
- 保存
kamahori-2025-serving.mdLLM Servingを支える技術 - 未取得 注意メカニズムとは| IBM
- 未取得 flash-attention/README.md at main · Dao-AILab/flash-attention · GitHub
- 未取得 【システム研究調査(理化学研究所)チーム 】令和6年度成果報告書(2)
- 未取得 theonlyengine/Flash-attention1 · Hugging Face
- 未取得 GitHub - imcaoxuan/flash-attention · GitHub
- 未取得 Transformerとは?意味・仕組みと関連論文、コンテキスト長(2026年10月時点) | TRAIL
- 未取得 GitHub - royc6/flashattn: FlashAttention forward pass from scratch: PyTorch, Triton and CUDA behind one SDPA-style interface, with a KV-cache decode kernel, tests and H100 benchmarks · GitHub
- 未取得 5.8 最新アーキテクチャ - AI研究ロードマップ - はとはとプロジェクト
- 未取得 KV Cache & Flash Attention: an interactive walkthrough
- 未取得 Transformerとは|仕組みと仕事用AIのTier表 | 福井AI/データサイエンス研究所
- 未取得 5.2 Attention機構 - AI研究ロードマップ - はとはとプロジェクト
- 未取得 2023 年度修士論文
- 未取得 Transformerの構造深堀り #MachineLearning - Qiita
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 I built FlashAttention from scratch in CUDA to understand LLM performance. Here’s what I learned about the GPU Memory Wall.
- 未取得 FlashAttention-4: Algorithm and Kernel Pipelining Co-Design for Asymmetric Hardware Scaling
- 未取得 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- 未取得 FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision
- 未取得 Transformer (deep learning)
- 未取得 FlashAttention from first principles
- 未取得 FlashAttention: the library running inside almost every LLM you use, 2-8x faster attention on GPU (25k stars)
- 未取得 [R] FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
「["efficient transformer long sequences FlashAttention Longformer Big Bird Performer Linformer original papers attention", "GQA grouped query attention KV cache original paper Lost in the Middle long contexts"]」
- 未取得 Big Bird: Transformers for Longer Sequences
- 未取得 Contextual priority attention enables linear time sequence modeling in transformers - PMC
- 未取得 Grouped Value Attention: Efficient KV Caching via On-Demand Key Reconstruction
- 未取得 Longformer: The Long-Document Transformer
- 未取得 Constructing Transformers For Longer Sequences with Sparse Attention Methods
- 未取得 Big Bird: Transformers for Longer Sequences
- 未取得 Under review as a conference paper at ICLR 2026
- 未取得 Big Bird: Transformers for Longer Sequences
- 未取得 QCQA: Quality and Capacity-aware grouped Query Attention
- 未取得 Paper page - Grouped Value Attention: Efficient KV Caching via On-Demand Key Reconstruction
- 未取得 GQA creates a mismatch at the granularity of attention heads. A brute-force solution would be to load tokens independently for each query head, but this leads to inefficient, repeated memory reads. Twilight addresses this issue by operating at the granularity of query groups. Specifically, the set of tokens selected for a given query group is the union of tokens identified by all query heads within that group [54].
- 未取得 A lesser challenge LLMs face as context lengths increase is the quadratically scaled memory footprint of the Key-Value (KV) cache during inference. Grouped-Query Attention (GQA) [1] allows multiple query heads to share a single key and value head, significantly compressing the cache size with minimal impact on performance. As such, this is often not the bottleneck as context lengths increase. Additionally, long context LLMs are often pretrained on shorter contexts and Rotary Positional Embeddings (RoPE) [31] extensions such as YaRN [29], NTK-Aware interpolation [30] and position interpolation [9] are used to extend their context length with no impact on time and space complexity [41].
- 未取得 A Practical Survey on Faster and Lighter Transformers | ACM Computing Surveys
- 未取得 Cost-Optimal Grouped-Query Attention for Long-Context Modeling
- 未取得 Aman's AI Journal • Primers • Attention
- 未取得 Paper page - Grouped Query Experts: Mixture-of-Experts on GQA Self-Attention
- 未取得 blog/long-range-transformers.md at main · huggingface/blog · GitHub
- 未取得 Multi Resolution Analysis (MRA) for Approximate Self-Attention - PMC
- 未取得 Paper page - Longformer: The Long-Document Transformer
- 未取得 Constructing Transformers For Longer Sequences with Sparse Attention Methods
- 未取得 Long-Short Transformer: Efficient Transformers
- 未取得 Big Bird: Transformers for Longer Sequences | ML Anthology
- 未取得 Rethinking Attention with Performers
- 未取得 Grouped Query Attention
- 未取得 CAB: Comprehensive Attention Benchmarking on Long Sequence Modeling
- 未取得 Grouped-Query Attention (GQA) | Sebastian Raschka, PhD
- 未取得 Grouped Query Experts: Mixture-of-Experts on GQA Self-Attention | Arxiv - DeepPaper
- 未取得 Page-EntroKV: Hardware-Aligned, Entropy-Weighted KV-Cache Eviction under Grouped-Query Attention · Pith
- 未取得 Grouped-Query Attention (GQA) | Sebastian Raschka, PhD
- 未取得 Grouped Query Experts: Mixture-of-Experts on GQA Self-Attention | alphaXiv
- 未取得 Grouped Query Attention
- 未取得 Grouped Value Attention: Efficient KV Caching via On-Demand Key Reconstruction | Arxiv - DeepPaper
- 未取得 GQA: What the Grouped Query Attention Paper Actually Says — Ashwani Jha
- 未取得 (PDF) Grouped Query Experts: Mixture-of-Experts on GQA Self-Attention
- 未取得 Attention (machine learning)
- 未取得 [2606.20945] Grouped Query Experts (GQE): Mixture-of-Experts on GQA Self-Attention
- 未取得 [2606.20945] Grouped Query Experts (GQE): Mixture-of-Experts on GQA Self-Attention
- 未取得 线性注意力
- 未取得 Attention Is All You Need
- 未取得 Generative pre-trained transformer
- 未取得 PagedAttention
- 未取得 Transformer (deep learning)
「"GQA: Training Generalized Multi-Query" "Lost in the Middle" "Performers"」
- 未取得 Meta - AI Interview Atlas
- 未取得 April 2026 — AI Post Transformers
- 未取得 Attention Mechanism Explained: From Scaled Dot-Product to Grouped-Query Attention | Scixa
- 未取得 Long Context Language Modeling Survey | PDF
- 未取得 AI Research Library: Rajesh Ranjan Mahapatra
- 未取得 ‘self-attention’ directory · Gwern.net
- 未取得 (PDF) A Comprehensive Survey on Long Context Language Modeling
- 未取得 (PDF) Where Does Long-Context Supervision Actually Go? Effective-Context Exposure Balancing
- 未取得 ‘self-attention’ directory · Gwern.net
- 未取得 How Transformers Work: Complete Technical AI Guide | Scixa
- 未取得 Where Does Long-Context Supervision Actually Go? Effective-Context Exposure Balancing · mlsanity
- 未取得 HLA: Expressive Hybrid Linear Attention via Chunk-Wise Dynamic Mixing · mlsanity
1周目(検索 6本・ヒット 76件)
「10.48550/arXiv.1706.03762」
「Attention Is All You Need」
- 未取得 Attention Is All You Need
- 未取得 Is Space-Time Attention All You Need for Video Understanding?
- 未取得 Attention Is All You Need In Speech Separation
- 未取得 Attention is not all you need: the complicated case of ethically using large language models in healthcare and medicine
- 未取得 Attention is all you need: utilizing attention in AI-enabled drug discovery
「W2626778328」
- 未取得 Deep Residual Learning for Image Recognition
- 未取得 AutoResearch Lite: a reproducible paper-inspired experiment runner (Adam mechanism reproduction and convergence-speed comparison)
- 未取得 Effective Approaches to Attention-based Neural Machine Translation
- 未取得 Building a Large Annotated Corpus of English: The Penn Treebank
- 未取得 Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation
- 未取得 Generating Sequences With Recurrent Neural Networks
- 未取得 Convolutional Sequence to Sequence Learning
- 未取得 Long Short-Term Memory-Networks for Machine Reading
- 未取得 A Deep Reinforced Model for Abstractive Summarization
- 未取得 Exploring the Limits of Language Modeling
- 未取得 Learning accurate, compact, and interpretable tree annotation
- 未取得 Using the Output Embedding to Improve Language Models
「W2626778328」
- 未取得 BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
- 未取得 AI-Assisted Pipeline for Dynamic Generation of Trustworthy Health Supplement Content at Scale
- 未取得 Highly accurate protein structure prediction with AlphaFold
- 未取得 Squeeze-and-Excitation Networks
- 未取得 Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
- 未取得 An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- 未取得 End-to-End Object Detection with Transformers
- 未取得 High-Resolution Image Synthesis with Latent Diffusion Models
- 未取得 HISTORIAE, History of Socio-Cultural Transformation as Linguistic Data Science. A Humanities Use Case
- 未取得 Language Models are Few-Shot Learners
- 未取得 Learning Transferable Visual Models From Natural Language Supervision
- 未取得 Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
- 未取得 Squeeze-and-Excitation Networks
- 未取得 Graph Attention Networks
- 未取得 Non-local Neural Networks
「Tri Dao」
- 未取得 Mamba: Linear-Time Sequence Modeling with Selective State Spaces
- 保存
arxiv-2205.14135-flashattention.txtFlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness - 未取得 Combining Recurrent, Convolutional, and Continuous-time Models with Linear State-Space Layers
- 未取得 StarCoder: may the source be with you!
- 未取得 HiPPO: Recurrent Memory with Optimal Polynomial Projections
- 保存
arxiv-2307.08691-flashattention2.txtFlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning - 未取得 Hungry Hungry Hippos: Towards Language Modeling with State Space Models
- 未取得 A Kernel Theory of Modern Data Augmentation
- 未取得 FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision
- 未取得 Hyena Hierarchy: Towards Larger Convolutional Language Models
- 未取得 Sovereign Byte Firewall: Comparing Transformer and Mamba-2 Backbones for Tokenization-Free Zero-Day Network Anomaly Detection
- 未取得 Caduceus: Bi-Directional Equivariant Long-Range DNA Sequence Modeling
「Tri Dao publications FlashAttention FlashAttention-2 FlashAttention-3 official」
- 未取得 flash-attention/README.md at main · Dao-AILab/flash-attention · GitHub
- 未取得 about | Dao AI Lab
- 未取得 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- 未取得 FlashAttention-2:
- 未取得 FlashDA/README.md at main · SJTU-DENG-Lab/FlashDA · GitHub
- 未取得 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- 未取得 GitHub - theonlyengine/flash-attention · GitHub
- 未取得 flash-attn · PyPI
- 未取得 theonlyengine/Flash-attention1 · Hugging Face
- 未取得 FlashAttention-3:
- 未取得 GitHub - togethercomputer/flash-attention-3: Fast and memory-efficient exact attention · GitHub
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 GitHub - Dao-AILab/flash-attention: Fast and memory-efficient exact attention · GitHub
- 未取得 GitHub - drew-chen/dao-flash-attention: Fast and memory-efficient exact attention · GitHub
- 未取得 Introducing Together AI Chief Scientist Tri Dao, as he releases FlashAttention-2 to speed up model training and inference
- 未取得 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- 未取得 FLASHATTENTION: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FLASHATTENTION-2:
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision
- 未取得 Flash Attention 1, 2, 3Tri Dao (PhD, Stanford) ->
- 未取得 FlashAttention-4: Algorithm and Kernel Pipelining Co-Design for Asymmetric Hardware Scaling
- 未取得 Transformer (deep learning)
- 未取得 线性注意力
- 未取得 FlashAttention: the library running inside almost every LLM you use, 2-8x faster attention on GPU (25k stars)
- 未取得 Transformer (aprendizado profundo)
- 未取得 [R] FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- 未取得 FlashAttention-2 released - 2x faster than FlashAttention v1
- 未取得 I built FlashAttention from scratch in CUDA to understand LLM performance. Here’s what I learned about the GPU Memory Wall.
- 未取得 [N] FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
2周目(検索 4本・ヒット 85件)
「Rethinking Attention with Performers original paper Choromanski arxiv」
- 未取得 Rethinking Attention with Performers
- 未取得 Rethinking Attention with Performers
- 未取得 Published as a conference paper at ICLR 2021
- 未取得 Paper page - Rethinking Attention with Performers
- 未取得 Rethinking Attention with Performers
- 未取得 Rethinking Attention with Performers · Pith Review
- 未取得 dblp: Rethinking Attention with Performers.
- 未取得 Masked Language Modeling for Proteins via Linearly Scalable Long-Context Transformers
- 未取得 Rethinking Attention with Performers | ArxivLens
- 未取得 Krzysztof Choromanski
- 未取得 Rethinking Attention with Performers
- 未取得 Rethinking Attention with Performers | alphaXiv
- 未取得 Rethinking Attention with Performers — Lacuna
- 未取得 (PDF) Rethinking Attention with Performers
- 未取得 Performer — Random Feature Softmax Approximation (Performer) · LLM Architecture KB
- 未取得 Krzysztof Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Davis, Afroz Mohiuddin, Lukasz Kaiser, David Belanger, Lucy Colwell, and Adrian Weller. 2022. *Rethinking attention with performers.*
- 未取得 Published as a conference paper at ICLR 2025
- 未取得 Krzysztof Marcin Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Quincy Davis, Afroz Mohiuddin, Lukasz Kaiser, et al. 2020. Rethinking attention with performers. In *International Conference on Learning Representations*.
- 未取得 [33] Krzysztof Marcin Choromanski, Valerii Likhosherstov, David Dohan, Xingyou Song, Andreea Gane, Tamas Sarlos, Peter Hawkins, Jared Quincy Davis, Afroz Mohiuddin, Lukasz Kaiser, David Benjamin Belanger, Lucy J Colwell, and Adrian Weller. Rethinking attention with performers. In *International Conference on Learning Representations*, 2021.
- 未取得 Rethinking Attention with Performers
- 未取得 [D] Paper Explained - Rethinking Attention with Performers (Full Video Analysis)
- 未取得 On the Expressive Power of Self-Attention Matrices
- 未取得 [D] A Theoretical Review on "Rethinking Attention with Performers (ICLR 2021 Oral)"
- 未取得 线性注意力
- 未取得 [2009.14794v1] Rethinking Attention with Performers
- 未取得 Atención (aprendizaje automático)
- 未取得 Synthesizer: Rethinking Self-Attention in Transformer Models
- 未取得 [P] Performers: The Kernel Trick, Random Fourier Features, and Attention
「Lost in the Middle How Language Models Use Long Contexts original paper」
- 未取得 Lost in the Middle: How Language Models Use Long Contexts - ACL Anthology
- 未取得 Lost in the Middle: How Language Models Use Long Contexts | Transactions of the Association for Computational Linguistics | MIT Press
- 未取得 Lost in the Middle: How Language Models Use Long Contexts
- 未取得 Lost in the Middle: How Language Models Use Long Contexts | Transactions of the Association for Computational Linguistics
- 未取得 Lost in the Middle: How Language Models Use Long Contexts
- 未取得 [2307.03172] Lost in the Middle: How Language Models Use Long Contexts
- 保存
liu-2024-lost-middle.txtLost in the Middle: How Language Models Use Long Contexts - 未取得 Lost in the Middle: How Language Models Use Long Contexts
- 未取得 Lost in the Middle: How Language Models Use Long Contexts
- 未取得 Lost in the Middle: How Language Models Use Long Contexts
- 未取得 Paper page - Lost in the Middle: How Language Models Use Long Contexts
- 未取得 Found in the Middle: How Language Models Use Long Contexts Better via Plug-and-Play Positional Encoding
- 未取得 Lost in the Middle: How Language Models Use Long Contexts - ACL Anthology
- 未取得 Lost in the Middle: How Language Models Use Long Contexts · Mouseion
- 未取得 Found in the Middle: How Language Models Use Long Contexts Better via Plug-and-Play Positional Encoding - Microsoft Research
- 未取得 Lost in the Middle: An Emergent Property from Information Retrieval Demands in LLMs
- 未取得 Lost in the Middle: How Language Models Use Long Contexts | NDL Search | National Diet Library
- 未取得 Lost in the Middle: How Language Models Use Long Contexts
- 未取得 Found in the Middle: Calibrating Positional Attention Bias Improves Long Context Utilization
- 未取得 Paper page - Found in the Middle: How Language Models Use Long Contexts Better via Plug-and-Play Positional Encoding
- 未取得 Found in the Middle: How Language Models Use Long Contexts Better via Plug-and-Play Positional Encoding
- 未取得 In context learning
- 未取得 Context window
- 未取得 Language model benchmark
- 未取得 AI's Memorization Crisis
- 未取得 Kevin Roose is AGI-pilled. Why aren't you?
- 未取得 Training of large language models
- 未取得 Do LLM's get "lost in the middle" during summarization as well? [D]
- 未取得 "Writing in the Margins (WiM)" - a better inference pattern for long context LLMs that solves the Lost-in-the-Middle problem
- 未取得 Who said what: using machine learning to correctly attribute quotes
- 未取得 Language model
- 未取得 Reading AI summaries makes people more likely to buy something - despite alarming 60% hallucination rate
- 未取得 Talking to Strangers
- 未取得 Does AI Actually Understand Language?
- 未取得 FILM: New paper from Microsoft to take into account before training or fine-tuning models with long context.
- 未取得 Lost in the Middle: How Language Models use Long Context - Explained!
- 未取得 What Kind of Mind Does ChatGPT Have?
- 未取得 Positional encoding
- 未取得 Paper: Distance between Relevant Information Pieces Causes Bias in Long-Context LLMs (Current models are robust against Lost-in-the-Middle but are still highly susceptible to positional bias )
- 未取得 Long context: what I think I know, what I don’t, and what I’d test
- 未取得 [R] How Well Can a Long Sequence Model Model Long Sequences? Comparing Architectural Inductive Biases on Long-Context Abilities
- 未取得 Had to make this post because I have seen so many HORRIBLE takes about long context and RAG on twitter and here......
「Flashback 関井大気 Linear Attention メモリ 実験」
- 保存
sekii-2025-flashback.txtFlashback: 深層系列処理モデルのメモリ効率化・高速化のための記憶機構 - 未取得 GitHub - lengstrom/flashback: A FlashAttention backwards-over-backwards ⚡🔙🔙 · GitHub
- 未取得 FlashAttention原論文を読む 注意計算のメモリ移動を減らす | TRAIL
- 未取得 Flashback: Memory Mechanism for Enhancing Memory Efficiency and Speed in Deep Sequential Models - ACL Anthology
- 未取得 GitHub - lengstrom/flashback: A FlashAttention backwards-over-backwards ⚡🔙🔙 · GitHub
- 未取得 Paper page - FlashBack: Knowing When to Remember in Streaming Vision-Language Models
- 未取得 JP2026020895A - 学習装置、推定装置、学習方法、推定方法及びプログラム - Google Patents
- 未取得 Flashback: Memory Mechanism for Enhancing Memory Efficiency and Speed in Deep Sequential Models - Conftrace
- 未取得 [論文レビュー] FlashBack: Knowing When to Remember in Streaming Vision-Language Models
- 未取得 [2610.01192] FlashBack: Knowing When to Remember in Streaming Vision-Language Models
- 未取得 JP7756765B1 - Learning device, estimation device, learning method, estimation method, and program - Google Patents
- 未取得 FlashAttentionとは? GPUのメモリ階層から高速化の仕組みを解説
- 未取得 How Linear Attention Remembers | alphaXiv
- 未取得 【システム研究調査(理化学研究所)チーム 】令和6年度成果報告書(2)
- 未取得 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
「10.52202/068431-1189」
ヒット0
検索結果以外から取得した原文
- 保存 https://arxiv.org/pdf/1706.03762
arxiv-1706.03762-attention.txt - 保存 https://arxiv.org/pdf/2007.14062
arxiv-2007.14062-bigbird.txt - 保存 https://aclanthology.org/D15-1166.pdf
luong-2015-effective-attention.txt - 保存 https://arxiv.org/pdf/2004.05150
arxiv-2004.05150-longformer.txt - 保存 https://arxiv.org/pdf/2006.04768
arxiv-2006.04768-linformer.txt - 保存 https://arxiv.org/pdf/2305.13245
arxiv-2305.13245-gqa.txt - 保存 https://arxiv.org/pdf/2309.06180
arxiv-2309.06180-pagedattention.txt - 保存 https://arxiv.org/pdf/2009.14794
arxiv-2009.14794-performer.txt - 保存 https://raw.githubusercontent.com/Dao-AILab/flash-attention/main/README.md
dao-2026-flashattention-readme.md - 保存 https://tridao.me/
dao-2026-home.md - 保存 https://developer.nvidia.com/ja-jp/blog/mastering-llm-techniques-inference-optimization/
nvidia-2023-inference-ja.md - 保存 https://aclanthology.org/2025.coling-main.575.pdf
sekii-2025-flashback-coling.txt - 保存 https://arxiv.org/pdf/1911.02150
arxiv-1911.02150-mqa.txt