Skip to content

feat: add SVHN Quantum Kernel SVM benchmark#1175

Open
rich7420 wants to merge 3 commits intoapache:mainfrom
rich7420:svhn
Open

feat: add SVHN Quantum Kernel SVM benchmark#1175
rich7420 wants to merge 3 commits intoapache:mainfrom
rich7420:svhn

Conversation

@rich7420
Copy link
Contributor

@rich7420 rich7420 commented Mar 12, 2026

Related Issues

N/A

Changes

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Test
  • CI/CD pipeline
  • Other

Why

A Quantum Kernel SVM pipeline eliminates the iterative training loop — encoding becomes ~19% of total pipeline time, making QDP's GPU encoding advantage clearly visible in end-to-end results.

How

Added two new benchmark scripts that implement a Quantum Kernel SVM classification pipeline on SVHN:

SVHN (32×32×3) → StandardScaler → Amplitude Encode (3072→4096, 12 qubits)
  → Quantum Kernel K[i,j] = |⟨ψ(xⱼ)|ψ(xᵢ)⟩|² → SVM (precomputed) → 5-fold CV

New files

  • pennylane_baseline/svhn_kernel_amplitude.py — CPU encoding (L2-norm + zero-pad)
  • qdp_pipeline/svhn_kernel_amplitude.py — QDP GPU encoding (amplitude)

Benchmark results (RTX 3080)

5000 samples, 5-fold stratified CV, binary classification (digit 1 vs 7), C=100

Step CPU QDP GPU Speedup
Scale + Encode 0.648s 0.342s 1.89×
Kernel (matmul) 1.191s 0.788s 1.51×
CV fit + predict (5 folds) 1.597s 1.170s 1.36×
Total 3.44s 2.30s 1.49×

Accuracy: 0.9104 ± 0.0091 (identical for both pipelines)

How to run

# CPU baseline
python benchmark/encoding_benchmarks/pennylane_baseline/svhn_kernel_amplitude.py

# QDP GPU pipeline
python benchmark/encoding_benchmarks/qdp_pipeline/svhn_kernel_amplitude.py

# Custom parameters
python benchmark/encoding_benchmarks/qdp_pipeline/svhn_kernel_amplitude.py \
  --n-samples 10000 --folds 5 --svm-c 100

SVHN data (~180 MB) is auto-downloaded on first run.

Checklist

  • Added or updated unit tests for all changes
  • Added or updated documentation for all changes

Copy link
Member

@ryankert01 ryankert01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg, just need to be careful when we want to write an article about it:

  • baseline: cpu
  • qdp_pipeline: cpu -> gpu(encoding) -> cpu (train)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants