[ggml-webgpu] Implement 2D workgroups for scale, binary, and unary ops#24044
Conversation
# Conflicts: # .github/workflows/build.yml
# Conflicts: # .github/workflows/build.yml
| let src1_i = params.offset_src1 + src1_index(gid.x); | ||
| update(params.offset_dst + gid.x, src0_i, src1_i); | ||
| fn main(@builtin(global_invocation_index) gindex: u32) { | ||
| if (gindex < params.ne) { |
There was a problem hiding this comment.
It seems better to use global_invocation_id as is, because global_invocation_index is a wgsl extension (linear_indexing), and safari doesn't support it yet.
I reverted to using global_invocation_id in #23955.
There was a problem hiding this comment.
Good callout, thanks! I will update this.
| shader_lib_ctx.src1 = nullptr; | ||
| shader_lib_ctx.dst = dst; | ||
| shader_lib_ctx.max_wg_size = ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup; | ||
| shader_lib_ctx.max_wg_size = ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup; |
There was a problem hiding this comment.
Still conflicting versions of clang-format?
There was a problem hiding this comment.
Hmm, my environment (clangd 22.1.6) produces the same format changes as this PR, plus some additional format changes in this file.
@nikhilJain17 , what version of clang-format or clangd are you using? (see #23760 (comment))
There was a problem hiding this comment.
Thanks! For reference, since the formatting output seems to differ slightly between versions 21 and 22, it might be good to use version 22 or later for future PRs.
There was a problem hiding this comment.
Sounds good, will do
ggml-org#24044) * Only run webgpu CI on my fork * Add webgpu only workflow * Implement 2d workgroups for more operations * fix * Fix type * Move back to global_invocation_id (cherry picked from commit 3b3da01)
ggml-org#24044) * Only run webgpu CI on my fork * Add webgpu only workflow * Implement 2d workgroups for more operations * fix * Fix type * Move back to global_invocation_id
Overview
When running the WebGPU backend with stable-diffusion.cpp, it dispatched the following kernels with too many workgroups:
scale, add, mul, silu.Apply the same technique as #23750 to dispatch 2D workgroups to run these models.
Additional information
Tested with
test-backend-ops -b WebGPUand CI suite locally.Requirements