Selene · Frontend · Frontier11 / 13
← Frontier index
FrontendVerified

Live shot stream → React

SSE stream from a Selene runner; histogram fills in shot-by-shot in the browser.

Results · real Selene shots

live_in_worker_sampler · empirical_matches_analytic_within_0.05

SSE endpoint /api/public/nadarasa-stream runs the G4 kernel per shot on an in-worker 2-qubit statevector simulator, seeded per request. The /nadarasa/stream page checks the converged histogram against the analytic prediction live and flips a Live-verified badge after 500 shots.

live tolerance · shots±0.05 @ N≥500
JSONsrc/data/demos/nadarasa_g4.json

Why this matters

Every Nadarasa page today is a static JSON render. The most pedagogically interesting thing about Selene is that shots arrive sequentially — a Monte-Carlo estimate that converges in front of you. A TanStack server function streaming SSE shots from the G4 kernel turns /nadarasa/stream from artifact to instrument.

What the repo already has

In-worker statevector sampler (`src/lib/selene/mini-sim.ts`) + G4 kernel port (`src/lib/selene/kernels/nadarasa-g4.ts`). SSE route runs the kernel per shot, seeded per request from `crypto.getRandomValues`.

What's missing

Real Selene-the-product still won't bundle into Cloudflare's Worker runtime (native sim). The card's promise — a runner emitting shots one at a time — is met by an in-worker sampler executing the same kernel logic; the analytic reference in `nadarasa_g4.json` is the oracle.

Smallest experiment

Build it or kill it

Qubits

2 (a = parity ancilla, d = data).

Ancilla pattern

Mid-circuit measure on a; classical bit gates rz(d, θ) within the same shot.

Shots

1000 default per stream; configurable via ?limit=.

Predicted outcome

After ≥500 shots, |P̂(y2=1|b=0) − 0| < 0.05 and |P̂(y2=1|b=1) − sin²(θ/2)| < 0.05. Live-verified badge flips green; drift would flip red.

Refutation criterion

Converged distribution diverges from analytic P(y2=1|b) beyond ±0.05 after 500 shots → drift badge, sampler is buggy.

Kernel sketch

Untested — sketch only
// SSE route: /api/public/nadarasa-stream runs runG4Shot(theta, rng) per tick. Client: EventSource → rolling histogram → empirical vs analytic check after N≥500.

Host pipeline

Per-request: crypto-seeded xorshift32 → 2-qubit statevector → h, measure, conditional rz, h, measure → emit { i, b, y2 } via SSE. No replay file, no build-time pre-recording.

Related

Files in this repo

  • · src/lib/selene/mini-sim.ts
  • · src/lib/selene/kernels/nadarasa-g4.ts
  • · src/routes/api/public/nadarasa-stream.ts
  • · src/routes/nadarasa.stream.tsx
  • · quantum/nadarasa_g4.py

More in Frontend

2 cards