{"id":26101571,"url":"https://github.com/zachgrayio/headless-webgpu-playground","last_synced_at":"2025-07-05T01:39:47.371Z","repository":{"id":280247660,"uuid":"941410827","full_name":"zachgrayio/headless-webgpu-playground","owner":"zachgrayio","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-02T08:49:25.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T09:23:33.381Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zachgrayio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-02T08:13:41.000Z","updated_at":"2025-03-02T08:49:28.000Z","dependencies_parsed_at":"2025-03-02T09:23:42.434Z","dependency_job_id":"592344f6-2aaf-4f52-9dc8-7d106697504c","html_url":"https://github.com/zachgrayio/headless-webgpu-playground","commit_stats":null,"previous_names":["zachgrayio/headless-webgpu-playground"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachgrayio%2Fheadless-webgpu-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachgrayio%2Fheadless-webgpu-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachgrayio%2Fheadless-webgpu-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachgrayio%2Fheadless-webgpu-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zachgrayio","download_url":"https://codeload.github.com/zachgrayio/headless-webgpu-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242729531,"owners_count":20175957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-09T18:04:30.310Z","updated_at":"2025-03-09T18:04:30.700Z","avatar_url":"https://github.com/zachgrayio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# headless-webgpu-playground\n\nExploring the settings needed to get headless WebGPU working on NVIDIA hardware, and the performance of WebGPU shaders under frameworks like puppeteer and playwright.\n\n## Usage\n\n- `npm run test:puppeteer` - runs the puppeteer tests that will check the `chrome://gpu` page for expected settings, and save a screenshot of the page\n- `npm run test:webgpu` - run the playwright tests that render a few things that require working WebGPU, as well as validate that `navigator.gpu` is present. This also will run some matrix math on the GPU and dump a FLOPS estimate, to show what kind of performance WebGPU is capable of on the current machine.\n- NOTE: if the test times out on your hardware, remove some of the larger `shapes` from the GEMM benchark so it doesn't pass the default 30s timeout threshold, or raise the timeout.\n\n## GPU status\n\nWith the checked in configuration, `chrome://gpu` reports the following on my machine (Nvidia 4090, ubuntu, cuda sdk, drivers and nvidia-smi etc all working):\n\n![image](https://github.com/user-attachments/assets/07249d11-bfd0-4dd2-866a-698b772f5cc5)\n\nContrary to some guides, using the flag `--use-gl=egl` or `gl` or similar to get the `chrome://gpu` page to show WebGL and WebGPU as fully hardware accelerated actually will break the availability of `navigator.gpu` because the GL backend isn't fully compatible yet, so mileage may vary with that approach.\n\n## Results \u0026 GEMM Performance on RTX 4090\n\nAgain on my 4090, I'm seeing the following output from the `sgemm` benchmark on WebGPU:\n\n```\nnpm run test:webgpu\n\n\u003e headless-gpu@1.0.0 test:webgpu\n\u003e playwright test webgpu.spec.ts\n\n\nRunning 4 tests using 4 workers\n[chromium] › tests/webgpu.spec.ts:48:7 › WebGPU tests › should get WebGL device info\nWebGL Device Info: {\n  vendor: 'Google Inc. (NVIDIA)',\n  renderer: 'ANGLE (NVIDIA, Vulkan 1.3.277 (NVIDIA NVIDIA GeForce RTX 4090 (0x00002684)), NVIDIA)',\n  version: 'WebGL 2.0 (OpenGL ES 3.0 Chromium)',\n  shadingLanguageVersion: 'WebGL GLSL ES 3.00 (OpenGL ES GLSL ES 3.0 Chromium)'\n}\n[chromium] › tests/webgpu.spec.ts:23:7 › WebGPU tests › should have gpu on navigator\nGPU Adapter info: {\n  isFallbackAdapter: false,\n  features: [\n    'depth32float-stencil8',\n    'rg11b10ufloat-renderable',\n    'bgra8unorm-storage',\n    'chromium-experimental-multi-draw-indirect',\n    'texture-compression-bc',\n    'dual-source-blending',\n    'chromium-experimental-snorm16-texture-formats',\n    'chromium-experimental-timestamp-query-inside-passes',\n    'float32-filterable',\n    'indirect-first-instance',\n    'float32-blendable',\n    'depth-clip-control',\n    'timestamp-query',\n    'chromium-experimental-unorm16-texture-formats',\n    'clip-distances',\n    'subgroups'\n  ],\n  limits: {}\n}\n[chromium] › tests/webgpu.spec.ts:89:7 › WebGPU tests › should perform WebGPU matmul\nWebGPU gemms completed:  {\n  \"gemmResults\": [\n    ...\n    {\n      \"success\": true,\n      \"averageTimeMs\": 419.3766666666915,\n      \"flops\": 640.0820010650349,\n      \"sampleValues\": [\n        2031.99755859375,\n        2064.060302734375,\n        2070.109130859375,\n        2069.388671875\n      ],\n      \"shape\": [\n        4096,\n        4096,\n        8000\n      ],\n      \"launchParams\": {\n        \"dispatchX\": 512,\n        \"dispatchY\": 512,\n        \"workgroupSizeX\": 8,\n        \"workgroupSizeY\": 8\n      }\n    }\n  ]\n}\n  4 passed (23.6s)\n\n```\nAnd in `nvtop`: \n![image](https://github.com/user-attachments/assets/a5642c3e-4f1e-4648-85ae-250a84ee08a7)\n\n## MacOS CPU\n\nSee [this branch](https://github.com/zachgrayio/headless-webgpu-playground/tree/mac-cpu) to get this running on macOS and CPU via swiftshader. Compared to my 4090:\n- the 4090 completes the matmul benchmark at around 0.64 TFLOPS, not great, but good enough for my purposes\n- an M4 Max chip running with Swiftshader \u0026 CPU gets 0.0112 TFLOPS\n\nSo the real GPU is around 56x faster for this workload.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachgrayio%2Fheadless-webgpu-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzachgrayio%2Fheadless-webgpu-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachgrayio%2Fheadless-webgpu-playground/lists"}