open-standards/wai/wai-quantum-service/docs/self-host.md
Transaction Science 1b07caf646
All checks were successful
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (pull_request) Successful in 1m47s
standards workspaces build + test / which workspaces this change touches (pull_request) Successful in 8s
wai-audit collector and player integration / does this change touch it (pull_request) Successful in 9s
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (pull_request) Successful in 6s
WAI operation catalogue / does this change touch it (pull_request) Successful in 8s
WAI conformance / does this change touch it (pull_request) Successful in 6s
WAI energy receipts / does this change touch it (pull_request) Successful in 6s
WAI examples / WAI examples · does this change touch them (pull_request) Successful in 9s
wai-quantum command line / does this change touch it (pull_request) Successful in 7s
wai-quantum contract / does this change touch it (pull_request) Successful in 8s
wai-quantum CUDA member / does this change touch it (pull_request) Successful in 7s
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Successful in 23s
wai-quantum dataflow member / does this change touch it (pull_request) Successful in 8s
wai-quantum docs, course and locales / does this change touch it (pull_request) Successful in 8s
wai-quantum signal processor / does this change touch it (pull_request) Successful in 8s
wai-quantum editors / does this change touch it (pull_request) Successful in 8s
wai-quantum resource estimation / does this change touch it (pull_request) Successful in 7s
wai-quantum other formats / does this change touch it (pull_request) Successful in 6s
wai-quantum FPGA member / does this change touch it (pull_request) Successful in 7s
wai-quantum HIP member / does this change touch it (pull_request) Successful in 8s
wai-quantum OpenQASM reader / does this change touch it (pull_request) Successful in 6s
wai-quantum for JavaScript / does this change touch it (pull_request) Successful in 8s
wai-quantum Metal member / does this change touch it (pull_request) Successful in 7s
WAI conformance / delivery telemetry · CMCD and CMSD against an independent library (pull_request) Successful in 32s
wai-quantum OpenCL member / does this change touch it (pull_request) Successful in 6s
wai-quantum npu-cores member / does this change touch it (pull_request) Successful in 10s
wai-quantum neural-processor member / does this change touch it (pull_request) Successful in 9s
wai-audit collector and player integration / collector, player integration and the browser end to end · macos (pull_request) Successful in 1m39s
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Successful in 45s
wai-quantum CUDA member / member · CUDA (jetson-hub) (pull_request) Successful in 1m38s
WAI conformance / cross-arch byte-equality · macos (pull_request) Successful in 33s
wai-quantum CUDA member / member · CUDA (thor) (pull_request) Successful in 2m10s
wai-quantum OpenCL member / member · OpenCL GPU and CPU (jetson-hub) (pull_request) Successful in 42s
WAI conformance / fast integer kernels, every x86_64 kernel set (AVX-512 silicon) (pull_request) Successful in 3m28s
wai-quantum OpenCL member / member · OpenCL GPU and CPU (thor) (pull_request) Successful in 54s
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Successful in 2m25s
wai-quantum on every processor / emulated · loongarch64-unknown-linux-gnu (pull_request) Successful in 3m20s
WAI conformance / codec wrappers · fuzz smoke, text decode limits, C entry points, provenance, the semantic path (pull_request) Successful in 1m55s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 4m54s
wai-quantum HIP member / member · HIP (framework-128gb) (pull_request) Successful in 1m6s
wai-quantum on every processor / emulated · riscv64gc-unknown-linux-gnu (pull_request) Successful in 2m55s
wai-quantum pulse and dynamics / does this change touch it (pull_request) Successful in 8s
wai-quantum for Python / does this change touch it (pull_request) Successful in 9s
wai-quantum OpenCL member / member · OpenCL GPU (framework-128gb) (pull_request) Successful in 28s
wai-quantum error correction and mitigation / does this change touch it (pull_request) Successful in 8s
wai-quantum-qpu / does this change touch it (pull_request) Successful in 7s
wai-quantum on every processor / emulated · powerpc64-unknown-linux-gnu (pull_request) Successful in 4m22s
wai-quantum extension points / does this change touch it (pull_request) Successful in 7s
wai-quantum service / does this change touch it (pull_request) Successful in 8s
wai-quantum matrix-extension member / does this change touch it (pull_request) Successful in 7s
wai-quantum studio and desktop / does this change touch it (pull_request) Successful in 8s
wai-quantum tensor-engine member / does this change touch it (pull_request) Successful in 9s
wai-quantum portable tensor program / does this change touch it (pull_request) Successful in 12s
wai-quantum variational and algorithm library / does this change touch it (pull_request) Successful in 10s
wai-quantum CPU vector units / does this change touch it (pull_request) Successful in 8s
wai-quantum views in agent hosts / does this change touch it (pull_request) Successful in 9s
wai-quantum WebGPU member / does this change touch it (pull_request) Successful in 8s
wai-quantum on every processor / emulated · i686-unknown-linux-gnu (pull_request) Successful in 1m44s
wai-quantum verdicts and repairs / does this change touch it (pull_request) Successful in 14s
WAI Studio / does this change touch it (pull_request) Successful in 6s
wai-sink-android native sink library / does this change touch it (pull_request) Successful in 11s
wai-sink-swift native sink package / does this change touch it (pull_request) Successful in 10s
wai-web wasm32 / does this change touch it (pull_request) Successful in 6s
wai-web reach builds / wai-web reach · does this change touch it (pull_request) Successful in 13s
wai-quantum service / service energy · linux packages (pull_request) Successful in 1m49s
wai-quantum npu-cores member / member · npu-cores, neural processor (framework-128gb silicon) (pull_request) Successful in 2m24s
wai-quantum portable tensor program / tensor program · integrated GPU (framework-128gb) (pull_request) Successful in 17s
wai-quantum portable tensor program / tensor program · GPUs (jetson-hub) (pull_request) Successful in 25s
wai-audit collector and player integration / collector · linux (pull_request) Successful in 1m37s
wai-quantum CPU vector units / member · vector units, avx2 and avx512 (framework-128gb silicon) (pull_request) Successful in 21s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (pull_request) Successful in 1m58s
wai-quantum on every processor / emulated · armv7-unknown-linux-gnueabihf (pull_request) Successful in 7m57s
wai-quantum command line / command line · macos (pull_request) Successful in 4m47s
WAI conformance / cross-arch byte-equality · linux (pull_request) Successful in 38s
WAI conformance / faces from keypoints under wasm32-wasip2 (wasmtime) (pull_request) Successful in 1m45s
wai-quantum on every processor / emulated · powerpc64le-unknown-linux-gnu (pull_request) Successful in 8m40s
WAI operation catalogue / the catalogue and every door · linux (pull_request) Successful in 4m40s
wai-quantum dataflow member / member · dataflow device absent (macos) (pull_request) Successful in 1m30s
WAI conformance / quantum core and corpus under wasm32-wasip2 (wasmtime) (pull_request) Successful in 4m24s
wai-quantum on every processor / emulated · aarch64-unknown-linux-gnu (pull_request) Successful in 11m21s
wai-quantum contract / the policy is linked, and the deprecations page reads (pull_request) Successful in 17s
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (pull_request) Successful in 6m28s
WAI conformance / cargo-class corpora · macos (pull_request) Successful in 12m47s
WAI examples / WAI examples · the archive, the readiness check, the browser and Apple · macos (pull_request) Successful in 10m37s
wai-quantum CUDA member / member · CUDA absent (linux) (pull_request) Successful in 2m52s
wai-quantum FPGA member / member · FPGA datapath, simulated (macos) (pull_request) Successful in 1m2s
wai-quantum contract / API compatibility · linux (pull_request) Successful in 4m31s
wai-quantum OpenCL member / member · OpenCL GPU (macos) (pull_request) Successful in 24s
wai-quantum dataflow member / member · dataflow device, simulated (pci 1e52:401e) (pull_request) Successful in 3m41s
wai-quantum pulse and dynamics / the same bits · macos (pull_request) Successful in 1m1s
wai-quantum editors / editors · macos (pull_request) Successful in 5m39s
wai-quantum docs, course and locales / the Studio's words in every locale · linux (pull_request) Successful in 22s
wai-quantum docs, course and locales / the course and the command line's languages · linux (pull_request) Successful in 1m59s
wai-quantum Metal member / member · Metal (macos) (pull_request) Successful in 50s
wai-quantum command line / command line · linux (pull_request) Successful in 7m27s
wai-quantum-qpu / credentials in the keychain (macos) (pull_request) Successful in 37s
WAI energy receipts / energy receipts · macos (pull_request) Successful in 14m19s
wai-quantum contract / schemas and the committed tool lists · linux (pull_request) Successful in 7m18s
wai-quantum on every processor / emulated · s390x-unknown-linux-gnu (pull_request) Successful in 16m33s
WAI conformance / each feature of the independent verifiers' steps compiles alone (pull_request) Successful in 18m44s
wai-quantum for Python / python · macos (pull_request) Successful in 2m11s
wai-quantum matrix-extension member / member · matrix extension absent (macos) (pull_request) Successful in 14s
standards workspaces build + test / joule-code-rs (joule-code/joule-code-rs, joule-code-rs, linux-arm64, true) (pull_request) Successful in 19m29s
wai-quantum portable tensor program / tensor program · Metal and the arm64 CPU (macos) (pull_request) Successful in 19s
wai-quantum dataflow member / member · dataflow device, simulated (pci 1e52:b140) (pull_request) Successful in 6m58s
wai-quantum CPU vector units / member · vector unit absent (macos) (pull_request) Successful in 18s
wai-quantum editors / editors · linux (pull_request) Successful in 2m8s
wai-quantum neural-processor member / member · neural processor (macos) (pull_request) Successful in 4m29s
wai-quantum HIP member / member · HIP absent (linux-arm64) (pull_request) Successful in 54s
wai-quantum FPGA member / member · FPGA simulation absent (linux) (pull_request) Successful in 50s
wai-quantum npu-cores member / member · npu-cores absent (linux-arm64) (pull_request) Successful in 26s
wai-quantum WebGPU member / member · DX12 and Vulkan (cbio-windows) (pull_request) Successful in 13m9s
wai-quantum on every processor / emulated · sparc64-unknown-linux-gnu (pull_request) Successful in 17m49s
wai-quantum WebGPU member / member · integrated GPU, Vulkan (framework-128gb) (pull_request) Successful in 13m13s
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Successful in 17m15s
wai-quantum other formats / the set under wasm32-wasip2 (wasmtime) (pull_request) Successful in 2m51s
WAI examples / WAI examples · portable · linux (pull_request) Successful in 11m50s
wai-quantum WebGPU member / member · browser WebGPU (macos) (pull_request) Successful in 2m24s
wai-quantum pulse and dynamics / the same bits · linux-arm64 (pull_request) Successful in 1m38s
WAI conformance / cargo-class corpora · linux (pull_request) Successful in 15m51s
wai-quantum OpenCL member / member · OpenCL absent (linux) (pull_request) Successful in 25s
wai-quantum resource estimation / estimation and calibration · linux, release (pull_request) Successful in 4m32s
wai-quantum tensor-engine member / member · tensor engine absent (linux-arm64) (pull_request) Successful in 20s
wai-quantum Metal member / member · Metal absent (linux) (pull_request) Successful in 53s
wai-quantum service / service · macos (pull_request) Successful in 4m14s
wai-quantum neural-processor member / member · neural processor absent (linux) (pull_request) Successful in 19s
wai-quantum studio and desktop / desktop app · macos (pull_request) Successful in 3m48s
wai-quantum for JavaScript / javascript · linux (pull_request) Successful in 3m0s
wai-quantum OpenQASM reader / corpus under wasm32-wasip2 (wasmtime) (pull_request) Successful in 1m32s
wai-quantum WebGPU member / member · Metal (macos) (pull_request) Successful in 3m33s
wai-quantum other formats / readers, writers and the set · linux (pull_request) Successful in 4m54s
wai-quantum-qpu / clients against their contracts (linux) (pull_request) Successful in 55s
wai-quantum pulse and dynamics / reader, simulator and pulse jobs · linux, release (pull_request) Successful in 1m36s
wai-quantum OpenQASM reader / reader and corpus · linux (pull_request) Successful in 3m47s
wai-quantum matrix-extension member / member · matrix extension, emulated (aarch64 Linux) (pull_request) Successful in 24s
wai-quantum variational and algorithm library / parameters, gradients, optimisers, VQE, QAOA and builders · linux-arm64, release (pull_request) Successful in 1m53s
wai-quantum extension points / the registry and the example · linux-arm64 (pull_request) Successful in 2m56s
wai-quantum pulse and dynamics / reader, simulator and pulse jobs under wasm32-wasip2 (wasmtime) (pull_request) Successful in 2m4s
WAI examples / WAI examples · android-app · linux-arm64 (pull_request) Successful in 5m44s
wai-quantum extension points / the registry under wasm32-wasip2 (wasmtime) (pull_request) Successful in 1m0s
wai-quantum error correction and mitigation / codes, decoders, texts and mitigation · linux, release (pull_request) Successful in 2m32s
wai-quantum portable tensor program / tensor program · CPU, mutants, GPU builds (pull_request) Successful in 32s
wai-quantum CPU vector units / member · vector unit, rvv 1024-bit (riscv64, emulated) (pull_request) Successful in 26s
wai-quantum CPU vector units / member · vector unit, sve 128-bit (aarch64, emulated) (pull_request) Successful in 48s
wai-quantum variational and algorithm library / parameters, gradients, optimisers, VQE, QAOA and builders · linux, release (pull_request) Successful in 1m28s
wai-quantum CPU vector units / member · vector unit, rvv 128-bit (riscv64, emulated) (pull_request) Successful in 15s
wai-quantum CPU vector units / member · vector unit, sve 2048-bit (aarch64, emulated) (pull_request) Successful in 24s
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Successful in 27m2s
wai-sink-android native sink library / the JNI layer and the platform-free half on the host JVM · linux-arm64 (pull_request) Successful in 2m40s
wai-quantum CPU vector units / member · vector unit, avx2 (x86_64 silicon) (pull_request) Successful in 22s
wai-quantum CPU vector units / member · vector unit, sve 512-bit (aarch64, emulated) (pull_request) Successful in 10s
WAI Studio / Studio in Chromium and Firefox · macos (pull_request) Successful in 7m43s
wai-quantum for Python / python · linux (pull_request) Successful in 5m12s
wai-quantum service / service · linux (pull_request) Successful in 5m3s
wai-sink-android native sink library / every ABI, the AAR, and the instrumented tests in a headless emulator · macos (pull_request) Successful in 7m10s
wai-quantum extension points / the registry and the example · linux (pull_request) Successful in 6m26s
wai-quantum WebGPU member / member · GPU, Vulkan (jetson-hub) (pull_request) Successful in 22m27s
wai-quantum WebGPU member / member · software Vulkan (linux) (pull_request) Successful in 1m44s
wai-quantum views in agent hosts / views · a scripted host (pull_request) Successful in 3m20s
wai-quantum WebGPU member / member · GPU, Vulkan (thor) (pull_request) Successful in 24m37s
wai-quantum views in agent hosts / views · the page and its engine (pull_request) Successful in 3m28s
wai-quantum studio and desktop / desktop app · linux (pull_request) Successful in 6m33s
wai-quantum studio and desktop / desktop app · windows (pull_request) Successful in 10m41s
wai-quantum studio and desktop / studio · browser (pull_request) Successful in 7m11s
WAI Studio / the catalogue's actions, the unit tests and the core · linux (pull_request) Successful in 53s
wai-quantum verdicts and repairs / the intent set and the verdict under wasm32-wasip2 (wasmtime) (pull_request) Successful in 1m16s
wai-quantum WebGPU member / shader checks · browser build · wasip2 inertness · MSRV (pull_request) Successful in 6m7s
wai-quantum verdicts and repairs / verdicts, repairs and the intent set · linux (pull_request) Successful in 4m34s
wai-web reach builds / wai-web reach builds · this tree's wai-web, every rung on its engine line (pull_request) Successful in 4m22s
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Successful in 6m6s
wai-sink-swift native sink package / libwai slices, desktop tests, simulator tests · macos (pull_request) Successful in 15m40s
WAI energy receipts / energy receipts · linux (pull_request) Successful in 28m44s
wai-web reach builds / wai-web reach builds · the package of record, every output as recorded (pull_request) Successful in 7m43s
wai-quantum tensor-engine member / member · tensor engine, the kernel toolchain's simulator (linux) (pull_request) Successful in 15m29s
WAI Studio / Studio in WebKit · linux (pull_request) Successful in 10m43s
wai-quantum signal processor / processor and member · signal processor, emulated (pull_request) Successful in 27m43s
wai-quantum docs, course and locales / every command and snippet in the docs · linux (pull_request) Successful in 30m9s
WAI conformance / independent verifiers · claims, JWP, key discovery and integer payloads (Python) (pull_request) Successful in 1h31m15s
wai-quantum-service: a job the service was running when it stopped runs once more
A job that was running when the service stopped came back interrupted,
its request kept, and nothing ran it again unless its client sent it
again. Since the engine gives the same result for the same request, the
service now runs it again itself: on start, a job that was running is
queued again in its order, to run once more from its stored request, and
its `interruptions` say when the service stopped. Stopped again while it
runs once more, it comes back interrupted with the reason and is not run
a third time (RERUNS = 1), so a job that stops the service whenever it
runs does not run for ever. GET /v1's `restored` counts the jobs run
again.

wai.quantum.job/1 now lists `interrupted` among its statuses, which the
service has returned since its jobs were kept across restarts, and the
optional `interruptions`.

Also: the store's pseudonym test held the hex of a keyed hash to not
containing "203", three digits of the address, which a random key gives
about once in 140 runs. It now holds it to hex, which cannot spell the
address.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 10:27:04 -05:00

12 KiB

Running the quantum job service yourself

The job service at https://wai.transaction.science/quantum-jobs is free and takes no account and no key. You can also run the same service on your own machine or in your own network, for a lab, a course, or work that should not leave your premises. This page says how: the binary or the image, its configuration, where it keeps jobs, its keys, and how to put it behind a reverse proxy.

Run it

From a checkout of the repository, with the toolchain rust-toolchain.toml names:

cd wai/wai-quantum-service
cargo build --locked --release
./target/release/wai-quantum-service serve          # 127.0.0.1:8241
bash smoke.sh http://127.0.0.1:8241                  # its promises, checked over HTTP

Or as an OCI image, built from the repository's wai/ directory (deploy/Containerfile):

docker build -f wai/wai-quantum-service/deploy/Containerfile -t wai-quantum-service wai/
docker run -d --name wai-quantum -p 127.0.0.1:8241:8241 \
  -v wai-quantum:/var/lib/wai-quantum-service \
  --read-only --tmpfs /tmp --cap-drop ALL --security-opt no-new-privileges \
  wai-quantum-service

podman takes the same commands. The image's build stage and run stage are each pinned by digest, the build uses the locked dependencies with paths remapped and the timestamp fixed, and the run stage holds the binary alone, run as an unprivileged user. bash wai/wai-quantum-service/deploy/check-image.sh builds the image, runs it, holds it to the smoke checks, restarts it to check that it keeps its jobs, and removes everything it made. It pushes nothing.

Each job runs in a child process of the same binary, at a lower scheduling priority than the host's other work, watched for its memory and its time. On macOS the child also runs in a sandbox with no network, no file writes and no other programs. Elsewhere, run the service in a container (as above) or under a service manager that confines it: it needs to listen on its port and to write its store, and nothing else.

Configure it

Everything is set by environment variables.

variable default meaning
WAI_QSVC_ADDR 127.0.0.1:8241 the address it listens on (0.0.0.0:8241 in the image)
WAI_QSVC_PUBLIC_BASE the public service's the URL it is reached at, for the links it hands out
WAI_QSVC_CONSOLE the public console the page a browser at / is sent to
WAI_QSVC_STORE ~/.local/share/wai-quantum-service/store the job store's directory, or memory to keep jobs only while the process runs
WAI_QSVC_RETAIN_SECS 86400 how long a finished job is kept
WAI_QSVC_KEY ~/.config/wai-quantum-service/signing.key the receipt key, created on first start
WAI_QSVC_API_KEYS unset (no keys) a file of API keys: set it and every request needs one
WAI_QSVC_TRUSTED_PROXIES 127.0.0.1,::1 peers whose X-Forwarded-For names the client
WAI_QSVC_ENERGY 1 0 meters no job's energy
WAI_QSVC_BUDGET_GB 96 the memory running jobs share
WAI_QSVC_JOB_GB 72 the memory one job may take
WAI_QSVC_WORKERS 4 jobs running at once
WAI_QSVC_MIN_FREE_PCT 15 the share of the host's memory a starting job must leave free
WAI_QSVC_JOB_SECS 900 the longest a job (or a whole set) may run
WAI_QSVC_CLIENT_ACTIVE 3 queued or running jobs one client may hold
WAI_QSVC_CLIENT_GB the job size the memory one client's jobs may hold together
WAI_QSVC_CLIENT_BURST 30 submissions one client may make in a window
WAI_QSVC_CLIENT_WINDOW_SECS 600 the window
WAI_QSVC_MAX_QUEUE 256 jobs waiting at once
WAI_QSVC_SANDBOX 1 0 runs the macOS worker unsandboxed, for debugging

Size the memory to the host: WAI_QSVC_BUDGET_GB below the host's memory, WAI_QSVC_JOB_GB at or below it. GET /v1 states every limit in force, and a dry run ("dry_run": true) states the ones a job meets.

The job store

Every job is written to the store before the request that admitted it is answered, and again at every change of its status. Programs, requests, results and receipts are kept content-addressed, each under the BLAKE3 digest of its bytes: a program's text, or the RFC 8785 canonical text of a request, a result without its receipt, or a receipt. A job's report names them under digests.

<store>/LOCK                    held while a process serves the store
<store>/client.key              the key client names are hashed with
<store>/objects/<ab>/<digest>   each object, named by its digest
<store>/jobs/<id>.json          each job's record
  • Writes are whole. Every file is written under a temporary name, synced, renamed into place, and its directory synced, so a crash leaves the old file or the new one. A second process on the same store is refused.
  • A restart loses nothing it answered. On start the service reloads the store. A finished job is served as it was, and its receipt still verifies. A job that was running is run again, once, from its stored request: it is queued again in its order, and its interruptions say when the service stopped. Stopped again while it runs once more, it comes back interrupted, with the reason; its request is kept, and sent again it runs to the same result. A queued job is queued again, in its order. A worker whose service has gone stops itself.
  • Objects are checked. An object is checked against its digest when it is read, and a record that does not read is set aside, not served.
  • Retention. A finished job is kept for WAI_QSVC_RETAIN_SECS, then dropped with every object no other job names.
  • No addresses. A record names its client by a keyed hash of the client's address, so it can count the client's limits after a restart and says nothing else.
  • Backups. Copy the store's directory while the service is stopped, or, while it runs, copy jobs/ first and objects/ after it: an object is never changed once written, and a record names only objects written before it.

Another kind of store is anything that implements the Store trait in src/store.rs: keep an object by its digest, read it back checked, keep and list the records, and sweep what no record names.

The receipt keys

Every result is sealed with the service's Ed25519 key, and the receipt names that key (key, in hex). The key set, every key the service has signed with, is published at GET /.well-known/wai-quantum-receipt-keys. It sits beside the key file as <key>.keys.json.

{ "format": "wai.quantum.receipt-keys/1", "algorithm": "ed25519",
  "keys": [
    { "key": "9f…", "did": "did:key:z6Mk…", "not_before_ms": null, "not_after_ms": 1793000000000,
      "successor": "4c…", "current": false,
      "transition": { "statement": { "format": "wai.quantum.key-transition/1", "retiring": "9f…", "successor": "4c…", "at_ms": 1793000000000 },
                      "retiring_signature": "…", "successor_signature": "…" } },
    { "key": "4c…", "did": "did:key:z6Mk…", "not_before_ms": 1793000000000, "current": true } ] }

To rotate the key, run wai-quantum-service rotate-key with the same WAI_QSVC_KEY, then restart the service. The rotation does four things:

  • It retires the current key. Its entry stays in the set with its window closed (not_after_ms), so receipts it signed still verify and can be placed in time.
  • It makes a new key, whose window opens at the same moment.
  • It writes a transition statement naming both keys and the moment, signed by each under the domain wai:quantum-key-transition (version 1). Whoever trusted the old key can check that the new one came from its holder.
  • It moves the old private key aside to <key>.retired-<ms>. The service never reads that file again, and you may destroy it.

not_before_ms is null for a key that signed before the set was kept. A key file replaced by hand is taken as current at the next start, and the old key is retired with no transition, which its entry says. The service refuses to start on a set whose recorded transition does not verify. A result itself carries no wall-clock time, so a receipt is placed in a key's window by the job's finished_ms or by your own record of when you received it.

API keys, for a private deployment

The public service takes no key, and nothing changes for it. A private deployment can require one. Make a key for each holder:

wai-quantum-service api-key lab-scheduler
# {"name": "lab-scheduler", "key": "3b9…", "line": "lab-scheduler 7f0…", …}

Hand key to its holder, and add line to the file WAI_QSVC_API_KEYS names. The file holds each key's BLAKE3 digest, never the key. With the variable set:

  • every request but the open ones carries Authorization: Bearer <key>, or is refused with 401 and J033. The open ones are /, /v1, /v1/health, /v1/methods, /v1/openapi.json and the receipt keys.
  • a client's limits are counted by its key's name, not its address, so one gateway or scheduler is one client wherever it connects from.

The command line sends a key with --api-key or WAI_QUANTUM_API_KEY.

Energy

Each finished job carries its energy inside the signed result: a counter reading with its class, its scope and its declared uncertainty, or {"unmetered": "<why>"}, never zero. GET /v1 says how this host meters (energy).

  • macOS: the kernel's count of the worker process's own CPU energy (attribution: process).
  • Linux: the processor packages' energy counters, read through the kernel's power-capping interface before the worker starts and after it exits. They count whole packages, so the figure is the packages' energy over the job's window, every process on the host included, with no attribution to the job (attribution: none). It names how many other jobs ran in the window (concurrent_jobs). The counter is used only when every package zone reads and its count is live; its declared uncertainty covers the two reads and the counter's update edges, measured at start.
  • Permissions: many Linux hosts let only root, or a group such as energy, read the count. Add the service's user to that group. In a container the interface is usually hidden; a container that should meter needs it visible and readable, which widens what the container sees of the host. Without it, jobs say they are unmetered and why.

Behind a reverse proxy

Run the service on a loopback address and let the proxy take the public traffic.

  • The client's address. The proxy sets X-Forwarded-For, and the service trusts it only from WAI_QSVC_TRUSTED_PROXIES. Have the proxy set the header from the connection itself, not pass on what the request carried, or a client could choose its own limits.
  • A path prefix. Mount the service under a prefix (the public one is /quantum-jobs) by stripping the prefix before passing the request on. Set WAI_QSVC_PUBLIC_BASE to the prefixed URL, so the links the service hands out are right. A well-known path belongs at the origin's root: map /.well-known/wai-quantum-receipt-keys there to the service's own.
  • Event streams. GET /v1/jobs/{id}/events is a server-sent event stream. The proxy must pass it through unbuffered (the service sends X-Accel-Buffering: no and a comment every 15 s), and allow it to stay open as long as WAI_QSVC_JOB_SECS. Polls with ?wait= are held up to 25 s.
  • Bodies. A request body is at most 1 MiB, and POST /v1/run waits up to 25 s before answering 202.
  • Rate-limit fields. Pass the RateLimit-Policy, RateLimit and Retry-After headers through.

A minimal site, in one common proxy's configuration format:

quantum.example.org {
    handle_path /quantum-jobs/* {
        reverse_proxy 127.0.0.1:8241 {
            header_up X-Forwarded-For {remote_host}
            flush_interval -1
        }
    }
}

Check it

bash wai/wai-quantum-service/smoke.sh https://quantum.example.org/quantum-jobs
wai-quantum submit prog.qasm --service https://quantum.example.org/quantum-jobs --dry-run

The command line's submit, task and verify work against any instance; verify checks a receipt offline against the key the receipt names, and the key set says when that key signed.