Bernstein-Vazirani experiments executed across ideal simulation, backend-noise emulation, custom noise injections, and optional IBM Quantum hardware, with automated plotting and metric aggregation.
- Implements the Bernstein-Vazirani oracle and circuit for 5-qubit secrets (one ancillary qubit for phase kickback).
- Evaluates a fixed suite of 25 secret bitstrings to benchmark robustness under varied noise conditions.
- Single-shot oracle query recovers the hidden bitstring; correctness is assessed via the most frequent measurement outcome.
- Ideal simulation: Aer simulator without noise for each secret.
- Backend-noise emulation: Aer simulator with noise models derived from
ibm_torinoandibm_fezwhen available. - Real hardware (optional): runtime Sampler execution on
ibm_torinoandibm_fez; missing backends are reported and skipped. - Readout sweeps: injected symmetric readout errors across predefined levels (
ultra-lowtovery-high) with ideal overlays. - Custom noise sweeps: depolarizing, amplitude/phase damping, thermal relaxation, and gate-specific noise across the same intensity levels.
- Plots: horizontal histograms comparing ideal, emulated, noisy, and real results; readout and custom sweeps are saved per secret and noise kind.
- Create an isolated Python environment and install dependencies:
python -m venv .venv && source .venv/bin/activatepip install -r requirements.txt
- Populate
.envfrom.env.examplewhen using cloud backends.
QISKIT_IBM_TOKEN- IBM Quantum API token used by
QiskitRuntimeServicefor authentication.
- IBM Quantum API token used by
QISKIT_IBM_INSTANCE- IBM Cloud instance CRN to scope backend access.
QISKIT_IBM_CHANNELorIBM_QUANTUM_SERVICE- Service channel passed to
QiskitRuntimeService; if omitted, default channel resolution is used.
- Service channel passed to
- Execute the Bernstein-Vazirani suite:
python src/bv.py
- The script targets
ibm_torinoandibm_fezfor backend-noise emulation and real execution; other backends are ignored.
- Predictions:
Plot_results/bv_predictions.csvwith per-run category, backend, expected secret, predicted bitstring, correctness flag, top outcome probability, and raw counts. - Metrics:
Plot_results/bv_metrics.csvwith accuracy, macro precision/recall, and macro F1 per(category, backend)pair, including noise annotations. - Histograms: PNG files under
Plot_results/grouped by category:ideal/andnoisy/histograms per secret and backend.backend_comparison/overlays of ideal vs emulated vs real (when available).custom_noise/readout/sweep plots per secret; analogous folders for each custom noise kind.
- Cached counts: JSON histograms under
Plot_results/hist_data/to avoid recomputation on subsequent runs.