Source-linked AI summary
Recurrent Quantum Neural Networks
Johannes Bausch
TL;DR
The paper addresses whether recurrent quantum models can support sequence learning while mitigating gradient decay. It constructs and trains a structured QRNN with parametrized quantum neurons, evaluates it on sequence tasks and MNIST, and reports strong results on digit classification and long-range DNA recognition despite current hardware limitations.
Problem
Existing recurrent models face vanishing or exploding gradients on long sequences, motivating a quantum recurrent model that can preserve long-range information.
Method
The paper builds a structured QRNN cell from parametrized quantum neurons and amplitude amplification, implements it in PyTorch, and evaluates its topology and training across sequence-learning and image-classification tasks.
Results
The QRNN achieved up to 99.6% pairwise MNIST accuracy, ≈99.2% on all digits with augmentation, and unaffected training on 1000-base DNA sequences with targets over 500 steps earlier.
Takeaways & Limitations
The work demonstrates that a quantum recurrent model can ingest high-dimensional non-superposed data, train thousands of parameters, and perform non-trivial sequence and MNIST tasks.
Takeaways & Limitations
The QRNN is outclassed by existing recurrent models on real-world learning tasks because classical simulation limits qubit counts and parameter numbers.
Abstract
from arXiv · showhide
Recurrent neural networks are the foundation of many sequence-to-sequence models in machine learning, such as machine translation and speech synthesis. In contrast, applied quantum computing is in its infancy. Nevertheless there already exist quantum machine learning models such as variational quantum eigensolvers which have been used successfully e.g. in the context of energy minimization tasks. In this work we construct a quantum recurrent neural network (QRNN) with demonstrable performance on non-trivial tasks such as sequence learning and integer digit classification. The QRNN cell is built from parametrized quantum neurons, which, in conjunction with amplitude amplification, create a nonlinear activation of polynomials of its inputs and cell state, and allow the extraction of a probability distribution over predicted classes at each step. To study the model's performance, we provide an implementation in pytorch, which allows the relatively efficient optimization of parametrized quantum circuits with thousands of parameters. We establish a QRNN training setup by benchmarking optimization hyperparameters, and analyse suitable network topologies for simple memorisation and sequence prediction tasks from Elman's seminal paper (1990) on temporal structure learning. We then proceed to evaluate the QRNN on MNIST classification, both by feeding the QRNN each image pixel-by-pixel; and by utilising modern data augmentation as preprocessing step. Finally, we analyse to what extent the unitary nature of the network counteracts the vanishing gradient problem that plagues many existing quantum classifiers and classical RNNs.
1. Introduction
The paper introduces a quantum recurrent neural network designed for sequence learning, with a structured unitary cell intended to address gradient decay while remaining trainable on classical hardware. It evaluates the model on temporal tasks and MNIST, including long-sequence behavior.
- 1. Introduction: Long-sequence RNN training is hindered by vanishing or exploding gradients, while LSTMs and GRUs typically capture only limited context.The supplied introduction states that LSTMs and GRUs are typically limited to about 200 tokens and may ignore word order beyond 50 tokens.
- 1. Introduction: Transformer-type alternatives can outperform LSTMs but use fixed-width context windows that do not easily scale with sequence length.
- 1. Introduction: The paper constructs a QRNN with a structured parametrized quantum circuit, quantum neurons, and amplitude amplification that keeps correctly initialized evolution arbitrarily close to unitary.
- 1. Introduction: The QRNN is implemented in PyTorch and benchmarked on Elman sequence-learning tasks to study cell-state size, cell topology, and optimizer hyperparameters.The optimizers include Adam, RMSProp, SGD, and L-BFGS.
- 1. Introduction: 99.6% accuracy was achieved for pairwise MNIST digit discrimination, while all-digit classification reached ≈99.2% with modern data augmentation.
- 1. Introduction: The model's long-sequence training remained unaffected for 1000-base DNA strings when target base pairs were over 500 steps in the past.
- 1. Introduction: The authors acknowledge that the model does not yet compete with state-of-the-art scores on much larger datasets than MNIST.
2. Recurrent Quantum Neural Networks
The QRNN uses structured parametrized quantum circuits and higher-degree quantum neurons to create nonlinear recurrent processing while retaining unitary operations. Its cell writes inputs to state, computes through work stages, and outputs class probabilities iteratively.
- Parametrized quantum gates: Structured QRNN circuits reuse few parameters, with each parameter steering a higher-level logical unit than in typical VQE circuits.This design addresses the training difficulty associated with dense VQE-style circuits on larger inputs.
- Sequence-to-sequence model: During training, amplitude amplification is applied to output lanes so the correct target token is measured at each step while measurements remain close to unitary.The QRNN cell is then applied iteratively to the input sequence.
- Sequence-to-sequence model: The circuits can be comparatively deep but require qubits proportional to input and cell-state widths, plus ancillas for neurons and amplification.Figure 5 expresses the requirement as H + I + ord qubits, with workspace size H, input width I, and neuron order ord.
- Higher-degree quantum neuron: Higher-order activations are implemented recursively, with order ord controlling activation shape and fixed-point amplitude amplification preserving near-unitary postselection.Amplitude amplification alleviates history-dependent amplitudes for superposed inputs, at the cost of multiple circuit rounds.
- Higher-degree quantum neuron: Quantum neurons generate nonlinear amplitudes by applying controlled rotations to polynomial transformations of binary inputs.The neuron extends the original construction with multi-control gates whose degree d determines the polynomial order.
- Sequence-to-sequence model: The recurrent cell resets input and output lanes while passing an internal cell state between iterations.It combines an input stage, multiple work stages accessing input and state, and an output stage that produces a probability distribution over predictions.
3. Implementation and Training
The QRNN is implemented in PyTorch as a quantum-circuit simulation with postselection shortcuts and direct gradient-based optimization. Experiments use character-level cross-entropy training and parallel data batching.
- Implementation: The PyTorch implementation uses custom quantum gate layers to extract predicted distributions at each step.During training, it postselects instead of explicitly performing fixed-point amplitude amplification and tracks postselection probabilities for overhead estimates.
- Training: Character-level training feeds predicted distributions into nn.CrossEntropyLoss against target sequences.PyTorch autograd enables direct gradient-based learning in the simulation.
- Training: On quantum hardware, the training setup would require gradient-free or numerical-gradient optimization instead of the simulation's direct autograd gradients.The passage names L-BFGS and NatGrad as possible gradient-free optimizers.
- Implementation: Experiments ran on 2–8 CPUs, used 500MB–35GB of memory per core, and supported parallel batch training.Real-hardware batching would execute identical QRNN parameters across multiple devices and average the resulting losses.
4. Empirical Results
The QRNN was evaluated on sequence memorization, temporal-structure learning, long-sequence prediction, and MNIST classification, with optimizer and topology choices benchmarked empirically. Results include stable training on sequences of length 1000, strong digit-pair and all-digit accuracy, and generative reconstruction of handwritten digits.
- 4.1. Sequence Memorization: The QRNN sequence-learning setup benchmarked optimizer and learning-rate choices using memorization tasks and a 1162-parameter model.The model reproduced repeated 4s and the sequence 12312… while Figure 6 compared SGD, RMSprop, Adam, and L-BFGS after 500 steps.
- 4.1. Sequence Memorization: Adam was selected as the default optimizer because it was relatively robust to learning-rate choice and generally converged faster than RMSprop.SGD had a narrow effective learning-rate range, while L-BFGS was costly and unpredictable outside simple sequence tasks.
- 4.1. Sequence Memorization: A bias initialization of µ = π/4 produced a large initial gradient by placing the activation polynomial at its steepest slope.The study treated bias, weight, and unitary initialization scales as separate parameter-group hyperparameters.
- 4.2. Finding Structure in Time: Neuron order ord = 2 performed best on Elman’s sentence-structure task because its activation combined steep flanks with plateau regions retaining small nonzero gradients.The task required predicting repeated letter patterns after observing word fragments such as “ba”, “dii”, and “guuu”.
- 4.3. MNIST Classification: The MNIST preprocessing pipeline reduced cropped images to 10×10 binary pixels, producing input sequences of length 100 as a computational compromise.The feature-extraction alternatives included t-SNE and UMAP with discretized coordinates; lower discretization resolution diminished information content.
5. Conclusion and Outlook
The paper presents QRNNs as an exploratory quantum recurrent architecture that runs on classical hardware, performs non-trivial sequence and image tasks, and may suit systems with limited qubit counts. It also identifies clear limitations in simulation cost, architectural simplicity, and current performance.
- Classical recurrent models outperform the proposed QRNN on real-world learning tasks because simulating many qubits requires exponentially growing classical memory.The authors note that this overhead would vanish on a quantum computer, where execution time would scale linearly with circuit depth.
- QRNNs demonstrate non-trivial sequence-learning and handwriting-recognition performance despite using usually 8–14 qubits.The authors emphasize that this performance is notable given the small number of qubits used.
- The QRNN cell remains simplistic relative to classical RNN and LSTM components, and a more specialized circuit structure will likely outperform it.
- The architecture runs on current hardware and ML implementations such as PyTorch, and is a candidate parametrization for unitary recurrent models.
- Convergence times may improve through more thorough tuning of hyperparameters, optimizers, activation functions, or trainable capacity.For sequences of length 100 or longer, some RNN runs timed out at 100k training steps, so those data require caution.
- The quantum model ingests non-superposed data much larger than a few bits, supports models with large parameter counts, and brings MNIST classification within reach for variational quantum algorithms.
- Variants could be combined with quantum beam search for language modelling or used to model quantum-system dynamics with their growing phase-space dimension.
A. QRNN Postselection Analysis
QRNN postselection uses fixed-point oblivious amplitude amplification to increase the probability of desired measurement outcomes without requiring prior knowledge of the relevant amplitude. This introduces quantum-device overhead from repeated circuit and inverse-circuit applications.
- Amplitude amplification is used at two QRNN locations, with postselection measurements requiring repeated sub-circuits and their inverse operations on quantum devices.The overhead is absent classically because the full statevector is available for postselection.
- Amplitude amplification raises the probability of measuring the desired component of a state from a likelihood proportional to |α|^2 toward one.
- Fixed-point oblivious amplitude amplification applies when a unitary produces the state and the amplitude α is unknown.Repeated applications of U and U† amplify the desired measurement outcome.
A.1. Quantum Neuron
The QRNN quantum neuron requires amplitude amplification so that its intended nonlinear transformation works across the full Hilbert space of input states. The resulting overhead depends strongly on the neuron order, while failures can be controlled through repetition.
- Amplitude amplification is required for each quantum neuron because measuring the undesired outcome produces a wrong operation.The neurons resemble repeat-until-success circuits, but their recovery operation is not sufficient for the full input-state Hilbert space.
- Postselecting on measuring 0 ensures the quantum neuron works as intended on the full Hilbert space of input states.
- The failure probability can be reduced to ϵ by repeating the entire QRNN run after a detected failure, with at most logarithmic overhead in ϵ and the number of postselections.
- The overhead analysis asks how many applications of the neuron and its inverse are needed to realize the intended nonlinear transformation.
- For neuron orders 1, 2, 3, and 4, the estimated amplitude-amplification overheads are about 2, 8, 128, and 32768, respectively.The experiments use ord = 2, chosen from empirical evidence and the resulting activation function.
A.2. QRNN Cell Output
During QRNN-cell training, input and output lanes are reset and measured output words define predictive distributions, while postselection avoids harmful state collapse. Empirically, overhead varies with lane width and task complexity.
- QRNN Cell Output: The cell writes the input bit string, processes it with the hidden state, resets the input/output lanes, and measures an output word.
- QRNN Cell Output: Measuring the output word produces a distribution over predicted letters, and the measured outcome determines which hidden cell state is retained.
- QRNN Cell Output: State collapse supports generative inference by making measured pixels influence the likelihood of subsequent handwritten-digit pixels.
- QRNN Cell Output: During training, output-state collapse performs poorly because early output distributions do not meaningfully correlate measured outputs with the resulting internal state.
- QRNN Cell Output: Postselecting on the expected next letter avoids this training problem, requiring repetition of only the current QRNN cell unitary and its inverse.Iteratively applying the entire preceding QRNN would create an exponential runtime overhead.
- Postselection Analysis: The overall postselection overhead is relatively small but increases with wider input/output lanes.
- Postselection Analysis: For memorization and simple-sequence tasks, overhead begins larger and converges to one; for pixel-by-pixel MNIST, it converges to a roughly constant value greater than one.
B. QRNN Network Topology
The QRNN topology study evaluates neuron degree, work stages, workspace size, and cell bias for sequence learning, finding that intermediate complexity generally converges fastest. The preferred configuration depends on task information capacity, with workspace six sufficient for augmented MNIST and workspace eight better for pixel-by-pixel MNIST.
- Workspace: A higher neuron degree becomes useful only when workspace size increases accordingly, because the three-bit input bounds the useful input-stage degree.The task input has width three bits, sufficient to encode the six letters used.
- Neuron degree: Degree two is optimal for the sequence task; degree three is no better, while degree four increases expected convergence time.Higher-degree neurons require more parameters, which likely explains the longer convergence time.
- Work stages: Two work stages learn considerably faster than one, while adding more stages increases learning time again.The comparison indicates an intermediate cell depth is preferable for this task.
- Workspace: Workspace improves learning speed but reaches a plateau at ≥6 qubits for the simple sequence task.The figure reports degree 2, workspace 6, and 2 stages as the best combination for sentence learning.
- Task-dependent capacity: Workspace six suffices for augmented MNIST, whereas workspace eight performs better for pixel-by-pixel MNIST.The augmented-MNIST configuration uses a two-bit input, order-2 neurons, two ancillas, and ten qubits overall.
- Cell bias: The cell bias µ = π/8 yields the fastest convergence in the reported parameter comparisons.The comparison is shown for the QRNN cell configuration described in the topology analysis.