HUB
Sign inSign up
measurementbasedqc-lab logo

credkellar/measurementbasedqc-lab

By credkellar

โ€ขUpdated 8 days ago

MeasurementBasedQC-Lab: MBQC lab - cluster states, one-way wires, J-gate patterns, frames. Sim only!

Image
Machine learning & AI
Developer tools
Data science
1

47

credkellar/measurementbasedqc-lab repository overview

โ MeasurementBasedQC-Lab ๐Ÿงฎโš›๏ธ

Measurement-Based Quantum Computing Lab โ€” Cluster States, One-Way Wires, J-Gate Patterns & Pauli-Frame Feed-Forward โ€” by Darion Kellar

Educational measurement-based quantum computing lab in ONE pure-Python file: the cluster state is built first (|+>^n plus one CZ per graph edge โ€” chains to 6 qubits, 2x3 and 3x3 patches) and every stabilizer K_a = X_a prod Z_neighbours is applied to the built state, returning deviation exactly 0.00e+00 at every site while a product state fails the same test. From there the only operations are single-qubit measurements, and the lab proves the model by enumeration, not sampling: every measurement branch of every pattern is run, each outcome probability is asserted 1/2 (worst deviation 6.11e-16), and the corrected output is graded against direct gate application on a 14-state input grid. The one-way wire gives H in 1 step and the identity in 2 and 4 steps (corrected deviation at most 5.55e-16); two J-steps give exact Rz and Rx rotations; three give H.Rz.Rx.Rz and four give the exact Euler form Rz.Rx.Rz. Feed-forward angles follow phi = -(-1)^x * alpha + pi * z from a Pauli frame that is tracked as a matrix and asserted to stay a Pauli at every step, and every branch's frame is fitted to an affine function of the outcome bits over GF(2). The two-qubit result is stated exactly as it computes: the 2x3 patch with all-X measurements implements (H x H) CZ (H x H) โ€” a CZ in the Hadamard frame, locally equivalent to CZ, maximally entangling (concurrence of U|00> = 1.0), NOT a bare CZ โ€” and (H x H).U.(H x H) = CZ to 8.88e-16, so the patch plus Hadamard patterns is exactly CZ.

Pure Python standard library. Zero dependencies. Zero network. Honest scope: an exact statevector simulation of small patterns (at most 9 qubits) โ€” no real quantum hardware was touched, no quantum advantage is claimed, and no pattern here is a fault-tolerance or compiler product. Every hardware / cloud-service / blind-computing / cryptographic / advantage use is a permanent HOLD gate (14 total).

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

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

Python Stdlib Only Network Deterministic License Branches Frame

  • ๐Ÿ Python 3.12, pure standard library (cmath, math, hashlib, json, sys) โ€” zero dependencies, zero network, deterministic (double-run byte-identical)
  • โš›๏ธ Statevector core from scratch: flat complex amplitude lists (qubit q = bit q), single-qubit gates, CZ, XY-plane measurement with basis rotation back to computational form โ€” no library quantum code anywhere
  • ๐Ÿงฉ Cluster builder: |+>^n plus one CZ per graph edge (chains to 6 qubits, 2ร—3 and 3ร—3 patches), with the stabilizer receipt K_a = X_a โˆ Z_neighbours applied to the built state operator-by-operator
  • ๐Ÿ“ Pattern engine: J-gate steps J(ฮฑ) = HยทRz(ฮฑ), feed-forward angle rule ฯ† = โˆ’(โˆ’1)^xยทฮฑ + ฯ€ยทz, and a Pauli frame tracked as a matrix (Pโ€ฒ = X^sยทJ(โˆ’ฯ†)ยทPยทJ(ฮฑ)โปยน) and asserted to stay inside the Pauli group at every step
  • ๐Ÿ”€ Branch enumeration: all 2^m outcome branches run deterministically โ€” the seeded splitmix64 PRNG (seed 20261119) only picks probe input states, it never samples a branch
  • ๐Ÿง  TinyML kNN pattern classifier (from scratch, stdlib, distance-weighted): resource-state / wire / single-step-gate / rotation-gate / entangling-gate from (measurements, outputs, cross edges, nonzero angles), labels from the lab's own policy
  • ๐Ÿช‘ Council seats: Gemini Argon 4 DECIDER (names-only, tighten-only) + Muse advisor (never overrides HOLD) + Google Flow plan-only (rendered = False, live = 0)
โ โ›“๏ธ Web3 & Infrastructure
  • ๐Ÿšซ Not applicable โ€” honestly. No blockchain, no Web3, no tokens: the "infrastructure" in this lab is one offline file holding a cluster state and a measurement-pattern engine. Quantum-hardware control, cloud quantum services, and blind-computing services are permanent HOLD gates, not features. 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 hardware is controlled, ever: real photonic processors, cluster-state sources, and detectors are permanent HOLD gates (see the gate table below)
โ โšก Low-Level Infrastructure & Performance
  • ๐Ÿšซ No low-level code โ€” honestly. No C, no C++, no GPU, no compiled extensions: this is one interpreted Python file on purpose, so every amplitude can be read, checked, and diffed. Performance here means honest algorithms โ€” exhaustive branch enumeration instead of Monte Carlo, exact Pauli-frame matrix tracking instead of post-hoc fitting, and an affine GF(2) fit that either holds on all 16 patch branches or fails the build.
โ ๐Ÿ› ๏ธ DevOps & Build Tools

Docker GitHub Actions pytest Git

  • ๐Ÿณ Docker (python:3.12-slim), GitHub Actions CI + Docker Publish (delivered in the paste pack)
  • ๐ŸŽฏ Target image: credkellar/measurementbasedqc-lab:latest
  • ๐Ÿงช Tests: pytest (22 tests) + the built-in CHECKS suite (48 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/measurementbasedqc-lab:latest
docker run --rm credkellar/measurementbasedqc-lab:latest

The default command runs the full demo plus the built-in self-checks (CHECKS 48/48).

Run a specific command instead:

docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py checks   # CHECKS 48/48
docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py cluster  # cluster states + stabilizer receipts (JSON)
docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py wire     # one-way wire reports, 1/2/4 steps (JSON)
docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py gates    # H / Rz / Rx / Euler pattern reports (JSON)
docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py cz       # 2x3 patch: target, frames, concurrence (JSON)
docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py frame    # Pauli-frame tables + affine fits (JSON)
docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py classify # kNN verdicts: resource / wire / rotation / entangling
docker run --rm credkellar/measurementbasedqc-lab:latest python3 main.py holds    # 14 HOLD gates

โ ๐Ÿ”ฌ What's inside

  • Cluster states, receipted โ€” chains (2โ€“6 qubits) and 2ร—3 / 3ร—3 patches; every stabilizer K_a applied to the built state returns deviation exactly 0.00e+00, single-qubit marginals are maximally mixed (purity 0.5), and a product state fails the same stabilizer test at deviation > 0.5.
  • Randomness, priced โ€” every XY-plane measurement in every pattern is 50/50 to within 6.11e-16; branches are enumerated (2^m of them), never sampled; the seeded splitmix64 PRNG (seed 20261119) only picks probe input states.
  • The one-way wire โ€” 1 step = H, 2 steps = identity, 4 steps = identity, on every branch ร— 14 inputs, corrected deviation at most 5.55e-16.
  • Gate patterns โ€” Rz(theta) for theta in {0.7, -1.3, pi/3} and Rx(theta) for theta in {0.7, -2.0} from two J-steps; H.Rz.Rx.Rz from three; the exact Euler Rz.Rx.Rz from four โ€” all graded against independently built matrix products.
  • Feed-forward with a referee โ€” angles follow phi = -(-1)^x * alpha + pi * z; the Pauli frame is tracked as a matrix (P' = X^s . J(-phi) . P . J(alpha)^-1) and asserted to stay in the Pauli group at every step, so a wrong angle rule would fail the build, not just the answer.
  • The patch, honestly named โ€” (H x H) CZ (H x H): 16 branches ร— 10 input pairs correct to 6.66e-16; distance from bare CZ is itself a check (> 0.5); the H-sandwich recovers CZ to 8.88e-16; concurrence of U|00> = 1.0 (maximally entangling), of U|++> = 0.0.
  • Frames as data โ€” wire, Euler, and patch frame tables all fit affine functions of the outcome bits over GF(2); worked example: Euler branch 1010 on |+i> is off by 0.1486 uncorrected and by 3.33e-16 after the predicted Z correction.
  • Adversarial frame extraction โ€” Pauli-eigenstate inputs admit spurious frames, so patch frames are found by intersecting candidate sets over generic seeded probes until exactly one Pauli survives per branch.
  • TinyML kNN classifier โ€” resource-state / wire / single-step-gate / rotation-gate / entangling-gate from (measurements, outputs, cross edges, nonzero angles); agreement with the lab's policy asserted on every scenario and all 120 training-grid rows.
  • Advisory seats โ€” Gemini Argon 4 DECIDER (names-only, tighten-only, sha256 trace), Muse advisor (can never override HOLD), Google Flow plan-only (rendered = False, live = 0).

โ โœ… Verified

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

โ ๐Ÿท๏ธ Categories

Science ยท Developer tools ยท Machine learning & AI

  • License: MIT ยฉ 2026 Darion Kellar
  • Image: credkellar/measurementbasedqc-lab:latest
Tag summary
Recent tags
Content type
Image
Digest
sha256:565e33458โ€ฆ
Size
41.3 MB
Last updated
8 days ago
docker pull credkellar/measurementbasedqc-lab:latest