Skip to content

Conversation

@reeselevine
Copy link
Collaborator

This PR builds on and supersedes #15826 from @ngxson.

  • Adds __EMSCRIPTEN__ preprocessors conditionals in places necessary for compilation (this included some OS specific things in common/
  • Adds flags for emscripten builds for 64-bit memory, memory growth that I found to be required to get the backend operations to pass when running through the browser (Chrome/M3 system)
  • Also adds a Github workflow that ensures emscripten builds compile (at least with test-backend-ops), to avoid other code additions that accidentally break things.
  • Disables dawn/native-only WebGPU features when building for the browser, like experimental support for subgroup matrices

reeselevine and others added 4 commits November 5, 2025 08:24
Add fast matrix and matrix/vector multiplication.
* webgpu : fix build on emscripten

* more debugging stuff

* test-backend-ops: force single thread on wasm

* fix single-thread case for init_tensor_uniform

* use jspi

* add pthread

* test: remember to set n_thread for cpu backend

* Add buffer label and enable dawn-specific toggles to turn off some checks

* Intermediate state

* Fast working f16/f32 vec4

* Working float fast mul mat

* Clean up naming of mul_mat to match logical model, start work on q mul_mat

* Setup for subgroup matrix mat mul

* Basic working subgroup matrix

* Working subgroup matrix tiling

* Handle weirder sg matrix sizes (but still % sg matrix size)

* Working start to gemv

* working f16 accumulation with shared memory staging

* Print out available subgroup matrix configurations

* Vectorize dst stores for sg matrix shader

* Gemv working scalar

* Minor set_rows optimization (#4)

* updated optimization, fixed errors

* non vectorized version now dispatches one thread per element

* Simplify

* Change logic for set_rows pipelines

---------

Co-authored-by: Neha Abbas <nehaabbas@macbookpro.lan>
Co-authored-by: Neha Abbas <nehaabbas@ReeseLevines-MacBook-Pro.local>
Co-authored-by: Reese Levine <reeselevine1@gmail.com>

* Comment on dawn toggles

* Working subgroup matrix code for (semi)generic sizes

* Remove some comments

* Cleanup code

* Update dawn version and move to portable subgroup size

* Try to fix new dawn release

* Update subgroup size comment

* Only check for subgroup matrix configs if they are supported

* Add toggles for subgroup matrix/f16 support on nvidia+vulkan

* Make row/col naming consistent

* Refactor shared memory loading

* Move sg matrix stores to correct file

* Working q4_0

* Formatting

* Work with emscripten builds

* Fix test-backend-ops emscripten for f16/quantized types

* Use emscripten memory64 to support get_memory

* Add build flags and try ci

---------

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
@github-actions github-actions bot added build Compilation issues script Script related testing Everything test related devops improvements to build systems and github actions ggml changes relating to the ggml tensor library for machine learning labels Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Compilation issues devops improvements to build systems and github actions ggml changes relating to the ggml tensor library for machine learning script Script related testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant