Repository navigation
削除済: metal: GQA 共有読み flash-attention vec の QK dot を simdgroup_matrix 化する - #4
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
upstream で対応済みであり、差分は削除済みです。
深部 KV の GQA 共有読み flash-attention vec カーネルの QK dot を
simdgroup_matrixのタイル積に置き換える。共有読みパスは 8 q head 分の QK dot を per-(head, 位置) の
simd_sum直列 (1 iteration あたり 32 位置 × 8 head = 256 回) で行っており、命令発行数が律速で深部の実効帯域が 151 GB/s に留まっていた (切り分けは ishikawa/local-llm#60)。Q (8 head × DK) と K (32 位置 × DK) の積をsimdgroup_half8x8のタイル積 (float 累積) に載せ替え、simd reduction を行列ユニットに置換する。設計
is_sameゲート)。量子化 K は従来の dot +simd_sumパスにフォールバックsimdgroup_float8x8累積に対し DK/16 反復 × C/8 出力タイル。K は device メモリからtranspose=trueでsimdgroup_load、Q は threadgroup 上の共有 Q から読むssに store した後、レーンごとに適用)実測
Note
計測環境: Mac mini M4 Pro。op は
test-backend-ops perfのFLASH_ATTN_EXT(A3B decode 形状:DK=DV=256・q16/kv2・F16 KV・batch1)。decode は spec_bench (Qwen3.6-35B-A3B UD-Q4_K_XL、seed 42、同条件 A/B)。op (baseline は ggml-org#59 反映後の再計測):
実モデル decode:
検証
FLASH_ATTN_EXTcorrectness 全形状 pass (-b MTL0)。深部共有パス (kv=98304/131072/245760、kvpad 非整列・sinks 含む) の ERR 0.0022–0.0052 で baseline 同水準 (F16 累積)