Skip to content

ggml-webgpu: compute pass batching and removing profiling overhead#21873

Merged
ggerganov merged 13 commits intoggml-org:masterfrom
reeselevine:command-batching
Apr 16, 2026
Merged

ggml-webgpu: compute pass batching and removing profiling overhead#21873
ggerganov merged 13 commits intoggml-org:masterfrom
reeselevine:command-batching

Conversation

@reeselevine
Copy link
Copy Markdown
Contributor

@reeselevine reeselevine commented Apr 13, 2026

Overview

Per https://bugs.webkit.org/show_bug.cgi?id=311598, it seems like lots of individual compute passes can cause issues on some WebGPU implementations. This PR batches multiple operations into the same compute pass, which does seem to be stable and allows for much faster decode speeds on Safari and iOS devices (30-54 t/s for small models and q4-ish quantizations). Performance doesn't change significantly on other devices or browsers, from what I've seen.

Along with this change, I fixed the overhead of WebGPU profiling by creating a single query set which records all timestamps, and is only mapped once at the end of each forward pass of the model. Unfortunately, timestamps only work at the boundaries of compute passes, so when profiling is enabled, we do not batch compute passes. This means that profiling won't work on iOS right now, but I think that's a reasonable trade-off.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: yes, to help batch timestamps into a single query set

@reeselevine reeselevine changed the title Command batching ggml-webgpu: Command batching Apr 13, 2026
@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning WebGPU labels Apr 13, 2026
@reeselevine reeselevine changed the title ggml-webgpu: Command batching ggml-webgpu: compute pass batching and removing profiling overhead Apr 15, 2026
@reeselevine reeselevine marked this pull request as ready for review April 15, 2026 16:24
@reeselevine reeselevine requested a review from a team as a code owner April 15, 2026 16:24
@reeselevine reeselevine requested review from CISC and ggerganov April 15, 2026 18:24
@reeselevine reeselevine added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Apr 15, 2026
@reeselevine
Copy link
Copy Markdown
Contributor Author

@ggml-org/maintainers another review please :)

@ggerganov ggerganov merged commit 82677a6 into ggml-org:master Apr 16, 2026
50 checks passed
cnsiva pushed a commit to saas-home/llama.cpp that referenced this pull request Apr 17, 2026
…gml-org#21873)

* Update register tiling matmul to use f32 accumulation

* fix profiling code

* Fix register tiling matmul for chrome, i'm blaming dawn

* Update batch tuning value for iOS

* compile fix

* Fix use of new load function

* Move to a single query set for GPU profiling

* Move to batching compute passes when not profiling

* Refactor build_multi

* remove iOS throttling now that we're batching compute passes
mengqin pushed a commit to mengqin/llama.cpp that referenced this pull request Apr 20, 2026
…gml-org#21873)

* Update register tiling matmul to use f32 accumulation

* fix profiling code

* Fix register tiling matmul for chrome, i'm blaming dawn

* Update batch tuning value for iOS

* compile fix

* Fix use of new load function

* Move to a single query set for GPU profiling

* Move to batching compute passes when not profiling

* Refactor build_multi

* remove iOS throttling now that we're batching compute passes
ArberSephirotheca pushed a commit to ArberSephirotheca/llama.cpp that referenced this pull request Apr 21, 2026
…gml-org#21873)

* Update register tiling matmul to use f32 accumulation

* fix profiling code

* Fix register tiling matmul for chrome, i'm blaming dawn

* Update batch tuning value for iOS

* compile fix

* Fix use of new load function

* Move to a single query set for GPU profiling

* Move to batching compute passes when not profiling

* Refactor build_multi

* remove iOS throttling now that we're batching compute passes
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Apr 23, 2026
…gml-org#21873)

* Update register tiling matmul to use f32 accumulation

* fix profiling code

* Fix register tiling matmul for chrome, i'm blaming dawn

* Update batch tuning value for iOS

* compile fix

* Fix use of new load function

* Move to a single query set for GPU profiling

* Move to batching compute passes when not profiling

* Refactor build_multi

* remove iOS throttling now that we're batching compute passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. WebGPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants