How a Quantum Program Runs: Circuit to Result
Step 1: write the circuit
A programmer describes the task as a quantum circuit: qubits start in a known state, gates are applied in order, and measurements are placed at the end. This is the abstract version, independent of any specific machine.
Step 2: compile for the device
Real hardware supports only a small set of native gates, and not every pair of qubits can interact. A compiler, often called a transpiler, rewrites the circuit in three main ways. It decomposes your gates into the native set. It maps your logical wires to physical qubits, preferring the better ones. And it inserts extra swap operations where the circuit asks for interactions between qubits that are not directly connected. It also tries to cut gate count, since each gate adds error.
Step 3: execution on hardware
The compiled circuit is turned into low level control signals, such as microwave pulses or laser pulses depending on the hardware type. These run on the physical qubits for a short time while the quantum state evolves, and the system then measures all the qubits. Each measurement gives a string of 0s and 1s. The quantum state is gone afterward, so the whole run must be repeated to learn anything more.
Step 4: shots and counts
Quantum results are probabilistic. Even a perfect machine would give different bit strings on different runs, with chances set by the amplitudes. So the program runs hundreds to thousands of times. Each run is a shot. The output is a histogram of counts, such as how many shots produced each bit string. A well designed algorithm makes the right answer the most common outcome, or lets you estimate a quantity from the statistics.
Step 5: noise and cleanup
Real devices add errors from imperfect gates, decoherence and faulty readout, so the histogram is blurred. Several steps can partially help:
- Error mitigation: post-processing techniques that estimate what an ideal result would have been, usually at the cost of more shots.
- Readout correction: adjusting counts based on measured misreading rates.
- Hybrid loops: a normal computer adjusts circuit settings between runs, as in variational methods.
Mitigation is not error correction, and it does not scale to very deep circuits.
The idea of the compiler matters more than it first seems. Two circuits that are mathematically the same can differ greatly in how many gates they need on a specific device, so good compilation can decide whether a program gives a recognizable answer or only noise.
Simulating instead
You can test the same circuit on a classical simulator first. It matches the ideal math, perhaps with an added noise model, but its memory needs double with every qubit, which caps it at a modest number of qubits for full state simulation. See programming tools and how to try a quantum computer online.
Frequently asked questions
What is a shot in quantum computing?
A shot is one complete run of a circuit ending in measurement. Programs are run many times to build up statistics.
Why do quantum programs have to be run many times?
Each measurement gives one random outcome and destroys the state. Repeating the run reveals the probabilities.
What does a transpiler do?
It converts a circuit into the native gates of a specific device, assigns physical qubits and adds swaps for qubits that cannot interact directly.
Why are results noisy?
Gates are imperfect, qubits lose their state, and measurement can misreport. All of these blur the final counts.
Is error mitigation the same as error correction?
No. Mitigation is statistical cleanup after the fact. Error correction protects the computation while it runs and needs many more qubits.
Can a quantum program run on a normal laptop?
Small ones can be simulated. The cost grows exponentially with qubit count, so large circuits are out of reach for classical simulation.
Keep reading
- Quantum Gates and Circuits Explained
What are quantum gates and circuits? A plain English guide to Hadamard, CNOT and how gates turn qubits into a working quantum program. - Quantum Programming Tools and SDKs Explained
What tools do people use to program quantum computers? A general guide to open source SDKs like Qiskit and Cirq, simulators, cloud access and how to choose one. - How to Try a Quantum Computer Online
You can run real quantum circuits from your browser. Here is a beginner guide to cloud quantum access, simulators, free tiers and what to try first. - NISQ Explained: Noisy Intermediate-Scale Quantum Computers
What does NISQ mean? Learn why today's noisy, mid-size quantum computers are limited, what they can do, and how the field plans to move past them.
All Quantum computing guides | Back to top | Search the site
Main pages: Quantum computing explained | Quantum and crypto | Companies | Quantum news | Glossary