You need Chrome 113+ (or Edge). Firefox does not support WebGPU.
You also need to serve it over HTTP — WebGPU is blocked on file:// URLs.
The easiest way:
# Python (built-in)
python3 -m http.server 8080
# Node
npx serve .
# Node with auto-reload on file changes
npx live-server --port=8080
# VS Code: install the "Live Server" extension, right-click index.html → Open with Live ServerThen open http://localhost:8080.
Write your WGSL shader in your editor, then paste it into the textarea and hit Run. Compile errors appear in the error box with line numbers.
tint is the WGSL compiler used inside Chrome. Running it locally catches errors before opening the browser.
Install (macOS via Homebrew):
brew install tintOr build from source: https://dawn.googlesource.com/dawn
Usage:
tint validate kernels/group_norm.wgslExit code 0 = valid. Errors include line numbers and a message from the same parser Chrome uses.
All tensors are flat array<f32> in row-major order.
input[b, c, i] = input[b * C * L + c * L + i]
Where:
B= batch sizeC= number of channelsG= number of groupsL= spatial length (channels per group = C / G)
GroupNorm groups consecutive channels: group g contains channels [g*L .. (g+1)*L).
- Compile errors appear in the error box with line numbers.
- Wrong output but no error: add
output[0] = f32(some_value)to probe intermediate values. - All zeros: usually a binding mismatch — check that JS binding indices match WGSL
@binding(N). - NaN/Inf: usually a divide-by-zero — add an epsilon:
1.0 / sqrt(variance + 1e-5). - The workgroup size in WGSL (
@workgroup_size(N)) must match your dispatch math in JS (dispatchWorkgroups(ceil(total / N))).