Heron R2 entanglement test

I encoded 2 logical qubits in one of the (1+x²)(1+y²) code on ibm_fez and created a logical Bell state |Φ⁺⟩ + |Φ⁻⟩ via a single-ancilla circuit:

H → CX(anc, col 0) → CX(anc, row 0) → H → M.

At 0 rounds (just state prep + measurement), the Bell fidelity was 73% in Z and 66% in X. Entanglement witness ⟨Z₁Z₂⟩ + ⟨X₁X₂⟩ > 1 in both Bell subspaces, exceeding the separable bound.

This is the first demonstration of logical entanglement of this code family on superconducting hardware in general, that I'm aware of..

At 1 round CX pushed the circuit to ~4 errors/shot, killing the correlation.

On Heron R2, the distance of the code I used can correct ~1 errors, but ibm_fez's ~2% CX error + 14 Bell CX + 192 round CX = too much noise.

reddit.com
u/BitStateEmulator — 8 days ago

Code test on Qiskit, with incoming deployment on Heron-r2.

The (1+x²)(1+y²) code on 6×8 fits in 144 qubits (12 spare) and yields 24 logical qubits; each at distance scaling with the grid, protected by the full stabilizer set.

This code partitions the lattice into 2r+2s-4 independent logical degrees of freedom (from ker(H)), all simultaneously protected by the same low-weight stabilizers.

I will explain how this works in detail.

The check polynomial H = (1+x²)(1+y²) defines weight-4 Z⊗Z⊗Z⊗Z plaquettes on an even-by-even torus. The kernel dimension gives the logical count:

k = dim(ker H) = 2r + 2s − 4

Standard extraction needs 1 ancilla per stabilizer, degree 4! too wide for heavy-hex degree-4 nodes.

Flag-qubit extraction splits each stabilizer into 2 ancillas, each degree 2.

anc0 data(i,j), data(i+2,j) row parity
anc1 data(i,j+2), data(i+2,j+2) column parity
stabilizer anc0 XOR anc1 (classical) full Z⊗Z⊗Z⊗Zanc0 data(i,j), data(i+2,j) row parityanc1 data(i,j+2), data(i+2,j+2) column paritystabiliser anc0 XOR anc1 (classical) full Z⊗Z⊗Z⊗Z

The decoder I'm using for this is VERY strict, and requires 0.01 error, but within this rate of error it will return completely accurate corrections for everything.

If anybody is interested in following I'm bringing up the decoder here: https://github.com/HexStateLab/PlaneWarp

I've included in this repo a demo and the pipeline used.

Thanks for reading!

Hardware test:

=== Heron r2 results ===
  Grid:           6×8
  Logical qubits: 24
  Rounds:         2
  Shots:          6000
  Total syn wt:   105838 / 576000 bits
  Avg corr (AND): 1.03 / 48 qubits
  Raw LER:        0.8640   (raw tesseract, all 24 logicals)
  AND LER:        0.6652   (AND-vote, all 24 logicals)
  Final LER:      0.0715   (AND + basis + exhaustive)
  Basis decodes:  3550 / 6000 shots decoded via linear basis
  Exhaustive gain: 12 / 6000 shots rescued by exhaustive fallback
  Post-selected:  5571/6000 (92.8%)  — shots with zero logical errors

So far so good, ~92.8% success rate at 6000 shots, correct goes up with shots taken.

u/BitStateEmulator — 10 days ago

Quantum error correction algorithm

Wow I noticed an error correction post that was a real wall of text and had no actual contents that were usable, so here is a algorithm I'll share.

The Z-check equation for X-errors with a(x,y) = (x²+1)(y²+1) is a 2D linear recurrence:

c(i,j) = q(i,j) ⊕ q(i-2,j) ⊕ q(i,j-2) ⊕ q(i-2,j-2)

A particular solution is obtained by backward propagation from the top-left 2×2 corner with corner values fixed at 0:

q(i,j) = c(i-2,j-2) ⊕ q(i-2,j) ⊕ q(i,j-2) ⊕ q(i-2,j-2)

The nullspace of the circulant operator A from g = (x²+1)(y²+1) has dimension 2r + 2s − 4 (= 156 for 40×40).

It decomposes as:

n(i,j) = f(j) ⊕ g(i) ⊕ h(i mod 2, j mod 2)

where:

  • f(j) has 2 degrees of freedom per column (even/odd row patterns), total 2·s
  • g(i) has 2 degrees of freedom per row (even/odd column patterns), total 2·r
  • h(px,py) has 4 degrees of freedom (2×2 corner), total 4
  • The overlap f(i%2,j%2) and g(i%2,j%2) is compensated by h: dimension = 2r + 2s + 4 − 8 = 2r + 2s − 4

For each of the 16 corner choices h, the problem decomposes into independent column and row optimizations:

  1. Column pass: for each column j and parity class px, choose the best of 4 patterns (0,0),(1,0),(0,1),(1,1) that minimizes weight
  2. Row pass: for each row i and parity class py, choose the best of 4 patterns
  3. Repeat column to row until convergence (typically 2-3 iterations)

The alternating optimization converges to the global minimum because the objective (Hamming weight) is separable and each sub problem is exactly solvable in closed form.

Total: 16 × 3 × 1600 = 76,800 operations per decode. O(n). :)

u/BitStateEmulator — 15 days ago

Quantum error correction algorithm

For a while, the consensus in QEC has been that Maximum Likelihood (ML) decoding; finding the absolute minimum-weight error that matches your syndrome, is computationally intractable for large-scale quantum LDPC codes.

It’s widely considered an NP-Hard problem, which is why the field largely relies on iterative heuristics like Belief Propagation.

Instead of navigating a massive Tanner graph (which is where all the complexity usually lives), I mapped the problem to a causal wave-front propagation.

I found that if you identify a "cut set" of qubits (for my use case, a 2x2 corner), you can uniquely determine the state of the entire grid by propagating the recurrence from those 4 seeds.

Initially, like a fool I brute-forced all possible origins to find the one where the seam didn't interfere with the noise.

Then I realized I could just use a centroid calculation on the syndrome map to dynamically shift the origin, lol.. essentially using the syndrome distribution to physically "re-align" the coordinate system of the code before decoding.

This is the algorithm:

The Z-check equation for X-errors with a(x,y) = (x²+1)(y²+1) is a 2D linear recurrence:

c(i,j) = q(i,j) ⊕ q(i-2,j) ⊕ q(i,j-2) ⊕ q(i-2,j-2)

Rearranged as backward propagation from the 2×2 corner:

q(i,j) = c(i-2,j-2) ⊕ q(i-2,j) ⊕ q(i,j-2) ⊕ q(i-2,j-2)

The 2×2 corner spans a 4-dimensional nullspace (16 vectors).

For each corner position (every even-indexed (cx,cy) on the grid) and each of the 16 nullspace choices, the recurrence uniquely determines all qubits.

reddit.com
u/BitStateEmulator — 15 days ago

2D Surface code generator

https://hexstatelab.github.io/SurfaceCodeGenerator/

Pick two odd numbers.

Call them mx and my.

Set r = 2·mx, s = 2·my. The code lives on a torus with r positions in the x-direction and s in the y-direction.

Total qubits: N = 2·r·s = 8·mx·my.

The stabilizers are HX = [A|B], HZ = [Bᵀ|Aᵀ] where A and B are rs × rs block-circulant matrices built from bivariate polynomials a(x,y) and b(x,y) over the ring GF(2)[x,y]/(xʳ+1, yˢ+1).

The gcd structure in 2D is the product of the 1D structures:

gcd_2d = (x+1)² · (y+1)²

This has total degree 4 (2 from x, 2 from y). The formula for K is the same as 1D, applied to the total degree:

K = 2 · deg(gcd_2d) = 2 · 4 = 8

The nullspace generator is what's left after dividing out the gcd:

h(x,y) = (xʳ+1)(yˢ+1) / ((x+1)²(y+1)²) = ((xʳ+1)/(x+1)²) · ((yˢ+1)/(y+1)²) = h_x(x) · h_y(y)

Each factor h_x(x) is the 1D nullspace generator we already analyzed. In 1D with gcd=(x+1)², the nullspace vector h_x has weight exactly mx. Same for h_y with weight my. The minimum-weight 2D logical operator is the product of the shorter 1D operator with the identity in the other dimension, giving:

D = min(mx, my)

That's it. No search. No enumeration. The distance is forced by the factorization of xʳ+1 and yˢ+1 over GF(2).

The Freshman's Dream f(x)² = f(x²) makes (x+1)² = x²+1 divide xʳ+1 whenever r is even. You set r = 2·mx specifically so that xʳ+1 = (xᵐˣ+1)² has the repeated-root structure. Same in y. The gcd consumes two copies of (x+1) and two of (y+1), leaving h_x of weight mx and h_y of weight my. The shorter dimension wins.

For a square code where mx = my = D:

N = 8D², K = 8, D = D, rate = 1/D²

That's the surface code scaling; quadratic qubit cost, linear distance, but with 8 logical qubits instead of 1 or 2.

The weight-8 stabilizers come from choosing a(x,y) = b(x,y) = (x+1)(y+1) which has 4 terms.

Each circulant block contributes 4 ones, total 8 per check. You can choose denser polynomials to increase rate further, at the cost of heavier checks.

The QFT diagonalizes the whole thing. The eigenvalues of the 2D circulant are a(ωˣ, ωʸ) evaluated at the r×s roots of unity. The shared zeros between a, b, xʳ+1, and yˢ+1 create the nullspace. The gcd degree counts the shared zeros.

reddit.com
u/BitStateEmulator — 17 days ago

Quantum Error Code family

You pick an odd number. That's it.

Example: pick D = 7.

Step 1: The numbers fall out.

m = 7 (your number)

N = 4 × 7 = 28 (physical qubits)

K = 4 (logical qubits always; 4 for this family)

D = 7 (distance; corrects 3 errors)

Step 2: Make two polynomials

Roll a random 28-bit number that has an odd number of 1s. Call it p_a. Roll another. Call it p_b.

Multiply each by x² + 1. In GF(2) arithmetic, multiplication by x² + 1 just means: for each bit position i, XOR the bit at position i with the bit at position i−2 (wrapping around at position 28).

That gives you a(x) and b(x).

Step 3: The code exists

Those two polynomials define a quantum error-correcting code. You don't need to build the matrix. You don't need to check anything. The code has exactly the parameters N=28, K=4, D=7.

Guaranteed.

The circulant matrix from a(x) has each row equal to the previous row shifted by one. The "shift by one" operation is a rotation. After rotating 7 times around a 28-element circle, you come back to the start. This means the matrix has a 4-fold symmetry; 28 = 7×4 and that symmetry creates exactly 4 logical qubits.

The factor x² + 1 baked into both a(x) and b(x) is what creates the code space. It's like putting a notch at every second position around the circle. The minimum-weight logical operator spans exactly 7 of the 28 positions; one notch in each of the 7 blocks of 4. That gives distance 7.

The construction works for any odd number. The factor x² + 1 always creates this notch pattern, the block count is always the odd number you picked, and the minimum weight is always exactly that number.

Input: any odd integer m

Output: [[4m, 4, m]] quantum error-correcting code

  1. Set L = 2m
  2. Pick random polynomials p_a(x), p_b(x) of degree < L-2 with odd parity (not divisible by x+1)
  3. a(x) = (x²+1) · p_a(x) mod x^(L+1)
  4. b(x) = (x²+1) · p_b(x) mod x^(L+1)
  5. Build GB code: HX = [circulant(a) | circulant(b)] HZ = [circulant(b)^(T) | circulant(a)^(T])
  6. Done. The code has N=4m, K=4, D=m. That's the whole thing. The d_target tool does it in one command:

Error code examples

Distance 100: 404 4 1 101 0.010 224 (a,b: 202-bit polys, a[0]=0x6b8b4567327b23c7 b[0]=0x238e1f2946e87ccc)

Distance 10000000:

40000004 4 1 10000001 0.000 19995118 (a,b: 20000002-bit polys, a[0]=0x6b8b4567327b23c7 b[0]=0x7313e0551f2e9345)

reddit.com
u/BitStateEmulator — 17 days ago

BitState Quantum Simulator

Standard quantum simulators run out of RAM at around 50 qubits because tracking state vectors scales exponentially.

Google’s Willow chip claimed "Quantum Supremacy" at 105 qubits, and 40 cycles because simulating chaotic entanglement at that depth was considered classically impossible.

I built a C-based simulator (BitState HPC) that represents quantum states as topological graphs rather than amplitude vectors.

It runs up to 4,000,000 qubits, at supremacy depths in linear time, maintaining bit-perfect fidelity, effectively achieving a Classical Supremacy bypass.

Instead of tracking a massive array of complex amplitudes (state-vector) or dealing with exponential treewidths (tensor networks), BitState represents the quantum wave function as a dynamic graph.

The trick relies on a mechanism I call Hadamard Absorb.

Instead of branching the state space when non-commuting gates interact, the engine dynamically compresses local graph invariants.

It treats entanglement as a structural topology, rather than an amplitude calculation.

I ran heavy stress tests (Random Circuit Sampling with a ~15% non-Clifford T-gate fraction) scaling up to 40 cycles to mimic the Willow benchmark.

Standard theory says the memory should blow up, here are the results:

  1. Strictly Linear Edge Growth: Deep into the chaotic phase (36+ cycles), the graph did not densify into an unmanageable mess. The edges-per-qubit (ed/q) metric plateaued at a mere ~29.1.
  2. Absorption Equilibrium: The engine reaches a state where it absorbs structural entanglement exactly as fast as the chaotic circuit generates it. The absorb-per-qubit metric perfectly flatlines at 1.0. The memory scaling remains strictly linear.
  3. Bit-Perfect Precision: To prove it wasn't just heavily truncating or losing phase data, I ran it against a brute-force state-vector on smaller scales. Across deep cycles, the fidelity is 1.000000000000001 with exactly 0 amplitude mismatches. It is a mathematically lossless compression.

Because the engine isn't constrained by a physical 2D grid like real hardware, non-local CZ gates (connecting any qubit to any other qubit) are O(1) operations.

Physical chips need noisy SWAP gates to do this. :(

Because of this, my BitState can natively simulate Hypergraph Product Codes (qLDPC) natively.

I'm currently running million-qubit topological codes natively with only a few gigabytes of RAM footprint.

To 'drive' this engine, give it to an AI; have it ingest and analyze all the source files using the API which is provided and just tell it the experiment you need to conduct.

For a free AI, or a cheap one I suggest Deepseek because Claude has issues with running some experiments and is just not as good at using the API.

codeberg.org
u/BitStateEmulator — 19 days ago