deskmerc/ quantum

Quantum protection / KINGSTON

Through the Noise Wall

Steane without the journey

Prepare and decode the six states directly on Charlie’s Steane layout.

IBM job ID
dc0pea2nj2vs73dec230
Submitted
21 Nov 2026 · report date
QPU charge
Not in supplied record
Backend
ibm_kingston
Sampling
256 shots per recorded setting/case
Provenance
Through the Noise Wall, pages 4–6.

The question

Prepare and decode the six states directly on Charlie’s Steane layout.

Circuit & method

Use the same final seven-carrier output layout as the transported Steane job, with 256 shots per state. The direct circuit still uses 232 CZ gates, including routing. The new physical encoder differs from the sender encoder.

PrepareState, codeword or problem instance
Run on KingstonRecorded physical circuit and settings
Measure & checkCounts, decoding and classical verification

Results

Correction raised the direct score from 1,022/1,536 to 1,091/1,536 (71.0%). Clean checks kept 335 shots, of which 318 were correct (94.9%). All 1,536 direct ideal-simulator shots passed.

Measured outcomesAll-shot success; each bar runs from 0% to 100%.
Before correction1,022/1,536 · 66.5%
After correction1,091/1,536 · 71.0%
The clean-check score uses a different denominator from the all-shot bars.
PostselectionCorrectKeptAll attemptsCorrect / kept
Clean syndrome318335153694.9%

What this supports

The separate jobs and changed encoder prevent isolating transport’s exact cost. The report gives an approximate shot-noise-only 95% interval of −0.3 to +6.2 points for the direct-minus-transported gain. Archived circuit pubs were unavailable: the saved local check matched historical endpoints, readout, operation tallies and depth. Timestamps, QPU charge and versions are omitted.

Percentages are rounded for reading. The original integer counts, physical layouts, settings and available uncertainty calculations remain in the records below. Sampling intervals do not account for drift or every systematic error.

Full experiment record

Every top-level field from the primary hardware JSON is reproduced below, including the complete saved measurement distributions where present. Field names and outcome strings retain their original order and spelling.

stage
done
backend
ibm_kingston
shots
256
tag
direct-steane-charlie-control-20261121-v1
order
[
  "Y-",
  "X+",
  "X-",
  "Z+",
  "Y+",
  "Z-"
]
hardware_layout
{
  "encoded_on": [
    57,
    50,
    38,
    28,
    66,
    41,
    24
  ],
  "readout_wires": [
    48,
    29,
    47,
    67,
    57,
    46,
    49
  ],
  "logical_readout": 47,
  "routing_footprint": [
    24,
    25,
    26,
    27,
    28,
    29,
    37,
    38,
    41,
    42,
    43,
    44,
    45,
    46,
    47,
    48,
    49,
    50,
    57,
    66,
    67
  ],
  "circuits": {
    "Z+": {
      "ops": {
        "sx": 470,
        "cz": 232,
        "rz": 100,
        "measure": 7,
        "barrier": 1
      },
      "depth": 265,
      "cz_by_half": [
        116,
        116
      ]
    },
    "Z-": {
      "ops": {
        "sx": 470,
        "cz": 232,
        "rz": 100,
        "measure": 7,
        "x": 1,
        "barrier": 1
      },
      "depth": 265,
      "cz_by_half": [
        116,
        116
      ]
    },
    "X+": {
      "ops": {
        "sx": 472,
        "cz": 232,
        "rz": 104,
        "measure": 7,
        "barrier": 1
      },
      "depth": 265,
      "cz_by_half": [
        116,
        116
      ]
    },
    "X-": {
      "ops": {
        "sx": 472,
        "cz": 232,
        "rz": 104,
        "measure": 7,
        "x": 1,
        "barrier": 1
      },
      "depth": 266,
      "cz_by_half": [
        116,
        116
      ]
    },
    "Y+": {
      "ops": {
        "sx": 472,
        "cz": 232,
        "rz": 106,
        "measure": 7,
        "barrier": 1
      },
      "depth": 267,
      "cz_by_half": [
        116,
        116
      ]
    },
    "Y-": {
      "ops": {
        "sx": 472,
        "cz": 232,
        "rz": 106,
        "measure": 7,
        "x": 1,
        "barrier": 1
      },
      "depth": 268,
      "cz_by_half": [
        116,
        116
      ]
    }
  },
  "historical_job": "dc0pc0anj2vs73debv60",
  "verified_against_ibm_archive": {
    "status": "No archived pubs returned",
    "available_fields": [
      "options",
      "quantum_program",
      "schema_version"
    ],
    "local_check": "Historical endpoints, final readout, operations and depth matched for all six states."
  }
}
ideal_live_circuits
{
  "Z+": {
    "attempted": 256,
    "kept": 256,
    "correct": 256,
    "raw_correct": 256,
    "clean": 256,
    "clean_correct": 256
  },
  "Z-": {
    "attempted": 256,
    "kept": 256,
    "correct": 256,
    "raw_correct": 256,
    "clean": 256,
    "clean_correct": 256
  },
  "X+": {
    "attempted": 256,
    "kept": 256,
    "correct": 256,
    "raw_correct": 256,
    "clean": 256,
    "clean_correct": 256
  },
  "X-": {
    "attempted": 256,
    "kept": 256,
    "correct": 256,
    "raw_correct": 256,
    "clean": 256,
    "clean_correct": 256
  },
  "Y+": {
    "attempted": 256,
    "kept": 256,
    "correct": 256,
    "raw_correct": 256,
    "clean": 256,
    "clean_correct": 256
  },
  "Y-": {
    "attempted": 256,
    "kept": 256,
    "correct": 256,
    "raw_correct": 256,
    "clean": 256,
    "clean_correct": 256
  }
}
job_id
dc0pea2nj2vs73dec230
counts
{
  "Y-": {
    "0100001": 4,
    "0000110": 9,
    "1010101": 2,
    "0110101": 5,
    "0000100": 44,
    "0111111": 1,
    "0000001": 4,
    "0010000": 3,
    "1001100": 1,
    "1011100": 3,
    "0110110": 3,
    "0010100": 12,
    "0010110": 4,
    "0001000": 2,
    "1011000": 1,
    "0000101": 6,
    "1001111": 3,
    "0100100": 3,
    "0100011": 2,
    "0100110": 3,
    "0111000": 3,
    "1000010": 2,
    "0001100": 4,
    "1110001": 2,
    "1010000": 3,
    "0011110": 1,
    "1111000": 2,
    "0000011": 6,
    "0101000": 1,
    "1000111": 2,
    "0001010": 5,
    "1110100": 4,
    "1000000": 3,
    "0111110": 2,
    "0001111": 1,
    "1101101": 1,
    "1010010": 5,
    "0011101": 1,
    "0100101": 3,
    "0110011": 1,
    "0110100": 5,
    "1110110": 3,
    "0010101": 2,
    "1010011": 2,
    "1110000": 4,
    "1110101": 2,
    "0011001": 2,
    "0001011": 2,
    "0011010": 3,
    "1100100": 3,
    "0110000": 6,
    "0110111": 4,
    "0110010": 1,
    "1000001": 2,
    "0000111": 1,
    "0010111": 2,
    "1000100": 3,
    "1100101": 1,
    "0100010": 2,
    "0000010": 3,
    "0010010": 3,
    "0101011": 1,
    "1010001": 1,
    "1011111": 1,
    "0100000": 1,
    "0010011": 4,
    "0101111": 2,
    "1011010": 1,
    "1000110": 1,
    "1000101": 1,
    "1110010": 1,
    "0010001": 1,
    "1110011": 1,
    "0110001": 1,
    "0000000": 3,
    "1100000": 1,
    "1100110": 1,
    "1010111": 1,
    "0001110": 2,
    "1101001": 2,
    "1010100": 1,
    "0111100": 1,
    "0101001": 1,
    "0101100": 1,
    "1011110": 1,
    "1001001": 1
  },
  "X+": {
    "1011000": 2,
    "0101000": 2,
    "0011010": 2,
    "0100100": 3,
    "0000100": 6,
    "0100111": 4,
    "0000000": 36,
    "0000010": 8,
    "0000101": 6,
    "1110001": 3,
    "0010010": 4,
    "0110101": 4,
    "1100111": 2,
    "0100001": 3,
    "0010000": 12,
    "0101011": 2,
    "0110001": 6,
    "1100001": 3,
    "1010010": 6,
    "1110101": 3,
    "1001011": 3,
    "0011101": 2,
    "0010111": 4,
    "0110000": 7,
    "0000001": 3,
    "1001110": 2,
    "1000010": 10,
    "1101110": 2,
    "0001000": 7,
    "0100000": 6,
    "1011110": 2,
    "1000110": 2,
    "1000001": 2,
    "1010011": 3,
    "1110010": 1,
    "1011011": 1,
    "1100100": 1,
    "0010001": 1,
    "1100101": 2,
    "0111000": 5,
    "0100101": 3,
    "0011100": 1,
    "1111011": 1,
    "0010100": 2,
    "1001001": 1,
    "1101101": 1,
    "1110011": 3,
    "0001101": 1,
    "0100010": 5,
    "1000000": 2,
    "0010101": 3,
    "0110111": 2,
    "1001111": 1,
    "0111110": 1,
    "1110000": 2,
    "0101001": 2,
    "1010000": 2,
    "0000111": 4,
    "1000111": 1,
    "0110010": 2,
    "1010100": 2,
    "1000100": 1,
    "1100010": 1,
    "1010101": 1,
    "0101010": 1,
    "1011001": 1,
    "1010111": 2,
    "0000011": 1,
    "0100011": 1,
    "0111111": 1,
    "1110111": 3,
    "0101110": 1,
    "1111110": 1,
    "0110100": 2,
    "1111010": 1,
    "0101100": 1,
    "1010001": 1,
    "0010110": 1,
    "1000011": 3,
    "0011111": 1,
    "0011000": 1,
    "0111101": 1,
    "1000101": 1,
    "0001110": 1,
    "0001111": 1,
    "0110011": 1
  },
  "X-": {
    "1100100": 3,
    "0000011": 10,
    "1101111": 3,
    "0000100": 56,
    "1000111": 3,
    "1010011": 2,
    "0010100": 10,
    "0101010": 2,
    "0110110": 5,
    "1100010": 2,
    "0000110": 12,
    "0010000": 3,
    "0010010": 4,
    "0111010": 1,
    "1100000": 1,
    "0100001": 3,
    "0100010": 3,
    "0110011": 3,
    "1111110": 1,
    "1111100": 1,
    "0010011": 1,
    "1010111": 4,
    "0001010": 3,
    "1101100": 2,
    "1010110": 2,
    "1001000": 1,
    "0110100": 9,
    "1011001": 1,
    "1010100": 3,
    "0010111": 2,
    "1010001": 1,
    "0000010": 1,
    "0100101": 6,
    "1010010": 2,
    "1001101": 2,
    "0100110": 4,
    "1001010": 1,
    "0101000": 1,
    "1110100": 1,
    "0000111": 1,
    "0110010": 2,
    "0101001": 1,
    "0100000": 2,
    "0010001": 3,
    "1000011": 2,
    "1001100": 1,
    "0110000": 3,
    "0100011": 1,
    "1111011": 1,
    "0001111": 1,
    "0101100": 2,
    "0010110": 4,
    "0010101": 3,
    "1101101": 1,
    "1100111": 1,
    "1000001": 4,
    "0100100": 6,
    "1000110": 2,
    "0111100": 4,
    "1010000": 2,
    "1100001": 1,
    "0101111": 2,
    "1110101": 1,
    "1111010": 2,
    "1111111": 1,
    "1100101": 2,
    "0110001": 1,
    "1110001": 1,
    "1110011": 1,
    "0011110": 1,
    "0000000": 3,
    "1000000": 1,
    "0110101": 1,
    "0001000": 2,
    "0000001": 2,
    "0001100": 3,
    "0110111": 1,
    "0000101": 2,
    "1110010": 1,
    "1000100": 1,
    "0111000": 1,
    "0011100": 1,
    "0101011": 1,
    "1011101": 1
  },
  "Z+": {
    "0110111": 5,
    "0000010": 7,
    "0110110": 8,
    "0100000": 10,
    "0010000": 5,
    "0100010": 5,
    "1101100": 1,
    "0000101": 1,
    "1000001": 5,
    "1110011": 1,
    "1010100": 3,
    "0010010": 2,
    "0001010": 2,
    "0001000": 2,
    "0000000": 64,
    "1110110": 3,
    "1000101": 1,
    "1110111": 2,
    "1100011": 5,
    "0000011": 9,
    "0011011": 1,
    "1000000": 2,
    "0011000": 4,
    "0000001": 5,
    "1001010": 2,
    "1101010": 1,
    "0111111": 1,
    "1010011": 3,
    "1000010": 3,
    "1100010": 3,
    "1010110": 7,
    "0110100": 5,
    "0010110": 2,
    "1010000": 2,
    "1100001": 5,
    "0001111": 2,
    "1010001": 2,
    "1010101": 3,
    "1011110": 1,
    "0110101": 7,
    "0010011": 3,
    "0101001": 1,
    "0010100": 2,
    "0110011": 4,
    "1001110": 1,
    "0100001": 1,
    "0101111": 1,
    "0000110": 1,
    "0011101": 2,
    "0010101": 2,
    "0100011": 1,
    "0111011": 1,
    "1100000": 3,
    "0011111": 1,
    "0111010": 1,
    "1111100": 1,
    "1000011": 3,
    "1100100": 2,
    "1000110": 1,
    "1010111": 2,
    "0001110": 1,
    "0101110": 1,
    "0110000": 1,
    "0111000": 2,
    "1100101": 1,
    "0101000": 1,
    "0100100": 1,
    "0011001": 1,
    "1100111": 1,
    "0000100": 1,
    "0011100": 1,
    "1110000": 2,
    "1111000": 1,
    "0001011": 1,
    "1011000": 1,
    "0001100": 2,
    "1001000": 1
  },
  "Y+": {
    "0011100": 2,
    "0110000": 4,
    "0010000": 11,
    "0000110": 7,
    "0000000": 57,
    "0000010": 10,
    "0000111": 4,
    "0000101": 5,
    "1010110": 2,
    "0100100": 4,
    "0101110": 4,
    "0001000": 7,
    "1000011": 3,
    "0000001": 6,
    "1010011": 2,
    "1001011": 1,
    "0001010": 2,
    "0100000": 7,
    "1000001": 3,
    "0010111": 3,
    "1010100": 2,
    "1001111": 1,
    "1000000": 3,
    "0100010": 2,
    "0110101": 3,
    "1101111": 1,
    "1100001": 2,
    "0000011": 2,
    "1001000": 1,
    "1000010": 3,
    "1010010": 3,
    "1000110": 3,
    "1000101": 1,
    "0010010": 4,
    "0110010": 2,
    "0010100": 4,
    "1100000": 2,
    "0010101": 1,
    "0011001": 1,
    "0011101": 2,
    "0101111": 1,
    "1100111": 3,
    "0110111": 1,
    "0001111": 1,
    "1111000": 1,
    "1101100": 3,
    "0110100": 2,
    "1011000": 1,
    "0001100": 1,
    "0110110": 2,
    "1100101": 3,
    "0100110": 2,
    "1011001": 1,
    "0001011": 1,
    "1101011": 2,
    "1100011": 2,
    "1100100": 1,
    "1110000": 3,
    "1111011": 1,
    "1110110": 1,
    "0101101": 1,
    "1110100": 2,
    "0101001": 1,
    "0110011": 2,
    "1010001": 2,
    "0010001": 1,
    "1001110": 1,
    "0111100": 2,
    "1110101": 1,
    "1101001": 1,
    "1001100": 1,
    "0100011": 2,
    "0111001": 2,
    "0111111": 2,
    "0001110": 1,
    "0000100": 1,
    "0001001": 2,
    "1101101": 2,
    "1100010": 1,
    "0111010": 1,
    "0011011": 1,
    "0011000": 1,
    "0011111": 1,
    "1010111": 1,
    "0101000": 1,
    "0100111": 1,
    "1110111": 1
  },
  "Z-": {
    "1100001": 3,
    "1100110": 3,
    "1110000": 4,
    "0001110": 3,
    "0000100": 61,
    "0010000": 10,
    "0000101": 9,
    "0001100": 4,
    "0110011": 3,
    "0101110": 3,
    "0100101": 2,
    "0110010": 4,
    "1010000": 2,
    "0111000": 2,
    "0000110": 6,
    "0000000": 3,
    "1010001": 1,
    "1000100": 3,
    "1001100": 2,
    "1001110": 3,
    "0100100": 11,
    "0100110": 3,
    "0000010": 1,
    "0101100": 2,
    "0111111": 2,
    "1000001": 1,
    "0000111": 3,
    "0110001": 3,
    "0100000": 1,
    "0111011": 1,
    "0110111": 2,
    "0110000": 8,
    "1110001": 2,
    "1100100": 1,
    "0010001": 4,
    "0011110": 1,
    "0010011": 3,
    "1000111": 4,
    "1100111": 2,
    "0101101": 2,
    "0011100": 1,
    "0111001": 1,
    "0010100": 4,
    "0100001": 2,
    "0110101": 2,
    "1011010": 1,
    "1011001": 1,
    "0000001": 1,
    "1001101": 1,
    "0110100": 4,
    "1110111": 1,
    "1000110": 2,
    "1111101": 1,
    "0011000": 2,
    "0111100": 3,
    "0010110": 2,
    "1110100": 2,
    "1100011": 1,
    "0011011": 2,
    "0101010": 1,
    "1011111": 2,
    "0010101": 1,
    "0000011": 2,
    "1011110": 1,
    "0111110": 1,
    "1010101": 2,
    "0001000": 1,
    "0100011": 1,
    "0010111": 1,
    "1100000": 2,
    "0100111": 1,
    "0110110": 1,
    "0001111": 2,
    "1010100": 1,
    "0011101": 3,
    "1000101": 1,
    "1111000": 1,
    "1010011": 1,
    "1010010": 1,
    "0010010": 1,
    "1000011": 1,
    "0001101": 2,
    "1100101": 1,
    "1101111": 1,
    "0101001": 1
  }
}
rows
{
  "Y-": {
    "attempted": 256,
    "kept": 256,
    "correct": 168,
    "raw_correct": 157,
    "clean": 47,
    "clean_correct": 44
  },
  "X+": {
    "attempted": 256,
    "kept": 256,
    "correct": 187,
    "raw_correct": 170,
    "clean": 42,
    "clean_correct": 36
  },
  "X-": {
    "attempted": 256,
    "kept": 256,
    "correct": 185,
    "raw_correct": 172,
    "clean": 59,
    "clean_correct": 56
  },
  "Z+": {
    "attempted": 256,
    "kept": 256,
    "correct": 192,
    "raw_correct": 179,
    "clean": 65,
    "clean_correct": 64
  },
  "Y+": {
    "attempted": 256,
    "kept": 256,
    "correct": 177,
    "raw_correct": 168,
    "clean": 58,
    "clean_correct": 57
  },
  "Z-": {
    "attempted": 256,
    "kept": 256,
    "correct": 182,
    "raw_correct": 176,
    "clean": 64,
    "clean_correct": 61
  }
}
totals
{
  "attempted": 1536,
  "kept": 1536,
  "correct": 1091,
  "raw_correct": 1022,
  "clean": 335,
  "clean_correct": 318
}

Simulation & checks

These are the supplied simulator records and their preserved variants. Their model, seed, settings and results appear exactly as saved. Shared simulator references on fresh-map pages describe the ideal graph protocol, rather than a new hardware-matched calibration.

noise-wall/results/direct-steane-simulator.json · full record
{
  "rows": {
    "Z+": {
      "attempted": 256,
      "kept": 256,
      "correct": 256,
      "raw_correct": 256,
      "clean": 256,
      "clean_correct": 256
    },
    "Z-": {
      "attempted": 256,
      "kept": 256,
      "correct": 256,
      "raw_correct": 256,
      "clean": 256,
      "clean_correct": 256
    },
    "X+": {
      "attempted": 256,
      "kept": 256,
      "correct": 256,
      "raw_correct": 256,
      "clean": 256,
      "clean_correct": 256
    },
    "X-": {
      "attempted": 256,
      "kept": 256,
      "correct": 256,
      "raw_correct": 256,
      "clean": 256,
      "clean_correct": 256
    },
    "Y+": {
      "attempted": 256,
      "kept": 256,
      "correct": 256,
      "raw_correct": 256,
      "clean": 256,
      "clean_correct": 256
    },
    "Y-": {
      "attempted": 256,
      "kept": 256,
      "correct": 256,
      "raw_correct": 256,
      "clean": 256,
      "clean_correct": 256
    }
  },
  "layout": {
    "encoded_on": [
      57,
      50,
      38,
      28,
      66,
      41,
      24
    ],
    "readout_wires": [
      48,
      29,
      47,
      67,
      57,
      46,
      49
    ],
    "logical_readout": 47,
    "routing_footprint": [
      24,
      25,
      26,
      27,
      28,
      29,
      37,
      38,
      41,
      42,
      43,
      44,
      45,
      46,
      47,
      48,
      49,
      50,
      57,
      66,
      67
    ],
    "circuits": {
      "Z+": {
        "ops": {
          "sx": 470,
          "cz": 232,
          "rz": 100,
          "measure": 7,
          "barrier": 1
        },
        "depth": 265,
        "cz_by_half": [
          116,
          116
        ]
      },
      "Z-": {
        "ops": {
          "sx": 470,
          "cz": 232,
          "rz": 100,
          "measure": 7,
          "x": 1,
          "barrier": 1
        },
        "depth": 265,
        "cz_by_half": [
          116,
          116
        ]
      },
      "X+": {
        "ops": {
          "sx": 472,
          "cz": 232,
          "rz": 104,
          "measure": 7,
          "barrier": 1
        },
        "depth": 265,
        "cz_by_half": [
          116,
          116
        ]
      },
      "X-": {
        "ops": {
          "sx": 472,
          "cz": 232,
          "rz": 104,
          "measure": 7,
          "x": 1,
          "barrier": 1
        },
        "depth": 266,
        "cz_by_half": [
          116,
          116
        ]
      },
      "Y+": {
        "ops": {
          "sx": 472,
          "cz": 232,
          "rz": 106,
          "measure": 7,
          "barrier": 1
        },
        "depth": 267,
        "cz_by_half": [
          116,
          116
        ]
      },
      "Y-": {
        "ops": {
          "sx": 472,
          "cz": 232,
          "rz": 106,
          "measure": 7,
          "x": 1,
          "barrier": 1
        },
        "depth": 268,
        "cz_by_half": [
          116,
          116
        ]
      }
    },
    "historical_job": "dc0pc0anj2vs73debv60"
  }
}

Source code

Original experiment and verification programs are preserved byte for byte. These are historical listings; dependencies, authentication prompts and machine-specific input paths may need adjustment before a rerun.

  • direct_steane.pyThrough the Noise Wall.pdf / Kingston measurements and source.zip · 9,544 bytes
noise-wall/source/direct_steane.py · complete source
"""Measure the on-site Steane round trip on the previous Kingston receiver block."""
import json
import os
import random
import sys
import traceback
from collections import Counter

from qiskit import QuantumCircuit, transpile
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
from qiskit_ibm_runtime.fake_provider import FakeKingston

import charlie_codes as prior

ROOT = prior.ROOT
SIM, HW, STATUS = [ROOT / f"direct-steane-{name}.json" for name in ("simulator","kingston","status")]
OLD = json.loads(prior.HW.read_text())
TAG = "direct-steane-charlie-control-20261121-v1"


def native(circuit, backend):
    return transpile(circuit, backend, initial_layout=list(range(backend.num_qubits)),
                     routing_method="none", optimization_level=0, num_processes=1,
                     seed_transpiler=prior.SEED)


def hardware_trace(circuit):
    # Reordering operations on disjoint wires is immaterial.
    traces = [[] for _ in circuit.qubits]
    for inst in circuit.data:
        op = inst.operation
        wires = tuple(circuit.find_bit(q).index for q in inst.qubits)
        bits = tuple(circuit.find_bit(b).index for b in inst.clbits)
        if op.name == "if_else":
            flag, value = op.condition
            params = (circuit.find_bit(flag).index, int(value),
                      tuple(tuple(x.operation.name for x in block.data) for block in op.blocks))
        else:
            params = tuple(round(float(v), 10) for v in op.params)
        for wire in wires:
            traces[wire].append((op.name, wires, bits, params))
    return traces


def tally(state, words):
    assert all(len(w) == 7 and set(w) <= {"0","1"} for w in words)
    # Historical scorer expects the seven data bits followed by the 14 Bell outcomes.
    # Those outcomes never enter Steane decoding; the direct experiment measures seven bits.
    row = prior.score("steane", state, {w+"0"*14: n for w,n in words.items()})
    clean = {w:n for w,n in words.items()
             if all(((int(w,2) >> i) & 1) == 0 for i in prior.CHECKS["steane"])}
    row["clean"] = sum(clean.values())
    row["clean_correct"] = sum(n for w,n in clean.items()
                               if ((int(w,2) >> prior.LOGICAL["steane"]) & 1) == (state[1] == "-"))
    return row


def circuits(backend):
    lanes = OLD["live_compile"]["lanes"]
    # Reuse the historical route. Only the connectivity graph from the snapshot
    # enters routing. The backend used for instruction translation is passed in.
    snapshot = FakeKingston()
    _, graph = prior.pick_lanes(snapshot)
    setup = prior.physical_setup(snapshot,graph,lanes,"steane")
    decoder, wires = setup[3]
    endpoints = [p[-1] for p in lanes]
    footprint = sorted({decoder.find_bit(q).index for op in decoder.data for q in op.qubits})
    result, reference, details = {}, {}, {}
    for state in prior.STATES:
        historic = OLD["live_compile"]["cases"]["steane_"+state]
        assert wires == historic["physical_readout"]
        full = prior.circuit("steane",state,*setup,fast=historic["fast_mid_measure"])
        full = native(full,snapshot)
        assert dict(full.count_ops()) == historic["operations"] and full.depth() == historic["depth"]
        reference[state] = full

        qc = QuantumCircuit(backend.num_qubits,7,name="direct_steane_"+state)
        prior.prepare(qc, wires[prior.LOGICAL["steane"]], state)
        qc.compose(decoder.inverse(), inplace=True)
        qc.barrier(*footprint)
        qc.compose(decoder, inplace=True)
        prior.rotate_readout(qc, wires[prior.LOGICAL["steane"]], state[0])
        for i,wire in enumerate(wires):
            qc.measure(wire,i)
        isa = native(qc,backend)
        backend.check_faulty(isa)
        halves = [0,0]
        side = 0
        measures = {}
        for op in isa.data:
            if op.operation.name == "barrier":
                side += 1
                continue
            if op.operation.name == "cz":
                halves[side] += 1
            if op.operation.name == "measure":
                measures[isa.find_bit(op.clbits[0]).index] = isa.find_bit(op.qubits[0]).index
            assert all(isa.find_bit(q).index in footprint for q in op.qubits)
        expected = decoder.count_ops()["cx"] + 3*decoder.count_ops()["swap"]
        assert side == 1 and halves == [expected,expected] and measures == dict(enumerate(wires))
        assert not {"if_else","measure_2"}.intersection(isa.count_ops())
        result[state] = isa
        details[state] = {"ops":dict(isa.count_ops()),"depth":isa.depth(),"cz_by_half":halves}
    provenance = dict(encoded_on=endpoints, readout_wires=wires, logical_readout=wires[prior.LOGICAL["steane"]],
                      routing_footprint=footprint, circuits=details, historical_job=OLD["job_id"])
    return result, reference, provenance


def check_ideal(batch):
    rows = {}
    for state, counts in zip(batch, prior.aer_run(list(batch.values()), prior.SHOTS), strict=True):
        rows[state] = tally(state,counts)
        assert all(rows[state][k] == prior.SHOTS for k in ("attempted","correct","raw_correct","clean"))
    return rows


def login():
    if os.getenv("QISKIT_IBM_TOKEN") or QiskitRuntimeService.saved_accounts():
        return QiskitRuntimeService(channel="ibm_quantum_platform",region="us-east",plans_preference=["open"])
    from tkinter import Tk, simpledialog
    root = Tk()
    root.withdraw()
    root.attributes("-topmost",True)
    prior.save(STATUS, {"stage":"waiting for private IBM login"})
    key = simpledialog.askstring("IBM Quantum – direct Steane control",
                                 "IBM Cloud API key for six direct Steane circuits on Kingston",
                                 show="*",parent=root)
    root.destroy()
    if not key or not key.strip():
        raise RuntimeError("Private login cancelled")
    return QiskitRuntimeService(channel="ibm_quantum_platform",token=key.strip(),region="us-east",
                                plans_preference=["open"])


def verify_archive(service, reference):
    params = service.job(OLD["job_id"]).inputs
    pubs = params.get("pubs")
    if pubs is None:
        return dict(status="No archived pubs returned", available_fields=list(params),
                    local_check="Historical endpoints, final readout, operations and depth matched for all six states.")
    matches = []
    for name, pub in zip(OLD["order"],pubs,strict=True):
        if name.startswith("steane_"):
            state = name.split("_")[1]
            submitted = pub.circuit if hasattr(pub,"circuit") else pub[0]
            assert hardware_trace(reference[state]) == hardware_trace(submitted), state
            matches.append(state)
    assert set(matches) == set(prior.STATES)
    return dict(status="verified",states=matches)


def hardware():
    assert SIM.exists()
    rec = json.loads(HW.read_text()) if HW.exists() else {}
    if rec.get("stage") == "done":
        return
    service = login()
    prior.save(STATUS,{"stage":"connected, checking circuits"})
    backend = service.backend("ibm_kingston")
    if not rec:
        batch, reference, provenance = circuits(backend)
        ideal = check_ideal(batch)
        # Compare the historical native gates, including all seven data measurements.
        provenance["verified_against_ibm_archive"] = verify_archive(service,reference)
        order = list(prior.STATES)
        random.Random(582911).shuffle(order)
        sampler = SamplerV2(mode=backend,options={"max_execution_time":30,
                   "environment":{"job_tags":[TAG]},"twirling":{"enable_measure":False,"enable_gates":False},
                   "dynamical_decoupling":{"enable":False}})
        rec = dict(stage="submitting",backend=backend.name,shots=prior.SHOTS,tag=TAG,order=order,
                   hardware_layout=provenance,ideal_live_circuits=ideal)
        with HW.open("x",encoding="utf8") as f:
            json.dump(rec,f)
        job = sampler.run([batch[s] for s in order],shots=prior.SHOTS)
    elif rec.get("job_id"):
        job = service.job(rec["job_id"])
    else:
        matches = service.jobs(job_tags=[TAG],limit=2)
        if len(matches) != 1:
            raise RuntimeError("Reconcile submission before retry")
        job = matches[0]
    rec.update(stage="submitted",job_id=job.job_id())
    prior.save(HW,rec)
    prior.save(STATUS,{"stage":"submitted","job_id":job.job_id()})
    counts = {s:p.data.c.get_counts() for s,p in zip(rec["order"],job.result(),strict=True)}
    rows = {s:tally(s,c) for s,c in counts.items()}
    assert len(rows)==6 and all(r["attempted"]==prior.SHOTS for r in rows.values())
    totals = dict(sum((Counter(row) for row in rows.values()),Counter()))
    rec.update(stage="done",counts=counts,rows=rows,totals=totals)
    prior.save(HW,rec)
    prior.save(STATUS,{"stage":"done","job_id":job.job_id()})
    rec["metrics"] = job.metrics()
    prior.save(HW,rec)


if __name__ == "__main__":
    if sys.argv[1:] == ["simulate"]:
        batch, _, details = circuits(FakeKingston())
        rows = check_ideal(batch)
        prior.save(SIM,dict(rows=rows,layout=details))
        print(details["encoded_on"], details["circuits"]["Z+"], rows["Z+"])
    elif sys.argv[1:] == ["hardware"]:
        try:
            hardware()
        except Exception as exc:
            prior.save(STATUS, {"stage":"error","type":type(exc).__name__,
                                "frames":[(f.name,f.lineno) for f in traceback.extract_tb(exc.__traceback__)]})
            sys.exit(1)

Personal comments

Personal comments will be added here.