Skip to content

Repository files navigation

Quantum vs Classical SVM: Cross-Framework Benchmarking on MNIST

License: MIT Python 3.10+

A capstone project for The Coding School — Qubit x Qubit program, continued investigating how quantum support vector machines (QSVMs) perform across three major quantum frameworks: PennyLane, Cirq, and Qiskit. This work reveals a critical insight often overlooked in quantum ML literature: framework choice significantly impacts classical baseline performance — sometimes more than the quantum model itself.

![Results Summary](Cirq_QSVM vs SVM.png, Pennylane_QSVM vs SVM.png, Qiskit_QSVM vs SVM.png)

🔬 Key Finding

While SVM accuracy remained stable at 99%. In PennyLane and Cirq implementations, accuracy varied dramatically (45.0% → 71.5% → 88.0%) depending solely on framework integration overhead. Training time similarly spanned three orders of magnitude (3.33s → 50.27s → 1057.90s).

💡 Novelty: First empirical demonstration that framework-specific implementation details—not quantum advantage alone—drive performance variations in QSVM benchmarking. Most prior work evaluates QSVMs within single frameworks; we benchmark identical models across three.

📊 Results Summary

Framework Model Accuracy (%) Time (s) Key Insight
PennyLane (NumPy) QSVM 71.5 3.33 Baseline impacted by minimal overhead
Classical SVM 99.0 0.00 Fastest simulation; lightweight wrapper
Cirq (TFQ) QSVM 88.0 50.27 Moderate integration overhead
Classical SVM 99.0 0.02 Balanced performance
Qiskit (Aer) QSVM 45.0 1057.90 ComputeUncompute bottleneck
Classical SVM 99.0 0.00 Full circuit simulation overhead

🧪 Methodology

  • Dataset: MNIST binary classification (digits 0 vs 1)
    • 14,780 total samples → 100 training / 200 test (NISQ constraints)
    • PCA dimensionality reduction to 2 features → 2-qubit amplitude encoding
  • Quantum Feature Map: ZZFeatureMap (2 repetitions) with RY rotations + CZ entanglement
  • Kernel: Fidelity-based quantum kernel $K(x_i,x_j) = |\langle 0|U^\dagger(x_i)U(x_j)|0\rangle|^2$
  • Classical Baseline: scikit-learn SVM with RBF kernel ($C=1.0$)
  • Hardware: Google Colab runtime (identical hardware across all runs)

🚀 Setup & Usage

Prerequisites

Core dependencies

pip install scikit-learn numpy matplotlib pandas

Quantum frameworks (install selectively based on notebook)

pip install pennylane # For PennyLane notebook pip install cirq # For Cirq notebook pip install qiskit # For Qiskit notebook pip install qiskit-machine-learning qiskit-aer qiskit-algorithms # Qiskit ML stack

About

Testing on the published article "Cross-Framework Benchmarking of Quantum Support Vector Machines on MNIST"

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages