Repository navigation
Add a WebAssembly build and a browser playground - #61
Merged
Merged
Conversation
A static landing page in site/ (no build step, self-hosted fonts) and a workflow that deploys it to GitHub Pages on pushes to main that touch site/** or the workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013gtFQRPe1eSSpmA7EJ2KNY
wasm/build.sh compiles the unchanged AutoQ CLI to WebAssembly with Emscripten, together with Z3 4.12.5 and the ANTLR 4.13.2 C++ runtime (built once and cached). site/playground runs it in a Web Worker: it writes the input files into the in-memory file system and calls main() with the CLI arguments, so results match the native tool. - CMake: an Emscripten-only branch (header-only Boost, prebuilt Z3 and ANTLR, ES-module link options). The native build is unchanged. - cli/autoq.cc: skip feenableexcept() under Emscripten (no FP traps). - src/util/memory.cpp: report the WebAssembly heap size under Emscripten; its getrusage() does not set ru_maxrss. - pages.yml: build the playground in CI with a cached dependency build. - wasm/compare.mjs checks every playground example against the native CLI; wasm/README.md documents the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013gtFQRPe1eSSpmA7EJ2KNY
The hero and the nav already link to it; this adds a sentence at the start of Get started for readers who want to try AutoQ before installing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013gtFQRPe1eSSpmA7EJ2KNY
In eq mode the editor now shows only a.qasm and b.qasm, and the example list offers equivalence examples: CX = H·CZ·H, SWAP as three CX gates, Toffoli against its Clifford+T decomposition, the same decomposition with one T replaced by T† (unequal), and XZ vs ZX (equal up to global phase). ver and ex keep sharing one workspace; each workspace keeps its edits when switching commands. [equal]/[unequal] are highlighted like [OK]/[failed]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013gtFQRPe1eSSpmA7EJ2KNY
ondrik
force-pushed
the
wasm-playground
branch
from
October 20, 2026 12:42
159071f to
75d7d98
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds AutoQ for WebAssembly and adds a browser playground at
site/playground/, served at/playground/next to the landing page. It runs the unchanged command-linemain()entirely in the browser, with Z3 and the ANTLR runtime compiled in, so nothing is uploaded and results match the native tool.Live preview: https://ondrik.github.io/AutoQ/playground/ is this branch deployed from my fork with the same workflow.
Depends on #58 (the landing page). This branch is built on #58's commit, so until #58 is merged this PR also shows that commit. After #58 is merged with a merge commit or a rebase, the diff here shrinks to the playground alone. If #58 is squash-merged, I'll rebase this branch.
What's in it
wasm/build.shbuilds Z3 4.12.5 and the ANTLR 4.13.2 C++ runtime as static WebAssembly libraries (once, then cached), then builds AutoQ and writesautoq.jsandautoq.wasm. It patches three lines of Z3: names left over from renames inside templates that are never instantiated, which the clang in current Emscripten rejects. Later Z3 releases contain the same fixes. Tested with Emscripten 6.0.12.autoqas an ES module exportingcreateAutoQ(). The native build is unchanged.cli/autoq.cc: skipfeenableexcept()under Emscripten, since WebAssembly has no floating-point traps.src/util/memory.cpp: report the WebAssembly heap size under Emscripten. Emscripten'sgetrusage()doesn't setru_maxrss, so the reported memory was garbage before.site/playground/: editable file tabs,ver/ex/eq,--loopsum, Stop, Ctrl+Enter to run, and eleven examples. Six are taken from the repository: the README example, BV, symbolic Grover, Grover, if, and while with an invariant. Five are foreq: CX = H·CZ·H, SWAP as three CX gates, Toffoli against its Clifford+T decomposition, the same decomposition with one T flipped to T† ([unequal]), and XZ vs ZX (equal up to a global phase).eqhas its own files (onlya.qasmandb.qasm) and its own example list.verandexshare one set of files, and each set keeps its edits when you switch commands. AutoQ runs in a Web Worker with a fresh instance per run. The landing page links to it from the hero, the nav and the start of Get started..github/workflows/pages.yml: installs Emscripten, restores the cached Z3/ANTLR build, runswasm/build.shand deployssite/. The generatedautoq.js/autoq.wasmare gitignored. The first run builds Z3, which takes a while; later runs use the cache.wasm/compare.mjsruns every playground example with the native CLI and with the WebAssembly build and checks that the output and exit code match.wasm/README.mddocuments the build and how the browser build differs from native.Testing
node wasm/compare.mjs build/cli/autoq site/playground: all 11 examples print the same output and exit code as the native CLI. A malformed input gives the same error and exit code 1.exprints the README's result set, and switching ver → eq → ex → eq shows the right files and examples and keeps edits. No console errors. Light, dark and phone layouts checked.autoq.wasmis 17 MB, or 5.2 MB gzipped. Download plus compile took under 0.1 s locally, and small examples run in 0.01–0.3 s.ctestpasses (2/2).pages.yml: the first run, which also builds Z3 and ANTLR, took 17m40s. The live page passes the same browser test.Differences from the native build
SIGFPEgivesinf/NaNhere.Try it locally
🤖 Generated with Claude Code
https://claude.ai/code/session_013gtFQRPe1eSSpmA7EJ2KNY