Source-linked AI summary
SPSA Hyperparameter Tuning for Variational Quantum Natural Language Inference
Nayan D'Souza, Christopher J. Agostino
TL;DR
The paper asks whether SPSA can provide a usable low-cost alternative to exact-gradient optimisation for supervised quantum language tasks. A broad hyperparameter search finds that AdamW-style SPSA reaches 55% ± 11% accuracy but remains 16–19 percentage points below parameter-shift baselines.
Problem
Few studies compare exact-gradient optimisers with SPSA on the same supervised QNLI task, leaving its optimisation trade-off unclear.
Method
The study grid-searches SPSA perturbation, learning-rate, and decay settings across three variants and compares them with parameter-shift AdamW and BuresQNG.
Results
55% ± 11% test accuracy is the best result for AdamW-style SPSA, up from 49% ± 6% by default but still 16–19 percentage points below parameter-shift baselines.
Takeaways & Limitations
The two-sample SPSA estimate remains too noisy for reliable optimisation of this 60-parameter task, and Bures preconditioning amplifies perturbation noise.
Takeaways & Limitations
SPSA’s expected O(P) training-time savings do not materialise here because full forward passes dominate runtime.
Abstract
from arXiv · showhide
Training variational quantum models requires choosing between parameter-shift gradients, which are exact but cost $O(P)$ forward evaluations, and simultaneous perturbation stochastic approximation (SPSA), which uses only two samples but produces high-variance estimates that can degrade optimisation on small supervised tasks. Whether the cheap gradient is usable depends on the variance that results from different choices of the SPSA perturbation scale, learning rate, and gain-decay schedule. We varied those quantities across a broad grid on a 6-qubit, 60-parameter QNLI classifier and compared the best configurations to parameter-shift AdamW and BuresQNG. AdamW-style SPSA with $c_0=0.01$, $η=0.10$, $γ=0.10$ reached $55\% \pm 11\%$ test accuracy, improving over the default configuration ($49\% \pm 6\%$) but remaining 16-19 percentage points below the parameter-shift baselines because the two-sample SPSA gradient estimate has too much variance for reliable optimisation of 60 parameters in 40 epochs. Classical-gain SPSA and Bures-preconditioned SPSA performed worse, at $51\%$ and $46\%$ respectively. Bures-preconditioning a noisy two-sample SPSA gradient amplifies perturbation noise.
1 Introduction
SPSA addresses the high cost of exact gradient estimation in variational quantum algorithms, but its usefulness for supervised quantum natural-language tasks remains unclear. This study grid-searches SPSA hyperparameters on a small QNLI task and compares three SPSA variants with parameter-shift baselines.
- Motivation: Stochastic approximation introduced gradient estimation from noisy observations using randomly chosen finite-difference directions.The approach avoids exact function evaluation but leaves error in the gradient estimate.
- Motivation: Parameter-shift methods provide exact gradients for many parameterized gates but require O(P) forward evaluations per parameter vector.Gradient estimation can therefore dominate training expense, especially as circuit size grows.
- Research gap: The crossover point where SPSA becomes worthwhile remains unclear because few studies compare exact-gradient optimisers and SPSA on the same supervised task.The gap is especially relevant for non-convex supervised natural-language objectives with coupled quantum and classical parameters.
- Contribution: The study grid-searches SPSA hyperparameters on a small QNLI task and compares classical-gain SPSA, AdamW-style SPSA, and Bures-preconditioned SPSA against parameter-shift AdamW and BuresQNG.This design directly evaluates multiple SPSA variants against exact-gradient optimisation baselines.
2 Methods
Experiments use a 6-qubit, 60-parameter QNLP classifier on a 300-example, three-label QNLI-style dataset, comparing parameter-shift and SPSA-based optimizers. The study evaluates 144 SPSA runs across perturbation, learning-rate, and gain-decay settings while measuring accuracy, loss, and training cost.
- Model architecture: The QNLPModel uses 6 qubits and 3 layers, with 36 circuit parameters plus 24 readout weights and biases, totaling 60 trainable parameters.NumPy statevector simulation is implemented in Qiskit.
- Model architecture: Word-level encoding initializes the first six words on separate qubits, and a linear classifier uses readout distributions plus their cosine similarity.Each sentence produces a 3-bin probability distribution; premise–hypothesis features are [p, h, sim(p, h)].
- Dataset and training: 300 QNLI-style examples cover entailment, contradiction, and neutral labels, split into 210 training and 90 test examples for 40 epochs.Optimization uses cross-entropy loss.
- Optimization methods: Five optimizers are compared: parameter-shift AdamW and BuresQNG, plus SPSA-classical, SPSA-AdamW, and BuresSPSA.BuresQNG recomputes a diagonal Bures metric every 5 epochs, while SPSA-AdamW accumulates SPSA gradients with AdamW-style moments.
- Hyperparameter evaluation: 144 SPSA runs span 48 configurations per variant, with c0, η, and γ varied and results aggregated as mean ± standard deviation across seeds 42, 2024, and 7.The perturbation scale follows ck = c0/k^γ, and each run records training loss, final test loss, and test accuracy.
- Computational cost: 4 s per epoch for SPSA variants versus 2.5 s for parameter-shift AdamW/BuresQNG, so expected O(P) savings do not materialize on this 60-parameter model.Full forward passes dominate runtime, making SPSA epochs comparable to or slightly longer than parameter-shift epochs.
3 Results
AdamW-style SPSA produced the strongest SPSA results, but remained below parameter-shift baselines and retained substantial variance. Small perturbations, slow gain decay, and moderate learning rates were favored, while BuresSPSA was unstable and low-performing.
- Best configurations: 55% ± 11% test accuracy was the best SPSA result, versus 49% ± 6% for default SPSA and roughly 72–74% for AdamW and BuresQNG.The best setting used c0 = 0.01, η = 0.10, and γ = 0.10, with 1.0 ± 0.02 test loss.
- Best configurations: 51% ± 8% was the best classical-gain SPSA result, while BuresSPSA reached 46% and most settings fell between 30% and 40%.Classical-gain SPSA achieved its best result at η = 0.50 and γ = 0.50.
- Hyperparameter trends: Nine of the top ten grid configurations used AdamW-style SPSA, clustering at c0 ≤0.05, γ = 0.10, and moderate learning rates around 0.10.Large learning rates of 0.50 frequently caused divergence or high variance; SPSA-AdamW at η = 0.50 and γ = 0.10 achieved 31% test accuracy.
- Variance: BuresSPSA was unstable, with standard deviations across seeds often reaching 10–18 percentage points.This instability accompanied low performance across the BuresSPSA grid.
- Training dynamics: AdamW and BuresQNG reached stable cross-entropy near 0.60, whereas AdamW-style SPSA stopped near 1.0 and BuresSPSA often increased loss after an initial drop.Test loss stayed near or above 1.0 for all SPSA variants, while AdamW and BuresQNG settled near 0.60.
- Variance: 11 percentage points was the best SPSA-AdamW standard deviation across three seeds, while c0 = 0.05, η = 0.10, γ = 0.50 produced 50% ± 20%.AdamW and BuresQNG had standard deviations of 13 and 9.5 percentage points at much higher mean accuracy.
4 Discussion
The grid search improved SPSA’s best accuracy, but its noisy two-sample gradients remained substantially worse than parameter-shift baselines. AdamW-style smoothing helped, whereas Bures preconditioning amplified noise rather than overcoming it.
- Performance gap: 55% best SPSA accuracy improved from 49%, but parameter-shift AdamW/BuresQNG reached 72–74%, preserving a 16–19 percentage-point gap.The strongest settings used small perturbations, moderate learning rates, and slow decay, but did not close the gap.
- Geometric preconditioning: Bures preconditioning amplified SPSA errors along geometrically sensitive directions instead of stabilizing the noisy gradient.The diagonal Bures metric rescales each parameter by inverse quantum sensitivity, so high-variance estimates can receive larger updates.
- Variance reduction: Reducing SPSA variance through averaged simultaneous perturbations is required before geometric preconditioning can become beneficial.The proposed remedy targets the noisy gradient estimate directly rather than relying only on update rescaling.
- Optimizer variants: AdamW-style moment accumulation consistently outperformed the classical decaying-gain schedule.First- and second-moment estimates smooth noisy directions and adapt per-parameter step sizes, but cannot eliminate underlying SPSA variance.
- Scaling outlook: Parameter-shift may become attractive for much larger encoders only when its wall-clock cost dominates and SPSA variance is reduced.Averaged perturbations or warm-start parameter-shift fine-tuning are suggested, but that regime was not studied here.
5 Conclusions
Hyperparameter tuning improved SPSA performance on the small QNLI classifier, but the best two-sample estimates remained well below parameter-shift baselines. AdamW-style momentum outperformed classical-gain and Bures-preconditioned SPSA, while SPSA’s gradient variance remained limiting.
- Hyperparameter tuning: 55% ± 11% test accuracy was achieved by AdamW-style SPSA with c0 = 0.01, η = 0.10, γ = 0.10, versus 49% ± 6% by default SPSA.The tuned result remained 16–19 percentage points below parameter-shift AdamW/BuresQNG.
- SPSA variants: Nine of the top ten grid configurations used AdamW-style SPSA, indicating stronger stabilisation than a classical decaying gain.Classical-gain SPSA peaked at 51% with η = 0.50 and γ = 0.50.
- SPSA variants: 46% was the best BuresSPSA result, and the method was unstable across seeds because preconditioning rescales high-variance estimates along sensitive circuit directions.Standard deviations across seeds were often 10–18 percentage points.
- Limitations and future work: The two-sample SPSA gradient variance limited reliable optimisation of the 60-parameter classifier, despite SPSA’s potential O(1) gradient-estimate savings on larger encoders.The larger-encoder regime was not covered by this experiment and may require variance reduction or warm-start strategies.