Posts

Showing posts from November, 2026

Grover's Search on a Noisy Quantum Computer: How Many Iterations Actually Help?

Every Grover tutorial gives you the same formula: for a search space of N items, run about (π/4)·√ N iterations and you will find the marked item with high probability. That formula is correct — on a perfect machine. I wanted to know what happens to it on real hardware, where every iteration adds gates and every gate adds error. Short answer: the best number of iterations is smaller than the textbook says, and you can measure exactly how much smaller. Grover in three sentences Start with every item in equal superposition. Repeat two steps: an oracle flips the sign of the marked item's amplitude, and a diffuser reflects all amplitudes about their average, which grows the marked one a little each round. Too few rounds and the marked item is not amplified enough; too many and you rotate past it and the probability falls again. The circuit The oracle uses X gates to map the marked string onto |11…1⟩, then a multi-controlled Z (written as H · multi-controlled X · H). The diff...

Bernstein–Vazirani in Qiskit: Find a Secret String in One Query

Here is a puzzle. A black box hides a secret bit string s of length n . You can feed it any string x , and it answers with one bit: the parity of the bits where x and s are both 1 (the dot product s·x mod 2). How many questions do you need to recover s ? Classically the answer is n : ask with 1000…0 to learn the first bit, 0100…0 for the second, and so on — each answer gives you exactly one bit. The Bernstein–Vazirani algorithm does it with one query. This post builds it in Qiskit, explains why it works, and checks how it holds up on a noisy model of IBM's ibm_fez . Why one query is enough The trick is phase kickback. Put an extra "answer" qubit in the state |−⟩ (X then H). When the oracle flips that qubit conditionally on s·x , the flip turns into a sign: the input register picks up a phase of (−1) s·x . If the input register is in an equal superposition of all strings — Hadamards on every qubit — every possible x gets its own sign at once. A second layer of H...

Quantum Teleportation in Qiskit, Step by Step (and What It Does Not Do)

"Teleportation" is the most misleading word in quantum computing. Nothing travels faster than light, no matter is moved, and you cannot use it to send a message for free. What the protocol actually does is narrower and, once you see the circuit, more interesting: it moves an unknown quantum state from one qubit to another, using one shared entangled pair and two classical bits. This post builds the protocol gate by gate in Qiskit, checks it exactly with a statevector, and then runs it on a noisy model of IBM's ibm_fez to see how well it survives real-world errors. The setup in one paragraph Alice holds a qubit in some state |ψ⟩ = α|0⟩ + β|1⟩ that she does not know (and cannot learn by measuring — measurement would destroy it). Alice and Bob also share a Bell pair, prepared in advance. Alice performs a joint measurement on her two qubits, sends the two classical result bits to Bob, and Bob applies one of four corrections. Afterwards Bob's qubit is in exactly |ψ⟩,...

Readout Error Mitigation on a 4-Qubit GHZ State, Step by Step

In Measurement Error Mitigation Without a Physics Degree I explained the idea: measure how often the hardware misreads each qubit, build a matrix from those rates, and invert it. This post is the follow-up I wanted to read back then — one complete experiment, start to finish, with real numbers: a 4-qubit GHZ state, its raw counts, a calibration, and the corrected result. Everything here runs on a laptop with Qiskit Runtime's local mode and FakeFez , a simulator that carries a snapshot of the ibm_fez noise model. The numbers are from that model, not from the live machine — but the code is the same one you would send to the real device. The experiment A GHZ state on four qubits is (|0000⟩ + |1111⟩)/√2. Ideally you only ever read 0000 or 1111 , so the fraction of shots landing on those two outcomes is a handy quality score. Anything else is noise — from the gates, from decoherence, or from the readout itself. Readout mitigation can only fix the last part, which makes it a good t...

How to Prove Two Qubits Are Entangled: A CHSH Bell Test in Qiskit

A few weeks ago I found out that the circuit behind my own art collection was not doing what I thought it was doing. Every piece in Quantum Genesis was seeded by a circuit with Hadamards and CNOTs, and I had described it as "entangling". It wasn't — with a Hadamard on every qubit, the CNOTs had nothing to entangle. (I wrote up the correction in the entanglement post .) That raised a better question than "is my circuit entangled?": how do you prove that any circuit is? Looking at counts like {'00': 2010, '11': 2038} is not enough — two coins glued together give the same pattern. The tool physicists use is the CHSH Bell test , and it fits in a few lines of Qiskit. This post walks through it, and runs it on two circuits: a real Bell pair, and the "collection style" circuit that fooled me. Why counts in one basis prove nothing Measure a Bell pair in the computational (Z) basis and you get 00 or 11 , never 01 or 10 . Impressive — un...