[QDP] Add SVHN IQP encoding benchmark with PennyLane baseline and QDP pipeline #1186
Open
ryankert01 wants to merge 2 commits intoapache:mainfrom
Open
[QDP] Add SVHN IQP encoding benchmark with PennyLane baseline and QDP pipeline #1186ryankert01 wants to merge 2 commits intoapache:mainfrom
ryankert01 wants to merge 2 commits intoapache:mainfrom
Conversation
Member
Author
|
It's not production code rn. will fix them when i have time. edit: it's ready now. |
3d00ce7 to
edb9e21
Compare
Member
Author
|
Ready for review! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new SVHN (digit 1 vs 7) IQP-encoding benchmark to compare PennyLane’s gate-by-gate embedding against a QDP one-shot encoding + StatePrep training pipeline, including CPU and GPU training backends.
Changes:
- Add SVHN IQP benchmark scripts for (1) pure PennyLane baseline and (2) QDP encoding +
StatePreppipeline. - Update benchmark dependency group to include newer PennyLane/Lightning GPU (py>=3.11) and SciPy (for SVHN
.matloading). - Update benchmark README with SVHN IQP usage instructions and refresh lockfiles.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Updates locked dependencies and benchmark requirement markers (incl. PennyLane/Lightning, SciPy). |
qdp/qdp-python/uv.lock |
Updates QDP Python workspace lock to include PennyLane 0.44.x + Lightning GPU deps. |
qdp/qdp-python/pyproject.toml |
Adds benchmark deps for PennyLane>=0.44 / Lightning GPU (py>=3.11) and SciPy. |
qdp/qdp-python/benchmark/encoding_benchmarks/qdp_pipeline/svhn_iqp.py |
New QDP pipeline benchmark: one-shot IQP encoding via QDP + StatePrep training (CPU/GPU). |
qdp/qdp-python/benchmark/encoding_benchmarks/pennylane_baseline/svhn_iqp.py |
New baseline benchmark: IQP circuit inside QNode (CPU/GPU). |
qdp/qdp-python/benchmark/encoding_benchmarks/README.md |
Documents how to run the new SVHN IQP benchmarks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
qdp/qdp-python/benchmark/encoding_benchmarks/pennylane_baseline/svhn_iqp.py
Show resolved
Hide resolved
qdp/qdp-python/benchmark/encoding_benchmarks/qdp_pipeline/svhn_iqp.py
Outdated
Show resolved
Hide resolved
Member
Author
|
fixed at f5b91a5 |
Member
Author
|
PTAL @guan404ming |
- Changed revision from 3 to 2. - Added conditional specifications for 'pennylane' and 'pennylane-lightning' for Python 3.11 and above. - Included 'scipy' with a minimum version of 1.11.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Introduction
QDP (Quantum Data Plane) is a CUDA-accelerated quantum state encoding library that
converts classical feature vectors into quantum state vectors using GPU kernels. This
report compares QDP's one-shot encoding approach against PennyLane's gate-by-gate
encoding for IQP (Instantaneous Quantum Polynomial) circuits in a variational
classification task on the SVHN dataset.
Key insight: PennyLane embeds the IQP encoding circuit (Hadamard-Phase-Hadamard
gates) inside the quantum node, so it re-executes on every forward and backward pass.
QDP encodes all samples once upfront on GPU, then feeds pre-computed state vectors via
StatePrepduring training. This eliminates redundant encoding and enables zero-copyGPU tensor sharing with
lightning.gpu.2. Method
2.1 Task
Binary classification on SVHN (digit 1 vs 7):
n_qubitsdimensionsexpval(PauliZ(0))2.2 IQP Encoding
The IQP circuit implements: H^n * Diag(phases) * H^n |0>^n
where phases include single-qubit terms z_i = features[i] and two-qubit terms
z_{ij} = features[i] * features[j] for all pairs i < j. This creates n + n(n-1)/2
parametric gates per sample.
2.3 Four Configurations
default.qubit(CPU)lightning.gpu(GPU)default.qubit(CPU)lightning.gpu(GPU)2.4 Hardware
3. Results
3.1 Accuracy Parity (Experiment 2)
Goal: Prove identical quantum states by showing matching accuracy across all configs.
Fixed parameters: 6 qubits, 200 samples, 200 iterations, batch size 10, 4 layers, seed 42, 1 trial.
All four configurations produce identical test accuracy (0.6750), confirming that
QDP's CUDA-encoded state vectors match PennyLane's gate-by-gate construction. The CPU
configs (PL-CPU, QDP-CPU) produce exact numerical agreement because both use
default.qubitwith deterministic autograd.QDP encoding time: 9.6 ms to encode all 200 samples (one-shot).
3.2 Qubit Scaling (Experiment 1)
Goal: Show QDP's advantage grows with qubit count.
Fixed parameters: 200 samples, 200 iterations, batch size 10, 4 layers, seed 42, 3 trials.
3.2.1 Training Time (mean of 3 trials, seconds)
3.2.2 Speedup Ratios (PL / QDP)
The GPU speedup (PL-GPU vs QDP-GPU) peaks at 1.51x at 6 qubits and remains
significant across all tested qubit counts. The cross speedup (PL-CPU vs QDP-GPU)
reaches 3.56x at 10 qubits, combining the benefits of one-shot encoding with GPU
training.
3.2.3 QDP One-Shot Encoding Time
QDP's encoding time is essentially constant (~10 ms) regardless of qubit count
for this dataset size, thanks to GPU parallelism. This is negligible compared to
training time (36-253 seconds).
3.2.4 Throughput (samples/sec, mean of 3 trials)
QDP-GPU consistently delivers the highest throughput at every qubit count.
3.3 Zero-Copy Advantage
The QDP-CPU vs QDP-GPU comparison isolates the effect of keeping encoded tensors on
GPU (zero copy) versus copying them to CPU after encoding:
The zero-copy advantage grows with qubit count (2.39x to 3.06x), reflecting the
increasing benefit of GPU-native state vector operations as the Hilbert space
dimension grows.
3.4 Test Accuracy Consistency
All configurations produce identical test accuracy at the same qubit count (seed = 42):
At 6+ qubits, all configs converge to the same accuracy. Minor variations at 4
qubits are due to different circuit structure (QDP uses
StatePrepvs PennyLane'sgate-by-gate IQP) and floating-point non-determinism on GPU.
4. Discussion
Why QDP is Faster
One-shot encoding: QDP encodes all samples once (~10 ms) regardless of training
iterations. PennyLane re-runs n + n(n-1)/2 parametric gates per sample per step.
Simpler training circuit: QDP's circuit uses
StatePrep(one operation) insteadof the full H-D-H IQP gate sequence. This reduces per-step circuit complexity.
Zero-copy GPU path: QDP-GPU keeps encoded tensors on GPU, avoiding GPU->CPU
data transfer. Combined with
lightning.gpufor training, the entire pipelinestays on GPU.
Where QDP Matters Most
that's 55 gates removed from every forward pass.
size 10, PennyLane executes the IQP circuit ~4000 times (200 iters x 2 for
forward/backward x 10 samples). QDP does it zero times during training.
(up to 3.56x vs PL-CPU).
Limitations
the IQP circuit is small relative to variational layers.
default.qubit(CPU) andlightning.gpu(GPU) state vectorsimulators. Results on real quantum hardware would differ.
task, not by the encoding method.
5. Reproduction
Prerequisites
cd qdp/qdp-python uv sync --group benchmarkExperiment 2: Accuracy Parity
Experiment 1: Qubit Scaling