Skip to main content

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 ∣β00⟩|\beta_{00}\rangle 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.

Figure 12.5 reminder — H then CNOT.

Statevector and density city plot​

On a statevector simulator, retrieve the amplitudes and visualize Re/Im\mathrm{Re}/\mathrm{Im} of the density matrix ρ=∣ψ⟩⟨ψ∣\rho=|\psi\rangle\langle\psi| (city plot). For ideal ∣β00⟩|\beta_{00}\rangle the imaginary part is zero and the real part shows the ∣00⟩|00\rangle / ∣11⟩|11\rangle block structure (Figure 12.6).

Figure 12.6 — density city sketch.

Graded labs lock the ideal amplitudes 1/21/\sqrt2 without importing Qiskit.

Hardware path (conceptual)​

  1. Authenticate with your saved account.
  2. Pick an operational backend with enough qubits (historically “least busy”; APIs change).
  3. measure_all() (or explicit measures), transpile to the device’s native gates / coupling map.
  4. Submit the job, monitor, download counts.

Expect ∣00⟩|00\rangle and ∣11⟩|11\rangle to dominate, with small leakage into ∣01⟩|01\rangle / ∣10⟩|10\rangle from noise — unlike the perfect simulator.

Composer vs Qiskit vs Cirq​

ComposerCirqQiskit
UIdrag-dropPythonPython
Default cloudIBMGoogle ecosystemIBM
This course gradesconceptsamplitude / bit locksamplitude / bit locks

Takeaway​

Build once, compare ideal statevector vs noisy counts. Token hygiene matters. Next chapter topics (QFT, algorithms) reuse the same circuit vocabulary.

Quiz

Qiskit / IBM

1 / 3

Minimal Bell circuit gate sequence is…

Pick an answer to see if you are right.

Next: 12.7b Qiskit labs.