Quantum operations on pure states can be fully represented by unitary matrices. Variational quantum circuits, also known as quantum neural networks, embed data and trainable parameters into gate-based operations and optimize the parameters via gradient descent. The high cost of training and low fidelity of current quantum devices, however, restricts much of quantum machine learning to classical simulation. For few-qubit problems with large datasets, training the matrix elements directly, as is done with weight matrices in classical neural networks, can be faster than decomposing data and parameters into gates. We propose a method that trains matrices directly while maintaining unitarity through a single regularization term added to the loss function. A second training step, circuit alignment, then recovers a gate-based architecture from the resulting soft-unitary. On a five-qubit supervised classification task with 1000 datapoints, this two-step process produces a trained variational circuit in under four minutes, compared to over two hours for direct circuit training, while achieving lower binary cross-entropy loss. In a second experiment, soft-unitaries are embedded in a hybrid quantum-classical network for a reinforcement learning cartpole task, where the hybrid agent outperforms a purely classical baseline of comparable size.
Figures & tables
Figure 1: Classification of a top-hat function comparing a directly trained VQC, the soft-unitary solution, and the circuit-aligned VQC. Outputs are rescaled from [−1,1] to [0,1] via a global shift and division by two. Both models use 5 qubits, 1000 datapoints, 200 epochs, 3 reuploading layers, and 4 variational layers. Circuit depth is 10 basic entangling layers per variational layer for the VQC and 69 basic entangling layers for the circuit-aligned soft-unitary.
Figure 2: Training loss versus wall-clock time for the soft-unitary and the directly trained VQC. The soft-unitary loss decreases faster and reaches lower values because it is unconstrained by ansatz and independent of gate count.
Figure 3: Circuit alignment loss, measured as the matrix norm ∥Utarget−Ucircuit∥ , versus epoch. Lower values indicate better agreement between the target soft-unitary and the compiled circuit.
Figure 4: Difference in output values between the soft-unitary and the circuit-aligned model. The mean squared error between the two outputs is 9.6×10−6 .
Figure 5: The cartpole problem. At each timestep the agent observes the cart’s position, cart’s velocity, pole angle, and pole angular velocity, and must decide whether to push the cart left or right to keep the pole upright for as long as possible.
Figure 6: Comparison of the cartpole task between a purely classical and a hybrid quantum-classical neural network. Both architectures have roughly the same number of classical weights. Duration measures how long the agent keeps the pole upright (higher is better); the dotted line shows the raw duration and the solid line shows the running average. Over 340 episodes, the classical network reached a mean duration of 232.9 while the hybrid model reached 417.0 . The last 71 episodes of the hybrid model were all maxed out at 500.