wai-quantum-serve 0.5.1: limits a request cannot pass, and a body is read whole or refused #235

Merged
dcharlot merged 1 commit from wai/quantum-serve-limits into main 2026-10-13 06:38:19 -04:00
Owner

Why

Before the component goes online, a request needs bounds it cannot pass. The algorithm library's circuits are small, because its builders clamp to 12 qubits. A caller's own OpenQASM is not: it could name 26 qubits (a 1 GiB statevector) and any number of gates, and /receipt took any number of shots.

There was also a bug: a POST body was cut at 4 MiB, and the cut text was parsed as if it were the whole request.

Change (0.5.1)

Request Answer
POST body over 256 KiB 413, never read in part
circuit on more than 20 qubits 422, before simulating or sealing
circuit of more than 2^27 amplitude updates (gates × 2^n) 422
measurement of more than 1,000,000 shots 422
top above 1024 read as 1024

GET / now states the limits. The module docs say a host should bound the component as well: time per request, memory per instance, and instances at once.

Checked

Native: cargo test --locked --lib, 10 of 10, including four new tests, one for each limit and one for the listing.

Served by wasmtime serve 49.0.1 on the build Mac with -W timeout=10s,max-memory-size=256MiB and a pooling allocator of 8 memories:

  • Every endpoint answers as expected, including the corpus hashes in both capabilities.
  • Every refusal answers as expected, and a tampered receipt gets 409.
  • A circuit exactly at the work limit runs in 1.9 s. At the earlier candidate limit, 2^30, it took 15 s, which is why the limit is 2^27.
  • Of 14 concurrent requests at the work limit, 8 were served in about 2 s and 6 were refused at once by the pool. The server answered normally afterwards.

🤖 Generated with Claude Code

## Why Before the component goes online, a request needs bounds it cannot pass. The algorithm library's circuits are small, because its builders clamp to 12 qubits. A caller's own OpenQASM is not: it could name 26 qubits (a 1 GiB statevector) and any number of gates, and `/receipt` took any number of shots. There was also a bug: a POST body was cut at 4 MiB, and the cut text was parsed as if it were the whole request. ## Change (0.5.1) | Request | Answer | |---|---| | POST body over 256 KiB | 413, never read in part | | circuit on more than 20 qubits | 422, before simulating or sealing | | circuit of more than 2^27 amplitude updates (gates × 2^n) | 422 | | measurement of more than 1,000,000 shots | 422 | | `top` above 1024 | read as 1024 | `GET /` now states the limits. The module docs say a host should bound the component as well: time per request, memory per instance, and instances at once. ## Checked Native: `cargo test --locked --lib`, 10 of 10, including four new tests, one for each limit and one for the listing. Served by `wasmtime serve` 49.0.1 on the build Mac with `-W timeout=10s,max-memory-size=256MiB` and a pooling allocator of 8 memories: - Every endpoint answers as expected, including the corpus hashes in both capabilities. - Every refusal answers as expected, and a tampered receipt gets 409. - A circuit exactly at the work limit runs in 1.9 s. At the earlier candidate limit, 2^30, it took 15 s, which is why the limit is 2^27. - Of 14 concurrent requests at the work limit, 8 were served in about 2 s and 6 were refused at once by the pool. The server answered normally afterwards. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wai-quantum-serve 0.5.1: limits a request cannot pass, and a body is read whole or refused
All checks were successful
standards workspaces build + test / jouledesk-rs (pull_request) Successful in 53s
standards workspaces build + test / jouleclaw-rs (pull_request) Successful in 2m45s
standards workspaces build + test / joule-code-rs (pull_request) Successful in 1m30s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 4m39s
standards workspaces build + test / aac-rs (pull_request) Successful in 2m44s
standards workspaces build + test / joulecontract-rs (pull_request) Successful in 57s
standards workspaces build + test / mesh-rs (pull_request) Successful in 56s
WAI energy receipts / energy receipts · macos (pull_request) Successful in 1m33s
standards workspaces build + test / map-rs (pull_request) Successful in 59s
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Successful in 2m0s
standards workspaces build + test / openpay (pull_request) Successful in 2m56s
lockfiles / every Cargo.lock is current (pull_request) Successful in 35s
no-vanity-metrics / Scan committed Markdown for vanity metrics (pull_request) Successful in 3s
no-vanity-metrics / WAI public text names no comparison (pull_request) Successful in 3s
no-vanity-metrics / WAI public text names no company or product (pull_request) Successful in 3s
standards workspaces build + test / arl-rs (pull_request) Successful in 1m14s
standards workspaces build + test / eoc-rs (pull_request) Successful in 2m8s
standards workspaces build + test / jcp-rs (pull_request) Successful in 1m38s
standards workspaces build + test / joule-ui-rs (pull_request) Successful in 1m15s
standards workspaces build + test / joulehook-rs (pull_request) Successful in 1m17s
standards workspaces build + test / proof-rs (pull_request) Successful in 1m28s
standards workspaces build + test / sense-rs (pull_request) Successful in 1m9s
standards workspaces build + test / sandbox-rs (pull_request) Successful in 2m24s
WAI energy receipts / energy receipts · linux (pull_request) Successful in 2m36s
standards workspaces build + test / smart-byte-rs (pull_request) Successful in 4m18s
3d3ff815c9
A circuit the algorithm library builds is small (its builders clamp to 12
qubits), but a caller's own OpenQASM could name 26 qubits and any number
of gates, and a receipt any number of shots: one request could hold a
host's memory and CPU. Every such request is now refused before it is
simulated or sealed:

- a POST body over 256 KiB: 413. Before, the body was cut at 4 MiB and the
  cut text parsed as if it were the request;
- a circuit on more than 20 qubits, or of more than 2^27 amplitude
  updates (gates × 2^n): 422. Served as a component on an M4 Max core,
  2^30 took 15 s and 2^27 about 2 s;
- a measurement of more than 1,000,000 shots: 422;
- top above 1024 is read as 1024.

GET / states the limits. The module docs say a host should bound the
component too: time per request, memory per instance, instances at once.

Checked under wasmtime serve 49.0.1 with a 10 s timeout, a 256 MiB memory
limit and a pool of 8 memories: every endpoint, every refusal, a tampered
receipt refused, a circuit at the work limit run in 1.9 s, and of 14
concurrent requests at that limit 8 served and 6 refused at once by the
pool, the server unaffected after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Transaction-Science/open-standards!235
No description provided.