12.7 Qiskit plus IBM Quantum
Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §12.7. Original sketches — package names (
Aer,IBMProvider, …) evolve; check current Qiskit docs. Continues 12.6. Labs: 12.7b.
Qiskit is an open-source SDK for circuits, simulators, and IBM hardware. Running the same circuit on a noiseless simulator and on a real backend shows how decoherence and gate error tilt histograms away from ideal peaks.
Local install (sketch)
conda create --name qiskit python=3.11
conda activate qiskit
pip install "qiskit[visualization]"
# IBM runtime / provider packages: follow current IBM Quantum docs
Save an API token once (local machine only):
# token_sketch.py — do not commit real tokens
# from qiskit_ibm_runtime import QiskitRuntimeService
# QiskitRuntimeService.save_account(channel="ibm_quantum", token="YOUR_TOKEN")
Bell circuit in Qiskit
# beta00_sketch.py — structure
from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
# circuit.draw("mpl") # local matplotlib
Same gate order as Composer / Cirq: H on qubit 0, CNOT control→target.
Statevector and density city plot
On a statevector simulator, retrieve the amplitudes and visualize of the density matrix (city plot). For ideal the imaginary part is zero and the real part shows the / block structure (Figure 12.6).
Graded labs lock the ideal amplitudes without importing Qiskit.
Hardware path (conceptual)
- Authenticate with your saved account.
- Pick an operational backend with enough qubits (historically “least busy”; APIs change).
measure_all()(or explicit measures), transpile to the device’s native gates / coupling map.- Submit the job, monitor, download counts.
Expect and to dominate, with small leakage into / from noise — unlike the perfect simulator.
Composer vs Qiskit vs Cirq
| Composer | Cirq | Qiskit | |
|---|---|---|---|
| UI | drag-drop | Python | Python |
| Default cloud | IBM | Google ecosystem | IBM |
| This course grades | concepts | amplitude / bit locks | amplitude / bit locks |
Takeaway
Build once, compare ideal statevector vs noisy counts. Token hygiene matters. Next chapter topics (QFT, algorithms) reuse the same circuit vocabulary.
Qiskit / IBM
1 / 3Minimal Bell circuit gate sequence is…
Pick an answer to see if you are right.
Next: 12.7b Qiskit labs.