Quantum

Qiskit Quantum Programming

By CourseTron Team ·  6 min read ·  Updated Oct 2026 💬 𝕏 in f
Table of Contents
    ? Print / Save as PDF

    In short: Qiskit is IBM's open-source Python toolkit that lets you build quantum circuits, test them on classical simulators, and submit them to real quantum hardware through one workflow: build, transpile, run, analyse.

    Why Qiskit is the default starting point

    If you read our overview of quantum computing programming, you know that a quantum program is a sequence of gates applied to qubits, followed by measurement. Qiskit turns that idea into Python objects. A QuantumCircuit holds the gates, a backend represents either a simulator or a physical processor, and a primitive (Sampler or Estimator) executes circuits and returns results. Because the same circuit object can target a laptop simulator or a 100+ qubit IBM device, it is the shortest path from textbook to hardware.

    The ecosystem splits into a few packages: qiskit (core circuits and the transpiler), qiskit-aer (high-performance simulators), and qiskit-ibm-runtime (cloud access to IBM systems). Install them with pip install qiskit qiskit-aer qiskit-ibm-runtime.

    The four-step workflow

    Every Qiskit program, from a two-qubit demo to a research experiment, follows the same pattern, often called the patterns workflow: map the problem to circuits, optimise for hardware, execute, then post-process.

    Qiskit workflow: four steps 1. Build QuantumCircuit 2. Transpile map to backend 3. Run Sampler / Estimator 4. Analyse counts, plots gates rewritten to native set simulator or real QPU CourseTron · coursetron.com
    The same four steps apply whether the backend is a simulator or an IBM quantum processor.

    Your first circuit: the Bell state

    The Bell state is the "hello world" of quantum computing because it demonstrates entanglement in just two gates. Start with both qubits in |00>. A Hadamard on qubit 0 creates an equal superposition. A CNOT (CX) with qubit 0 as control and qubit 1 as target then copies the branch into the second qubit, producing (|00> + |11>)/√2.

    from qiskit import QuantumCircuit
    from qiskit_aer import AerSimulator
    from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
    from qiskit_aer.primitives import SamplerV2
    
    qc = QuantumCircuit(2, 2)
    qc.h(0)
    qc.cx(0, 1)
    qc.measure([0, 1], [0, 1])
    
    backend = AerSimulator()
    pm = generate_preset_pass_manager(optimization_level=1, backend=backend)
    isa_qc = pm.run(qc)
    
    job = SamplerV2(default_shots=1024).run([isa_qc])
    counts = job.result()[0].data.c.get_counts()
    print(counts)   # e.g. {'00': 508, '11': 516}

    Key fact: A perfect Bell pair never yields "01" or "10". Over 1,024 shots you expect roughly 512 each of 00 and 11, with statistical spread of about ±16 (one standard deviation, √(1024×0.25)).

    Bell-state circuit q0 |0> q1 |0> H M M Result: (|00> + |11>)/√2 CourseTron · coursetron.com
    H puts q0 in superposition; CNOT entangles q1 with it; measurement collapses both together.

    What the transpiler really does

    Real processors do not run arbitrary gates. IBM's current Heron-class devices expose a small native set (for example cz, rz, sx, x), and qubits connect only to a few neighbours on a heavy-hex lattice. Transpilation does three jobs: translation (rewrite H and CX into native gates), layout and routing (choose physical qubits and insert SWAPs where the coupling map forbids a direct interaction), and optimisation (cancel redundant gates, merge single-qubit rotations).

    The idea mirrors technology mapping in classical synthesis: Synopsys Design Compiler or Cadence Genus maps RTL onto a standard-cell library, then place-and-route handles physical constraints. Qiskit's transpiler plays the same role for quantum gates. If you have attended an ASIC flow class at ChipXpert, the analogy will feel natural.

    Optimization levelWhat it doesUse when
    0Translation and trivial layout onlyDebugging the circuit
    1Light gate cancellationDefault for small tests
    2Noise-aware layout, commutation analysisMedium circuits
    3Heaviest resynthesis, slowest compileDepth-critical runs

    Key fact: Each two-qubit gate on today's hardware has an error around 0.1% to 1%, so every SWAP the router adds (three CX gates) directly lowers your result fidelity. Depth after transpiling matters more than depth before it.

    Seeing it in motion

    Run the Bell circuit many times and each shot lands in either the 00 or the 11 bucket. The animation below shows shots dropping into the two outcomes while "01" and "10" stay empty.

    Measurement outcomes build up shot by shot 00 (~50%) 01 (0%) 10 (0%) 11 (~50%) CourseTron · coursetron.com
    Only correlated outcomes appear; 01 and 10 stay near zero on an ideal simulator.

    From simulator to real hardware

    Moving to hardware changes only the backend. Save your IBM Quantum API token once, then pick the least busy device and rebuild the pass manager against it, because the native gate set and coupling map differ per chip:

    from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
    
    service = QiskitRuntimeService()
    backend = service.least_busy(operational=True, simulator=False)
    pm = generate_preset_pass_manager(optimization_level=3, backend=backend)
    isa_qc = pm.run(qc)
    job = SamplerV2(mode=backend).run([isa_qc], shots=1024)
    print(job.job_id())

    Jobs wait in a queue, so you retrieve results later by job ID. On real hardware you will see a few percent of "01" and "10" counts, caused by gate errors, readout error (often 1% to 3% per qubit) and decoherence. That leakage is a feature of learning: it is your first lesson in why error mitigation exists. For a deeper treatment of circuit patterns that follow this, see quantum error mitigation basics.

    Interview angles worth rehearsing

    Interviewers for quantum software roles rarely ask you to recite API names. They probe understanding. Expect questions such as: why does a Bell state violate classical correlation limits, what is the difference between a logical circuit and an ISA (instruction set architecture) circuit, and how would you estimate the cost of a routing pass? A strong answer ties the code to physics: Hadamard gives amplitude 1/√2 on each branch, CX is a conditional bit flip that preserves coherence, and measurement samples from the squared amplitudes.

    Also be ready to discuss resource limits. A 127-qubit device cannot be simulated exactly, so you validate small instances on Aer, then scale up with Clifford-only or matrix-product-state simulators when the circuit structure allows. Show that you know when each simulator method applies, and you will stand out from candidates who only ran tutorials.

    Common mistakes beginners make

    • Skipping transpilation on hardware. Runtime rejects circuits containing non-native gates or illegal qubit pairs.
    • Misreading bit order. Qiskit is little-endian: qubit 0 is the rightmost character in a count string such as "10".
    • Too few shots. With 100 shots, the Bell ratio can wander by ±5 counts easily; use 1,000 or more.
    • Trusting simulator numbers. An ideal Aer run is noise-free; add a noise model from a real backend before predicting hardware behaviour.

    Key fact: Statevector simulation needs 2n complex amplitudes; at 16 bytes each, 30 qubits already needs about 16 GB, which is why simulators stop around 30 to 35 qubits on ordinary machines.

    Ready to go beyond Bell states? Explore the quantum and VLSI learning paths in our CourseTron courses and build circuits with guided labs.

    FAQ

    Do I need a quantum computer to learn Qiskit?

    No. The Aer simulator runs on a laptop, and IBM offers free-tier access to real devices for short runs.

    What is the difference between Sampler and Estimator?

    Sampler returns measurement bitstring samples (counts); Estimator returns expectation values of observables, which suits chemistry and optimisation.

    Why does my hardware Bell result show 01 and 10?

    Gate errors, readout errors and decoherence flip some outcomes. Higher transpiler optimisation and error mitigation reduce, but do not remove, them.

    Is Qiskit only for IBM hardware?

    Qiskit is open source and has provider plugins, but its richest integration is with IBM Quantum systems.

    Advertisement