When computing the gradients of a quantum neural network using the parameter-shift rule, the cost function needs to be calculated twice for the gradient with respect to a single adjustable parameter of the network. When the total number of parameters is high, the quantum circuit for the computation has to be adjusted and run for many times. Here we propose an approach to compute all the gradients using a single circuit only, with a much reduced circuit depth and less classical registers. We also demonstrate experimentally, on both real quantum hardware and simulator, that our approach has the advantages that the circuit takes a significantly shorter time to compile than the conventional approach, resulting in a speedup on the total runtime.
翻译:在使用参数平移规则计算量子神经网络的梯度时,对于网络的单个可调参数,需要计算两次成本函数。当参数总数较多时,用于计算的量子电路必须多次调整并运行。本文提出了一种方法,仅使用单个电路即可计算所有梯度,同时大幅降低了电路深度并减少了经典寄存器的使用。我们还通过在真实量子硬件和模拟器上的实验证明,与传统方法相比,我们的方法在电路编译时间方面具有显著优势,从而实现了总运行时间的加速。