ggml-webgpu: simplify flash_attn shaders and refactor several WGSL shaders#26134
Draft
yomaytk wants to merge 3 commits into
Draft
ggml-webgpu: simplify flash_attn shaders and refactor several WGSL shaders#26134yomaytk wants to merge 3 commits into
yomaytk wants to merge 3 commits into
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.
Overview
This PR includes the changes from #25956, so I'll open this after the PR is resolved.
This PR refactors several WGSL files and simplifies the flash attention WGSL files. The changes to each WGSL shader are as follows:
concat.wgsl, rms_norm_mul.wgsl, row_norm.wgsl, solve_tri.wgsl, ssm_scan.wgsl: Remove unused params.conv2d.wgsl, conv2d_dw.wgsl, im2col.wgsl: Define the macros as the actual type for weights, input, and output buffer and remove some unnecessary functions.soft_max.wgsl: Remove the unused param ne. Also, binding numbers for each tensor buffer are computed sequentially instead of defining buffers with nested macros, since the nested macro structures aren't easy to read.flash_attn_decls.tmpl: This file contains the common definitions of params and types shared among flash attention WGSL shaders. Binding numbers for the tensor buffers are computed in the same way as in soft_max.wgsl.flash_attn_staging.tmpl: flash_attn_quant_staging.tmpl was renamed to this file, and load_(k|v)_tile_block for the float type is extracted from the three flash attention shaders.flash_attn.wgsl, flash_attn_tile.wgsl, flash_attn_vec_split.wgsl: Common code is extracted into flash_attn_decls.tmpl and flash_attn_staging.tmpl.Requirements