{"id":26788268,"url":"https://github.com/qedprotocol/poseidon2-webgpu-demo","last_synced_at":"2025-09-12T18:45:45.536Z","repository":{"id":199649581,"uuid":"703374402","full_name":"QEDProtocol/poseidon2-webgpu-demo","owner":"QEDProtocol","description":"A demonstration of hashing a Poseidon2 merkle tree in parallel using a WebGPU compute shader","archived":false,"fork":false,"pushed_at":"2023-10-14T08:44:34.000Z","size":517,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T21:48:38.692Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QEDProtocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2023-10-11T06:03:25.000Z","updated_at":"2024-06-18T09:53:51.000Z","dependencies_parsed_at":"2023-10-15T09:12:22.445Z","dependency_job_id":null,"html_url":"https://github.com/QEDProtocol/poseidon2-webgpu-demo","commit_stats":null,"previous_names":["qedprotocol/poseidon2-webgpu-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/QEDProtocol/poseidon2-webgpu-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QEDProtocol%2Fposeidon2-webgpu-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QEDProtocol%2Fposeidon2-webgpu-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QEDProtocol%2Fposeidon2-webgpu-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QEDProtocol%2Fposeidon2-webgpu-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QEDProtocol","download_url":"https://codeload.github.com/QEDProtocol/poseidon2-webgpu-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QEDProtocol%2Fposeidon2-webgpu-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274857490,"owners_count":25362788,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-29T13:16:40.681Z","updated_at":"2025-09-12T18:45:45.462Z","avatar_url":"https://github.com/QEDProtocol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg height=\"256\" src=\"public/poseidon2-webgpu-logo.png\"\u003e\n  \u003ch1\u003ePoseidon2 WebGPU Demo\u003c/h1\u003e \n  \u003cp\u003e\n\nA browser benchmark which compares the performance of hashing a poseidon2-goldilocks merkle tree on CPU using the \u003ca href=\"https://github.com/OpenAssetStandards/poseidon2\"\u003eposeidon2 npm package\u003c/a\u003e vs. our experimental WebGPU poseidon2 compute shader.\u003c/p\u003e\n\n\u003c/p\u003e\n\n### Demo Link - Requires the latest version of Chrome or a browser that supports WebGPU\n\u003cp align=\"center\"\u003e\n\n\u003ca href=\"https://s684hf.csb.app/\"\u003e\n\u003cimg height=\"300\" src=\"public/demo-screenshot.png\"\u003e\n\u003c/a\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://s684hf.csb.app/\"\u003e\nOpen Benchmark Demo \n\u003c/a\u003e\n\u003c/p\u003e\n\u003c/p\u003e\n\n## Setup\n```\npnpm i\npnpm start\n```\n\n_(you can use your favorite node package manager if you do not have pnpm installed)_\n\n### Note: This benchmark \u003cu\u003eonly\u003c/u\u003e works on [browsers which have support for WebGPU](https://caniuse.com/webgpu)\n\n## Benchmark Results on Chrome / 2021 Apple M1 Max (MacBook Pro)\n\n| Merkle Tree Height  | Total Time CPU (ms) | Total Time WebGPU (ms) | WebGPU Performace Gain |\n| ------------------- | ------------------- | ---------------------- | ---------------------- |\n| 8 (256 Leaves)      | 15.09 ms            | 32.07 ms               | 2.1x Slower than CPU   |\n| 12 (4096 Leaves)    | 216.1 ms            | 40.8 ms                | 5.3x Faster than CPU   |\n| 16 (65536 Leaves)   | 3606.4 ms           | 177.2 ms               | 20.35x Faster than CPU |\n| 20 (1048676 Leaves) | 58219.7 ms          | 2119.3 ms              | 27.47x Faster than CPU |\n\n### Info/Tips\n\n- Our WebGPU compute shader can be found in [src/webgpu/poseidon2-goldilocks.wgsl](src/webgpu/poseidon2-goldilocks.wgsl).\n- Right now there are limitations on how much memory can be allocated to WebGPU compute workgroups, so staying in the range of 1-22 height merkle trees is recommended (if you want larger, you can just create several job instances and then connect them with another small merkle tree on top)\n- For tree heights greater than 20, CPU is so slow that the benchmark often freezes, but you can still benchmark WebGPU at these heights if you check the \"Disable CPU\" option\n\n## Credits\n\nMade with ❤️ by QED Team\n\nSpecial thanks to [Recmo](https://github.com/recmo) for his uint128 implementation of [Goldilocks multiplication for WGSL](https://github.com/recmo/proto-goldilocks-webgpu/blob/cc6ce5d2df8a20ba89484a49f82b0037f8fd5676/shader/goldilocks.wgsl#L50)\n\n## License\n\nMIT License\n\nCopyright (c) 2023 Zero Knowledge Labs Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqedprotocol%2Fposeidon2-webgpu-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqedprotocol%2Fposeidon2-webgpu-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqedprotocol%2Fposeidon2-webgpu-demo/lists"}