Skip to content

Support building with Emscripten#833

Merged
copybara-service[bot] merged 2 commits intogoogle:devfrom
brendandahl:emscripten-cmake
Mar 27, 2026
Merged

Support building with Emscripten#833
copybara-service[bot] merged 2 commits intogoogle:devfrom
brendandahl:emscripten-cmake

Conversation

@brendandahl
Copy link
Copy Markdown

Update CMake configuration and utility functions to enable compilation
with Emscripten. This includes setting Wasm-specific flags like
memory64 and SIMD, implementing platform-specific memory detection, and
adding guards for features like OpenSSL that may be unavailable in a
web environment.

@brendandahl
Copy link
Copy Markdown
Author

For a little more context, we'd like to start using gemma.cpp in some experimental Wasm AI benchmarks. If you're interested, I can also add CI testing for this configuration and help keep it green if needed.

jan-wassenberg
jan-wassenberg previously approved these changes Feb 12, 2026
Copy link
Copy Markdown
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Benchmark sounds interesting, is there any info you can share?
Sure, we'd welcome a PR to add the CI and your help keeping it green.

@jan-wassenberg jan-wassenberg added the copybara-import Trigger Copybara for merging pull requests label Feb 12, 2026
@brendandahl
Copy link
Copy Markdown
Author

There's some more info on the benchmarks in this repo. Currently, it's mainly transformers.js (ONNX) and LiteRT workloads, but we'd like to add some more. We're still trying to figure out if we want to put Gemma.cpp in the default suite (what contributes to the overall score) since downloading such a big model would be slow. Gemma.cpp can at least go in the experimental benchmarks that devs can look at though.

We're planning to use the benchmarks to guide generating optimized Wasm SIMD from LLVM, improve v8 performance, and help see the impact of the FP16 proposal for Wasm.

In regards to the model size, is there a smaller model (<2B) that could be used for the benchmark that would simulate a similar workload?

@jan-wassenberg
Copy link
Copy Markdown
Member

Sounds interesting, thanks for sharing.
Yes, there is a 270M version on Kaggle that I'd recommend for reducing download size: https://www.kaggle.com/models/google/gemma-3/gemmaCpp/3.0-270m-it-sfp

FYI this PR is stuck on a permissions issue which I am fixing in cl/871333540.

@jan-wassenberg jan-wassenberg added copybara-import Trigger Copybara for merging pull requests and removed copybara-import Trigger Copybara for merging pull requests labels Mar 27, 2026
@jan-wassenberg
Copy link
Copy Markdown
Member

We can have another go at merging this, the internal error is now resolved. Can you help rebase this PR?

Qualify color constants and APIClient with the gcpp namespace in
gemma/api_client.cc to resolve potential symbol lookup issues.
Update CMake configuration and utility functions to enable compilation
with Emscripten. This includes setting Wasm-specific flags like
memory64 and SIMD, implementing platform-specific memory detection, and
adding guards for features like OpenSSL that may be unavailable in a
web environment.
@brendandahl
Copy link
Copy Markdown
Author

I've updated the branch, but ran into #885 yesterday.

@jan-wassenberg
Copy link
Copy Markdown
Member

Thanks :) Let's land this one first before investigating #885.

@jan-wassenberg jan-wassenberg removed the copybara-import Trigger Copybara for merging pull requests label Mar 27, 2026
@jan-wassenberg jan-wassenberg added the copybara-import Trigger Copybara for merging pull requests label Mar 27, 2026
@copybara-service copybara-service bot merged commit 0da94e5 into google:dev Mar 27, 2026
7 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copybara-import Trigger Copybara for merging pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants