← mohithgajjela.com
SYSTEM / 03
MOHITH GAJJELA
RECORDED DEMO
replays of emulator runs
SYSTEM 03 / SHOTGATE

A test gate
for quantum programs.

Quantum programs give random outputs, so a test has to check the pattern across thousands of runs. This does that for programs in Quantinuum's Guppy language. Pick a program below and plant a bug.

Guppy programs · Selene emulator · exact binomial and L1 bounds from the standard library · sequential stopping
BELL PAIRS + GHZ STATES + TELEPORTATION + BERNSTEIN-VAZIRANI + RANDOM BITS + 11 PLANTED BUGS + NOISE BUDGETS + BELL PAIRS + GHZ STATES + TELEPORTATION + BERNSTEIN-VAZIRANI + RANDOM BITS + 11 PLANTED BUGS + NOISE BUDGETS +
01THE REPLAY · 5 PROGRAMS, 11 PLANTED BUGS

Pick a program.
Then break it.

Each program is checked two ways: measured normally (Z), and after rotating the qubits (X). Some bugs only show up in one of them.

RECORDED DEMO

These are recordings from Quantinuum's Selene emulator, made . The working code is on GitHub.

WHAT THE REPO DOES

SHOTS SO FAR
observed share what the spec expects error bar on the distance allow detect
REPLAY one recorded run per check · the gate stops at the underlined look; later looks are shown so you can see what it skipped
02HOW IT WORKS · THREE IDEAS

A unit test for code
whose right answer is random.

Picture a CI job for a quantum team. Someone edits a program, the job runs it on an emulator a few thousand times, and it has to say pass or fail. If it fails correct code at random, people learn to hit rerun. If it passes broken code, the bug costs real time on scarce hardware. Shotgate is that CI job.

01 · TEST THE SHAPE

Distance, not equality.

Each test states what a correct program's outputs should look like, for example "00 half the time, 11 half the time, nothing else." The gate measures how far the real outputs are from that, and puts a guaranteed error bar around the number.

02 · TWO LINES

Allowed noise, and a real bug.

Every test has two thresholds. Below allow is drift a correct program can show from noise. Above detect is a bug. The gate fails only when the whole error bar is above allow, and passes only when the whole bar is below detect. Each mistake is held to 1 in 1,000 per check.

03 · STOP EARLY

Spend shots only when it's close.

It runs 250 shots, looks, and doubles until the answer is clear, up to 16,000. An obvious bug fails after 250. A close call takes more. Looking after every batch is paid for in the error budget, so it can't inflate the false alarm rate.

03RESULTS · MEASURED OVER REPEATED RUNS

What it catches,
and what it doesn't cry wolf on.

The replay above is one run per check. These numbers come from repeating every configuration hundreds of times on fresh shots, and comparing against the two tests people usually write: run 1,000 shots and assert that no impossible outcome appears, or that every share is within 2 points of what it should be. Every value here is read from the recorded results when the page loads.

FALSE ALARMS ON CORRECT PROGRAMS

EVERY PLANTED BUG, AND WHICH CHECK CAUGHT IT

HOW SMALL A BUG IT CAN SEE

THE PART I FOUND INTERESTING

04THE REAL THING · THIS PAGE IS A REPLAY

This page is a replay.
The repo is a working test gate.

Selene is a Rust emulator with Python bindings, so it can't run in a browser tab and this page plays back recordings. The code that made them is on GitHub, where it installs with pip, runs its tests on every push, and exits non-zero when a quantum program regresses, the same way a failing unit test does.

01 · WHAT'S IN THE REPO

A gate, a suite, and the proof.

  • shotgate/: three check types (match a distribution, forbid outcomes, hit a probability), exact Clopper-Pearson bounds and an L1 bound written from the definitions, the sequential runner, and a CLI.
  • examples/: five Guppy programs, each with planted bugs, including teleportation with mid-circuit measurement and classically controlled corrections.
  • tests checking the bounds against closed forms and simulation, plus end-to-end runs on Selene.
  • experiments/run.py re-records every number on this page.
02 · WHERE IT WORKS

Any Guppy program, in CI.

  • Python 3.10+ with guppylang and selene-sim from PyPI. Tested on Apple Silicon macOS and on Ubuntu x86-64 in GitHub Actions.
  • Your own programs: write a @guppy function that reports its measurements, state what a correct run looks like, and add it to a suite.
  • Noise: calibrate measures how far a known-good program drifts under a noise model and writes per-test budgets, like a snapshot file.
  • Writes JUnit XML and JSON, so CI shows which check failed and by how much.
03 · WHERE IT DOESN'T

Not real hardware.

  • Emulator only. Nothing here ran on a Quantinuum machine. Real runs go through Nexus and need an account and credits I don't have.
  • A hand-picked noise model. Uniform depolarizing noise I chose, not a model of any real device.
  • Small programs. 2 to 5 qubits. The math doesn't care about size, but a test needs an expected distribution you can write down.
  • You choose the bases. It can't tell you which bases you forgot to check. That turned out to matter most.
# install and run the example suite on the ideal emulator git clone https://github.com/Mohith26/shotgate && cd shotgate pip install -e ".[test]" && pytest -q python -m shotgate run # swap a bug in: exits 1 and names the check that caught it python -m shotgate run --mutant bell:phase --junit report.xml # under noise, with budgets measured from the known-good programs python -m shotgate calibrate && python -m shotgate run --noise --budgets budgets.json
05LIMITS · STATED PLAINLY

What this page cannot
claim.

01

Recorded on an emulator.

Every shot came from Selene on one laptop. Real hardware has noise that isn't uniform, drifts over a day, and depends on how ions move around the chip. A budget calibrated here would need recalibrating against a real machine's noise.

02

The thresholds are mine.

The gate's guarantee is only as useful as the allow and detect values you give it. Here, detect is allow plus 6 points. A bug smaller than detect but bigger than allow can go either way, and the gate reports that zone honestly as inconclusive rather than guessing.

03

The bounds are conservative.

Splitting the error budget evenly across the looks, and the L1 bound used for whole distributions, both cost extra shots over a tighter design. I chose bounds I could check line by line over the tightest ones available.

04

The statistics are standard.

Clopper-Pearson intervals, the Weissman L1 inequality and group-sequential testing are all textbook. What's mine is applying them to Guppy and Selene as a CI gate, the noise calibration, the planted bugs, and measuring where single-basis tests go blind.

Home