HUB
Sign inSign up
quantum-error-mitigation logo

credkellar/quantum-error-mitigation

By credkellar

โ€ขUpdated about 20 hours ago

Quantum Error Mitigation: noise channels, readout calibration, ZNE + Richardson, Shor prep. Sim only

Image
Developer tools
Data science
Monitoring & observability
1

39

credkellar/quantum-error-mitigation repository overview

โ Quantum Error Mitigation โš›๏ธ๐Ÿ›ก๏ธ

Quantum Error Mitigation โ€” Noise Channels, Readout Calibration, and Zero-Noise Extrapolation (Linear + Richardson), plus Shor Circuit-Prep โ€” by Darion Kellar

Educational quantum error mitigation lab in ONE pure-Python file: it simulates four noise channels (depolarizing, bit-flip, phase-flip, amplitude damping) acting on qubit expectation values, calibrates readout error with a measured confusion matrix and removes it by matrix inversion, and recovers noiseless expectation values from deliberately noise-scaled runs by zero-noise extrapolation. The headline numbers, all printed by the program itself: readout total-variation error falls from 0.015000 to 0.000000 after calibration mitigation, and for the ZNE circuit (ideal โŸจZโŸฉ = +0.891207) the raw noisy value at scale 1.0 is +0.774513, linear extrapolation recovers +0.846836, and Richardson extrapolation recovers +0.891162 โ€” within 0.000045 of ideal. A Shor circuit-prep section finds the period classically (N = 15, a = 7 โ†’ period 4 โ†’ factors 3 and 5; N = 21, a = 2 โ†’ period 6 โ†’ factors 3 and 7) and is labelled, in its own output, as a classical simulation of the quantum subroutine โ€” no quantum hardware is claimed anywhere.

Pure Python standard library. Zero dependencies. Zero network. Honest scope: every number here comes from simulated math on a laptop CPU โ€” no real device was run, no hardware error rate is certified, and the Shor section prepares and factors by classical period finding, not by executing a quantum circuit.

โ ๐Ÿงฐ Tech Stack Badges & Full Architecture Tech Stack

โ ๐Ÿ’ป Core Programming Languages & Core Systems

Python Stdlib Only Network Deterministic License Richardson Calibration

  • ๐Ÿ Python 3.12, pure standard library (math, json, sys) โ€” zero dependencies, zero network, deterministic (double-run byte-identical)
  • ๐ŸŽฒ Noise model from config.json: depolarizing 0.02, bit-flip 0.01, phase-flip 0.01, amplitude damping 0.03, each channel applied as its exact expectation-value map
  • ๐Ÿงฎ Readout calibration: per-qubit error rates (e0 = [0.03, 0.04], e1 = [0.05, 0.06]) build the 2-qubit confusion matrix; mitigation is the matrix inverse applied to the measured distribution
  • ๐Ÿ“ˆ Zero-noise extrapolation: expectation values at scale factors [1.0, 1.5, 2.0, 2.5, 3.0] (ฮธ = 1.1), fitted back to zero noise two ways โ€” linear fit and full Richardson extrapolation
  • ๐Ÿ”ข Shor circuit-prep: modular-exponentiation period finding feeding the standard gcd factor extraction, labelled classical simulation in its own output
โ โ›“๏ธ Web3 & Infrastructure
  • ๐Ÿšซ Not applicable โ€” honestly. No blockchain, no Web3, no tokens: the "infrastructure" in this lab is noise arithmetic and matrix inversion inside one offline file. No fake badges here.
โ โš™๏ธ Platform Support & Hardware Architecture

Linux macOS Windows

  • ๐Ÿ–ฅ๏ธ Pure Python โ€” runs anywhere Python 3.12+ runs (Linux, macOS, Windows), plus the python:3.12-slim Docker image
  • ๐Ÿ”’ No quantum hardware is controlled, ever: this is a simulation of mitigation mathematics, not a device driver
โ โšก Low-Level Infrastructure & Performance
  • ๐Ÿšซ No low-level code โ€” honestly. No C, no C++, no GPU, no compiled extensions, and no qiskit: this is one interpreted Python file on purpose, so every channel map, every matrix entry, and every extrapolation weight can be read, checked, and diffed. Performance here means exact arithmetic instead of sampling โ€” the mitigated values are computed, not estimated from shots.
โ ๐Ÿ› ๏ธ DevOps & Build Tools

Docker GitHub Actions pytest Git

  • ๐Ÿณ Docker (python:3.12-slim), GitHub Actions CI + Docker Publish
  • ๐ŸŽฏ Target image: credkellar/quantum-error-mitigation:latest
  • ๐Ÿงช Tests: pytest (35 tests) + the built-in CHECKS suite (20 checks) in main.py
โ โ˜๏ธ Cloud Providers
  • ๐Ÿšซ None โ€” honestly. No cloud provider is used or needed: the lab runs fully offline on your own machine or in a local Docker container. Docker Hub appears only as the registry the publish workflow pushes the image to.

โ ๐Ÿณ Quick start

docker pull credkellar/quantum-error-mitigation:latest
docker run --rm credkellar/quantum-error-mitigation:latest

The default command runs the full demo (noise โ†’ calibration โ†’ ZNE โ†’ Shor).

Run a specific command instead:

docker run --rm credkellar/quantum-error-mitigation:latest python main.py checks    # CHECKS 20/20
docker run --rm credkellar/quantum-error-mitigation:latest python main.py noise     # the four channels and their rates
docker run --rm credkellar/quantum-error-mitigation:latest python main.py calibrate # TV error 0.015000 -> 0.000000
docker run --rm credkellar/quantum-error-mitigation:latest python main.py zne       # raw +0.774513 -> Richardson +0.891162
docker run --rm credkellar/quantum-error-mitigation:latest python main.py shor      # N=15, a=7 -> period 4 -> factors 3, 5

โ ๐Ÿ”ฌ What's inside

  • Four noise channels, exact maps โ€” depolarizing, bit-flip, phase-flip, and amplitude damping, each applied as the closed-form map it induces on expectation values, with rates read from config.json so the whole noise model is one editable file.
  • Readout calibration that actually inverts โ€” the confusion matrix is built from measured per-qubit error rates, checked for invertibility by the built-in checks, and its inverse takes the measured distribution [0.4866, 0.2484, 0.1614, 0.1036] back to the true [0.5, 0.25, 0.15, 0.1] exactly: TV error 0.015000 โ†’ 0.000000.
  • ZNE at five scale factors โ€” โŸจZโŸฉ decays +0.774513 โ†’ +0.726906 โ†’ +0.685443 โ†’ +0.649461 โ†’ +0.618361 as noise scales 1.0 โ†’ 3.0, and both extrapolations are graded against the known ideal +0.891207 in the same output.
  • Linear vs Richardson, side by side โ€” the linear fit recovers +0.846836 (error 0.044371); Richardson recovers +0.891162 (error 0.000045), roughly a thousand times closer, and the program prints both so the difference is a number, not a claim.
  • Shor circuit-prep, honestly labelled โ€” period finding over the modular-exponentiation sequence: N = 15, a = 7 gives period 4 and factors 3 ร— 5; the built-in checks also grade N = 21 = 3 ร— 7. The output itself states the period was found by classical simulation of the quantum subroutine.
  • A referee suite, not just tests โ€” the built-in CHECKS verify the confusion matrix is invertible, that mitigation recovers the true distribution and beats raw readout, that Richardson beats linear, and that a CNOT builds a Bell state โ€” 20/20, alongside 35 pytest tests.

โ โœ… Verified

  • pytest: 35 passed
  • Built-in checks: CHECKS 20/20
  • Deterministic: double-run byte-identical
  • Base image: python:3.12-slim

โ ๐Ÿท๏ธ Categories

Science ยท Developer tools ยท Monitoring & observability

  • License: MIT ยฉ 2026 Darion Kellar
  • Image: credkellar/quantum-error-mitigation:latest
Tag summary
Recent tags
Content type
Image
Digest
sha256:218b90aa8โ€ฆ
Size
41.3 MB
Last updated
about 20 hours ago
docker pull credkellar/quantum-error-mitigation:latest