]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
ggml webgpu: support for backend sampling (#18880)
authorReese Levine <redacted>
Sat, 17 Jan 2026 00:12:43 +0000 (16:12 -0800)
committerGitHub <redacted>
Sat, 17 Jan 2026 00:12:43 +0000 (16:12 -0800)
commita89002f07b55dace8671fc07b2e2418700716992
tree59519a993650d7d9131b980e2c06a7156bea4596
parent388ce822415f24c60fcf164a321455f1e008cafb
ggml webgpu: support for backend sampling (#18880)

* ggml webgpu: add SOFTPLUS unary operator

Implements SOFTPLUS (log(1 + exp(x))) with f16/f32 support. Uses f32
precision for intermediate calculations to prevent f16 overflow.

* Add shader implementation and 4 variants (f32/f16, inplace/non-inplace)
* Register pipelines and device support
* Follow Vulkan backend numerical stability pattern

* ggml webgpu: add EXPM1 unary operator

Implements EXPM1 (exp(x) - 1) with f16/f32 support.

* Add shader implementation and 4 variants (f32/f16, inplace/non-inplace)
* Register pipelines and device support

* ggml webgpu: add FLOOR unary operator

Implements FLOOR (rounds down to nearest integer) with f16/f32 support.

* Add shader implementation and 4 variants (f32/f16, inplace/non-inplace)
* Register pipelines and device support

* ggml webgpu: add CEIL unary operator

Implements CEIL (rounds up to nearest integer) with f16/f32 support.

* Add shader implementation and 4 variants (f32/f16, inplace/non-inplace)
* Register pipelines and device support

* ggml webgpu: add ROUND unary operator

Implements ROUND (rounds to nearest integer) with f16/f32 support.

* Add shader implementation and 4 variants (f32/f16, inplace/non-inplace)
* Register pipelines and device support

* ggml webgpu: add TRUNC unary operator

Implements TRUNC (truncates towards zero) with f16/f32 support.

* Add shader implementation and 4 variants (f32/f16, inplace/non-inplace)
* Register pipelines and device support

* docs : update WebGPU support for unary operators (FLOOR, CEIL, ROUND, TRUNC, EXPM1, SOFTPLUS)

* Updates to webgpu get_memory

* Add argmax

* Add argmax,cumsum,sum,sum_rows

* Add necessary CPY/GET_ROWS operators

* Support for argsort using multi-pass strategy

* Update set_rows for i32 indices, move to pre-wgsl

* Port unary operators to pre-wgsl and support FILL

* Implement PAD

* Add support for top-k

* clean up, scope pipeline init mutex

* fix newline

* Add support for log

* Update LOG for better precision, and ops doc

---------

Co-authored-by: Abhijit Ramesh <redacted>
15 files changed:
docs/ops.md
docs/ops/WebGPU.csv
ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp
ggml/src/ggml-webgpu/ggml-webgpu.cpp
ggml/src/ggml-webgpu/wgsl-shaders/argmax.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/argsort.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/argsort_merge.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/cpy.tmpl.wgsl
ggml/src/ggml-webgpu/wgsl-shaders/cumsum.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/pad.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/set_rows.tmpl.wgsl [deleted file]
ggml/src/ggml-webgpu/wgsl-shaders/set_rows.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/sum_rows.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/unary.wgsl [new file with mode: 0644]
ggml/src/ggml-webgpu/wgsl-shaders/unary_op.wgsl [deleted file]