Inject noise
Random qubit, rotation plane, and angle from 0 to π/2.
Quantum Computing · Qiskit · May 2026
A five-qubit simulation that introduces rotational noise, detects a single corrupted data qubit with parity syndromes, and restores logical |0⟩ and |1⟩ states.
01 · Purpose
The project repeats one logical value across three data qubits, applies a random Rx or Ry rotation to one qubit, and compares measurement results before and after correction.
Two ancilla qubits compute adjacent parity checks. Their syndrome identifies the corrupted position, allowing controlled-X gates to restore the repeated state before the final measurement.
Random qubit, rotation plane, and angle from 0 to π/2.
Ancillas store q0 ⊕ q1 and q1 ⊕ q2.
The syndrome selects the data qubit that receives an X correction.
02 · Code
Rotational error model
The helper applies either an X-axis or Y-axis rotation, while the randomizer selects the affected qubit and angle.
def corrupt(angle, q, plane):
qc_err = QuantumCircuit(1)
if plane == 'ZX':
qc_err.rx(angle, 0)
else:
qc_err.ry(angle, 0)
return q.evolve(Operator(qc_err))
def get_noise():
which_qubit = rng.integers(0, 3)
plane = 'ZX' if rng.integers(0, 2) == 0 else 'ZY'
theta = rng.uniform(0.0, np.pi * 0.5)
return which_qubit, plane, theta
Detection + recovery
Syndromes 11, 10, and 01 identify the middle, first, and third data qubits.
# Compute syndrome with two ancillas
qc.cx(0, 3); qc.cx(1, 3)
qc.cx(1, 4); qc.cx(2, 4)
qc.measure(3, 3); qc.measure(4, 4)
# 11 → q1, 10 → q0, 01 → q2
qc.append(XGate().control(2), [3, 4, 1])
qc.x(4)
qc.append(XGate().control(2), [3, 4, 0])
qc.x(4)
qc.x(3)
qc.append(XGate().control(2), [3, 4, 2])
Randomized validation
Each trial creates new noise, runs 1,024 shots without correction, then repeats the same test with ECC.
for i in range(N):
init_one = (i % 2 == 1)
base = one if init_one else zero
which_qubit, plane, theta = get_noise()
qc_n = noisy_circuit(base, which_qubit, plane, theta)
c_n = sim.run(qc_n, shots=1024).result().get_counts()
noisy = corrupt(theta, base, plane)
args = [base, base, base]
args[2 - which_qubit] = noisy
qc_e = create(args[0], args[1], args[2])
c_e_raw = sim.run(qc_e, shots=1024).result().get_counts()
03 · Findings
000 in every shot.Result: across all 27 trials, ECC produced 27,648 correct data-register measurements out of 27,648. The uncorrected simulations averaged 81.0%, with individual trials ranging from 49.1% to 100%.
Scope: this demonstrates correction of one simulated data-qubit error in a repeated-state model; it is not a complete fault-tolerant quantum-computing architecture.
Professional development
Black Opal certificate issued by Q-CTRL on May 28, 2026.